@@ -16,7 +16,7 @@ function! vimtex#parser#tex#parse(file, opts) abort " {{{1
1616 \ ' default' : {' ftime' : -2 },
1717 \} )
1818
19- let l: parsed = s: parse (a: file , l: opts , l: cache )
19+ let l: parsed = s: parse (a: file , l: opts.root , l: cache )
2020
2121 if ! l: opts .detailed
2222 call map (l: parsed , ' v:val[2]' )
@@ -37,7 +37,7 @@ function! vimtex#parser#tex#parse_files(file, opts) abort " {{{1
3737 \ ' default' : {' ftime' : -2 },
3838 \} )
3939
40- return vimtex#util#uniq_unsorted (s: parse_files (a: file , l: opts , l: cache ))
40+ return vimtex#util#uniq_unsorted (s: parse_files (a: file , l: opts.root , l: cache ))
4141endfunction
4242
4343" }}}1
@@ -55,7 +55,7 @@ function! vimtex#parser#tex#parse_preamble(file, opts) abort " {{{1
5555 let l: time = min ([localtime () - 60 , getftime (a: file )])
5656 if l: time > l: current .time
5757 let l: current .time = l: time
58- let l: current .lines = s: parse_preamble (a: file , l: opts , [])
58+ let l: current .lines = s: parse_preamble (a: file , l: opts.root , [])
5959 endif
6060
6161 return deepcopy (l: current .lines )
@@ -179,12 +179,12 @@ endfunction
179179" }}}1
180180
181181
182- function ! s: parse (file , opts , cache) abort " {{{1
182+ function ! s: parse (file , root , cache) abort " {{{1
183183 let l: current = a: cache .get (a: file )
184184 let l: ftime = getftime (a: file )
185185 if l: ftime > l: current .ftime
186186 let l: current .ftime = l: ftime
187- call s: parse_current (a: file , a: opts , l: current )
187+ call s: parse_current (a: file , a: root , l: current )
188188 endif
189189
190190 let l: parsed = []
@@ -193,37 +193,35 @@ function! s:parse(file, opts, cache) abort " {{{1
193193 if type (l: val ) == v: t_list
194194 call add (l: parsed , l: val )
195195 else
196- call extend ( l: parsed, s: parse (l: val, a: opts , a: cache) )
196+ let l: parsed += s: parse (l: val. file , l: val .new_root , a: cache )
197197 endif
198198 endfor
199199
200200 return l: parsed
201201endfunction
202202
203203" }}}1
204- function ! s: parse_files (file , opts , cache) abort " {{{1
204+ function ! s: parse_files (file , root , cache) abort " {{{1
205205 let l: current = a: cache .get (a: file )
206206 let l: ftime = getftime (a: file )
207207 if l: ftime > l: current .ftime
208208 let l: current .ftime = l: ftime
209- call s: parse_current (a: file , a: opts , l: current )
209+ call s: parse_current (a: file , a: root , l: current )
210210 endif
211211
212212 " Only include existing files
213213 if ! filereadable (a: file ) | return [] | endif
214214
215215 let l: files = [a: file ]
216216 for l: included in l: current .includes
217- let l: opts = deepcopy (a: opts )
218- let l: opts .root = l: included .new_root
219- let l: files += s: parse_files (l: included .file , l: opts , a: cache )
217+ let l: files += s: parse_files (l: included .file , l: included .new_root, a: cache )
220218 endfor
221219
222220 return l: files
223221endfunction
224222
225223" }}}1
226- function ! s: parse_current (file , opts , current) abort " {{{1
224+ function ! s: parse_current (file , root , current) abort " {{{1
227225 let a: current .lines = []
228226 let a: current .includes = []
229227
@@ -243,8 +241,8 @@ function! s:parse_current(file, opts, current) abort " {{{1
243241 continue
244242 endif
245243
246- let l: result = vimtex#parser#tex#input_parser (l: line , a: file , a: opts . root)
247- call add (a: current .lines , l: result. file )
244+ let l: result = vimtex#parser#tex#input_parser (l: line , a: file , a: root )
245+ call add (a: current .lines , l: result )
248246
249247 if a: file == # l: result .file
250248 call vimtex#log#error ([
@@ -261,7 +259,7 @@ function! s:parse_current(file, opts, current) abort " {{{1
261259endfunction
262260
263261" }}}1
264- function ! s: parse_preamble (file , opts , parsed_files) abort " {{{1
262+ function ! s: parse_preamble (file , root , parsed_files) abort " {{{1
265263 if ! filereadable (a: file ) || index (a: parsed_files , a: file ) >= 0
266264 return []
267265 endif
@@ -270,11 +268,9 @@ function! s:parse_preamble(file, opts, parsed_files) abort " {{{1
270268 let l: lines = []
271269 for l: line in readfile (a: file )
272270 if l: line = ~# g: vimtex #re #tex_input
273- let l: result = vimtex#parser#tex#input_parser (l: line , a: file , a: opts .root)
274-
275- let l: opts = deepcopy (a: opts )
276- let l: opts .root = l: result .new_root
277- call extend (l: lines , s: parse_preamble (l: result .file , l: opts , a: parsed_files ))
271+ let l: result = vimtex#parser#tex#input_parser (l: line , a: file , a: root )
272+ let l: lines += s: parse_preamble (
273+ \ l: result .file , l: result .new_root, a: parsed_files )
278274 else
279275 call add (l: lines , l: line )
280276 endif
0 commit comments