@@ -149,15 +149,14 @@ end
149
149
150
150
-- get_headers retrieves all the found headers and returns a lua table with them
151
151
-- @param bufnr Buffer number, a.k.a id
152
- -- @param query_line Line to set cursor position
153
- local function get_headers (bufnr , query_line )
152
+ -- @param start_line Line where the request starts
153
+ -- @param end_line Line where the request ends
154
+ local function get_headers (bufnr , start_line , end_line )
154
155
local headers = {}
155
- -- Set stop at end of buffer
156
- local stop_line = vim .fn .line (" $" )
157
- local body_start = 0
156
+ local body_start = end_line
158
157
159
- -- Iterate over all buffer lines
160
- for line_number = query_line + 1 , stop_line do
158
+ -- Iterate over all buffer lines starting after the request line
159
+ for line_number = start_line + 1 , end_line do
161
160
local line = vim .fn .getbufline (bufnr , line_number )
162
161
local line_content = line [1 ]
163
162
@@ -302,15 +301,15 @@ rest.run = function(verbose)
302
301
303
302
local start_line = start_request ()
304
303
if start_line == 0 then
305
- error (" [rest.nvim]: No request found" )
304
+ vim . api . nvim_err_writeln (" [rest.nvim]: No request found" )
306
305
return
307
306
end
308
307
local end_line = end_request ()
309
308
go_to_line (bufnr , start_line )
310
309
311
310
local parsed_url = parse_url (vim .fn .getline (start_line ))
312
311
313
- local headers , body_start = get_headers (bufnr , start_line )
312
+ local headers , body_start = get_headers (bufnr , start_line , end_line )
314
313
315
314
local body = get_body (bufnr , body_start , end_line )
316
315
0 commit comments