Skip to content

Commit 10afe7f

Browse files
committed
FIX: Prevent cache corruption by moving before tags write.
A side effect of xolox#easytags#write_tagsfile() is that the entries argument is joined together. This then causes problems in s:cache_tagged_files_in(), where the filename element is addressed via entry[1]. When the entries have been flattened, this accesses a single character, and then the cache is corrupted. To fix this, move the cache update before the writing of the tags file. This avoids the need to make a copy of the entries before flattening them.
1 parent 44b0487 commit 10afe7f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

autoload/xolox/easytags.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,17 @@ function! s:filter_merge_tags(filter_tags, tagsfile, output, context) " {{{3
246246
call filter(entries, join(filters, ' && '))
247247
endif
248248
let num_filtered = num_old_entries - len(entries)
249-
" Merge old/new tags and write tags file.
249+
" Merge old/new tags.
250250
call extend(entries, a:output)
251+
" We've already read the tags file, cache the tagged files before the entries
252+
" get flattened by the write.
253+
let fname = s:canonicalize(a:tagsfile, a:context)
254+
call s:cache_tagged_files_in(fname, getftime(fname), entries, a:context)
255+
" And write tags file.
251256
if !xolox#easytags#write_tagsfile(a:tagsfile, headers, entries)
252257
let msg = "Failed to write filtered tags file %s!"
253258
throw printf(msg, fnamemodify(a:tagsfile, ':~'))
254259
endif
255-
" We've already read the tags file, might as well cache the tagged files :-)
256-
let fname = s:canonicalize(a:tagsfile, a:context)
257-
call s:cache_tagged_files_in(fname, getftime(fname), entries, a:context)
258260
return num_filtered
259261
endfunction
260262

0 commit comments

Comments
 (0)