summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/engine.vim7
-rw-r--r--test/test_loclist_corrections.vader38
2 files changed, 45 insertions, 0 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 828f8468..6a168958 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -336,6 +336,9 @@ function! s:RemapItemTypes(type_map, loclist) abort
endfor
endfunction
+" Save the temporary directory so we can figure out if files are in it.
+let s:temp_dir = fnamemodify(tempname(), ':h')
+
function! ale#engine#FixLocList(buffer, linter_name, loclist) abort
let l:bufnr_map = {}
let l:new_loclist = []
@@ -381,6 +384,10 @@ function! ale#engine#FixLocList(buffer, linter_name, loclist) abort
elseif has_key(l:bufnr_map, l:filename)
" Get the buffer number from the map, which can be faster.
let l:item.bufnr = l:bufnr_map[l:filename]
+ elseif l:filename[:len(s:temp_dir) - 1] is# s:temp_dir
+ " Assume that any temporary files are for this buffer.
+ let l:item.bufnr = a:buffer
+ let l:bufnr_map[l:filename] = a:buffer
else
" Look up the buffer number.
let l:item.bufnr = bufnr(l:filename)
diff --git a/test/test_loclist_corrections.vader b/test/test_loclist_corrections.vader
index a00eb21a..e0a21da1 100644
--- a/test/test_loclist_corrections.vader
+++ b/test/test_loclist_corrections.vader
@@ -1,4 +1,5 @@
After:
+ unlet! b:temp_name
unlet! b:other_bufnr
Given foo (Some file with lines to count):
@@ -291,3 +292,40 @@ Execute(FixLocList should accept filenames):
\ {'text': 'a', 'lnum': 5, 'filename': '/foo/bar/baz'},
\ ],
\ )
+
+Execute(FixLocList should interpret temporary filenames as being the current buffer):
+ let b:temp_name = tempname()
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'text': 'a',
+ \ 'lnum': 2,
+ \ 'col': 0,
+ \ 'bufnr': bufnr(''),
+ \ 'filename': b:temp_name,
+ \ 'vcol': 0,
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'linter_name': 'foobar',
+ \ },
+ \ {
+ \ 'text': 'a',
+ \ 'lnum': 3,
+ \ 'col': 0,
+ \ 'bufnr': bufnr(''),
+ \ 'filename': b:temp_name,
+ \ 'vcol': 0,
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'linter_name': 'foobar',
+ \ },
+ \],
+ \ ale#engine#FixLocList(
+ \ bufnr(''),
+ \ 'foobar',
+ \ [
+ \ {'text': 'a', 'lnum': 2, 'filename': b:temp_name},
+ \ {'text': 'a', 'lnum': 3, 'filename': b:temp_name},
+ \ ],
+ \ )