Skip to content

Commit 3d4bec4

Browse files
authored
Merge pull request #146 from alanoliveira/fix/fix_get_body
Fix get_body function
2 parents 4a23d38 + 7794b88 commit 3d4bec4

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lua/rest-nvim/request/init.lua

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local function get_importfile_name(bufnr, start_line, stop_line)
1111
local oldpos = vim.fn.getcurpos()
1212
utils.move_cursor(bufnr, start_line)
1313

14-
local import_line = vim.fn.search("^<", "n", stop_line)
14+
local import_line = vim.fn.search("^<", "cn", stop_line)
1515
-- restore old cursor position
1616
utils.move_cursor(bufnr, oldpos[2])
1717

@@ -43,10 +43,6 @@ end
4343
-- @param stop_line Line where body stops
4444
-- @param has_json True if content-type is set to json
4545
local function get_body(bufnr, start_line, stop_line, has_json)
46-
if start_line >= stop_line then
47-
return
48-
end
49-
5046
-- first check if the body should be imported from an external file
5147
local importfile = get_importfile_name(bufnr, start_line, stop_line)
5248
local lines
@@ -56,7 +52,7 @@ local function get_body(bufnr, start_line, stop_line, has_json)
5652
end
5753
lines = utils.read_file(importfile)
5854
else
59-
lines = vim.api.nvim_buf_get_lines(bufnr, start_line, stop_line, false)
55+
lines = vim.api.nvim_buf_get_lines(bufnr, start_line - 1, stop_line, false)
6056
end
6157

6258
local body = ""

0 commit comments

Comments
 (0)