@@ -149,15 +149,14 @@ end
149149
150150-- get_headers retrieves all the found headers and returns a lua table with them
151151-- @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 )
154155 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
158157
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
161160 local line = vim .fn .getbufline (bufnr , line_number )
162161 local line_content = line [1 ]
163162
@@ -302,15 +301,15 @@ rest.run = function(verbose)
302301
303302 local start_line = start_request ()
304303 if start_line == 0 then
305- error (" [rest.nvim]: No request found" )
304+ vim . api . nvim_err_writeln (" [rest.nvim]: No request found" )
306305 return
307306 end
308307 local end_line = end_request ()
309308 go_to_line (bufnr , start_line )
310309
311310 local parsed_url = parse_url (vim .fn .getline (start_line ))
312311
313- local headers , body_start = get_headers (bufnr , start_line )
312+ local headers , body_start = get_headers (bufnr , start_line , end_line )
314313
315314 local body = get_body (bufnr , body_start , end_line )
316315
0 commit comments