7171-- get_importfile returns in case of an imported file the absolute filename
7272-- @param bufnr Buffer number, a.k.a id
7373-- @param stop_line Line to stop searching
74- local function get_importfile (bufnr ,start_line , stop_line )
75- -- store old cursor position
76- local oldpos = vim .fn .getcurpos ()
77- go_to_line (bufnr , start_line )
74+ local function get_importfile (bufnr , start_line , stop_line )
75+ -- store old cursor position
76+ local oldpos = vim .fn .getcurpos ()
77+ go_to_line (bufnr , start_line )
7878
7979 local import_line = vim .fn .search (' ^<' , ' n' , stop_line )
80- -- restore old cursor position
81- go_to_line (bufnr , oldpos [2 ])
80+ -- restore old cursor position
81+ go_to_line (bufnr , oldpos [2 ])
8282
8383 if import_line > 0 then
8484 local fileimport_string = ' '
@@ -111,37 +111,31 @@ end
111111-- @param start_line Line where body starts
112112-- @param stop_line Line where body stops
113113local function get_body (bufnr , start_line , stop_line )
114- if start_line >= stop_line then
115- return
116- end
114+ if start_line >= stop_line then
115+ return
116+ end
117117
118118 -- first check if the body should be imported from an external file
119119 local importfile = get_importfile (bufnr , start_line , stop_line )
120120 if importfile ~= nil then
121121 return importfile
122122 end
123123
124- local lines = {}
125- local body = " "
126- -- nvim_buf_get_lines is zero based and end-exclusive
127- -- but start_line and stop_line are one-based and inclusive
128- -- magically, this fits :-) start_line is the CRLF between header and body
129- -- which should not be included in the body, stop_line is the last line of the body
130- lines = vim .api .nvim_buf_get_lines (
131- bufnr ,
132- start_line ,
133- stop_line ,
134- false
135- )
136- for _ , line in ipairs (lines ) do
137- -- Ignore commented lines with and without indent
138- if not utils .contains_comments (line ) then
139- body = body
140- .. utils .replace_vars (line )
141- end
142- end
143-
144- return body
124+ local lines = {}
125+ local body = ' '
126+ -- nvim_buf_get_lines is zero based and end-exclusive
127+ -- but start_line and stop_line are one-based and inclusive
128+ -- magically, this fits :-) start_line is the CRLF between header and body
129+ -- which should not be included in the body, stop_line is the last line of the body
130+ lines = vim .api .nvim_buf_get_lines (bufnr , start_line , stop_line , false )
131+ for _ , line in ipairs (lines ) do
132+ -- Ignore commented lines with and without indent
133+ if not utils .contains_comments (line ) then
134+ body = body .. utils .replace_vars (line )
135+ end
136+ end
137+
138+ return body
145139end
146140
147141-- is_request_line checks if the given line is a http request line according to RFC 2616
@@ -162,7 +156,7 @@ local function get_headers(bufnr, query_line)
162156 local headers = {}
163157 -- Set stop at end of buffer
164158 local stop_line = vim .fn .line (' $' )
165- local body_start = 0
159+ local body_start = 0
166160
167161 -- Iterate over all buffer lines
168162 for line_number = query_line + 1 , stop_line do
@@ -172,7 +166,7 @@ local function get_headers(bufnr, query_line)
172166 -- message header and message body are seperated by CRLF (see RFC 2616)
173167 -- for our purpose also the next request line will stop the header search
174168 if is_request_line (line_content ) or line_content == ' ' then
175- body_start = line_number
169+ body_start = line_number
176170 break
177171 end
178172 if not line_content :find (' :' ) then
0 commit comments