summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-08-22 22:45:55 +0100
committerw0rp <devw0rp@gmail.com>2017-08-22 22:45:55 +0100
commit0507503aa755587892e8841a749dc0ca8641a6f8 (patch)
tree0718c0683698ee38671c714dfb540105d194d314
parent80c7fbcefeca7beb80bb761447049ea0ca2a99be (diff)
downloadale-0507503aa755587892e8841a749dc0ca8641a6f8.zip
#653 Set loclists better when taking data from previous buffers
-rw-r--r--autoload/ale/engine.vim7
-rw-r--r--test/test_setting_problems_found_in_previous_buffers.vader54
2 files changed, 52 insertions, 9 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 2875d4ad..ca8a00f3 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -728,7 +728,10 @@ function! s:AddProblemsFromOtherBuffers(buffer, linters) abort
if has_key(l:item, 'filename')
\&& l:item.filename is# l:filename
\&& has_key(l:name_map, l:item.linter_name)
- call add(l:loclist, l:item)
+ " Copy the items and set the buffer numbers to this one.
+ let l:new_item = copy(l:item)
+ let l:new_item.bufnr = a:buffer
+ call add(l:loclist, l:new_item)
endif
endfor
endfor
@@ -737,6 +740,8 @@ function! s:AddProblemsFromOtherBuffers(buffer, linters) abort
call sort(l:loclist, function('ale#util#LocItemCompareWithText'))
call uniq(l:loclist, function('ale#util#LocItemCompareWithText'))
+ " Set the loclist variable, used by some parts of ALE.
+ let g:ale_buffer_info[a:buffer].loclist = l:loclist
call ale#engine#SetResults(a:buffer, l:loclist)
endif
endfunction
diff --git a/test/test_setting_problems_found_in_previous_buffers.vader b/test/test_setting_problems_found_in_previous_buffers.vader
index 262b9d18..45dfa662 100644
--- a/test/test_setting_problems_found_in_previous_buffers.vader
+++ b/test/test_setting_problems_found_in_previous_buffers.vader
@@ -1,6 +1,9 @@
Before:
Save g:ale_buffer_info
Save &filetype
+ Save g:ale_set_lists_synchronously
+
+ let g:ale_set_lists_synchronously = 1
" Set up items in other buffers which should set in this one.
let g:ale_buffer_info = {}
@@ -13,7 +16,7 @@ Before:
\ ])
call ale#engine#InitBufferInfo(bufnr('') + 2)
let g:ale_buffer_info[bufnr('') + 2].loclist =
- \ ale#engine#FixLocList(bufnr('') + 2, 'linter_two', [
+ \ ale#engine#FixLocList(bufnr('') + 2, 'linter_one', [
\ {'lnum': 1, 'filename': expand('%:p'), 'text': 'foo'},
\ {'lnum': 3, 'filename': expand('%:p'), 'text': 'baz'},
\ {'lnum': 5, 'text': 'ignore this one'},
@@ -23,15 +26,9 @@ Before:
\ 'name': 'linter_one',
\ 'callback': 'WhoCares',
\ 'executable': 'echo',
- \ 'command': 'echo',
+ \ 'command': 'sleep 1000',
\ 'lint_file': 1,
\})
- call ale#linter#Define('foobar', {
- \ 'name': 'linter_two',
- \ 'callback': 'WhoCares',
- \ 'executable': 'echo',
- \ 'command': 'echo',
- \})
After:
call ale#engine#Cleanup(bufnr(''))
@@ -53,6 +50,47 @@ Execute(Problems found from previously opened buffers should be set when linting
AssertEqual
\ [
+ \ {
+ \ 'lnum': 1,
+ \ 'bufnr': bufnr(''),
+ \ 'col': 0,
+ \ 'filename': expand('%:p'),
+ \ 'linter_name': 'linter_one',
+ \ 'nr': -1,
+ \ 'type': 'E',
+ \ 'vcol': 0,
+ \ 'text': 'foo',
+ \ 'sign_id': 1000001,
+ \ },
+ \ {
+ \ 'lnum': 2,
+ \ 'bufnr': bufnr(''),
+ \ 'col': 0,
+ \ 'filename': expand('%:p'),
+ \ 'linter_name': 'linter_one',
+ \ 'nr': -1,
+ \ 'type': 'E',
+ \ 'vcol': 0,
+ \ 'text': 'bar',
+ \ 'sign_id': 1000002,
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'bufnr': bufnr(''),
+ \ 'col': 0,
+ \ 'filename': expand('%:p'),
+ \ 'linter_name': 'linter_one',
+ \ 'nr': -1,
+ \ 'type': 'E',
+ \ 'vcol': 0,
+ \ 'text': 'baz',
+ \ 'sign_id': 1000003,
+ \ },
+ \ ],
+ \ g:ale_buffer_info[bufnr('')].loclist
+
+ AssertEqual
+ \ [
\ {'lnum': 1, 'bufnr': bufnr(''), 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'E', 'pattern': '', 'text': 'foo'},
\ {'lnum': 2, 'bufnr': bufnr(''), 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'E', 'pattern': '', 'text': 'bar'},
\ {'lnum': 3, 'bufnr': bufnr(''), 'col': 0, 'valid': 1, 'vcol': 0, 'nr': -1, 'type': 'E', 'pattern': '', 'text': 'baz'},