Skip to content

Commit 2d970d0

Browse files
committed
fix: proper search regex for json body start/end
1 parent 58a62d9 commit 2d970d0

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lua/rest-nvim/init.lua

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local vim = vim
21
local api, fn = vim.api, vim.fn
32

43
local curl = require('plenary.curl')
@@ -71,8 +70,8 @@ local function get_body(bufnr, stop_line, query_line, json_body)
7170
local start_line = 0
7271
local end_line = 0
7372

74-
start_line = fn.search('{', '', stop_line)
75-
end_line = fn.search('}', 'n', stop_line)
73+
start_line = fn.search('^{', '', stop_line)
74+
end_line = fn.search('^}', 'n', stop_line)
7675

7776
if start_line > 0 then
7877
local json_string = ''

syntax/http.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ syn match httpHeaderKey "^\(\w\)[^:]\+" nextgroup=httpHeaderSeparator skip
1212
syn match httpHeaderSeparator "[=:]" contained
1313

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

1717

1818
hi link httpComment Comment

0 commit comments

Comments
 (0)