Skip to content

Commit

Permalink
fix: proper search regex for json body start/end
Browse files Browse the repository at this point in the history
  • Loading branch information
NTBBloodbath committed Jun 10, 2021
1 parent 58a62d9 commit 2d970d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lua/rest-nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local vim = vim
local api, fn = vim.api, vim.fn

local curl = require('plenary.curl')
Expand Down Expand Up @@ -71,8 +70,8 @@ local function get_body(bufnr, stop_line, query_line, json_body)
local start_line = 0
local end_line = 0

start_line = fn.search('{', '', stop_line)
end_line = fn.search('}', 'n', stop_line)
start_line = fn.search('^{', '', stop_line)
end_line = fn.search('^}', 'n', stop_line)

if start_line > 0 then
local json_string = ''
Expand Down
2 changes: 1 addition & 1 deletion syntax/http.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ syn match httpHeaderKey "^\(\w\)[^:]\+" nextgroup=httpHeaderSeparator skip
syn match httpHeaderSeparator "[=:]" contained

syn include @json syntax/json.vim
syn region jsonBody start="\v\{" end="\v\}$" contains=@json keepend
syn region jsonBody start="\v^\{" end="\v^\}$" contains=@json keepend


hi link httpComment Comment
Expand Down

0 comments on commit 2d970d0

Please sign in to comment.