diff options
author | w0rp <devw0rp@gmail.com> | 2016-10-31 13:45:22 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2016-10-31 13:45:22 +0000 |
commit | cb410927d1d45b6b3bda0882037d68fa804933ff (patch) | |
tree | 956b94243dfe73fe304d68043145e89df6779eb1 | |
parent | f44756f347611122b4e8c4dcc379e4ac3adb30d3 (diff) | |
download | ale-cb410927d1d45b6b3bda0882037d68fa804933ff.zip |
Reduce sign column juttering by waiting for all jobs to complete before updating everything.
-rw-r--r-- | autoload/ale.vim | 4 | ||||
-rw-r--r-- | autoload/ale/engine.vim | 27 |
2 files changed, 19 insertions, 12 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim index 3e86c8f9..96588e59 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -30,8 +30,8 @@ function! ale#Lint(...) abort " Initialise the buffer information if needed. call ale#engine#InitBufferInfo(l:buffer) - " Set a variable telling us to clear the loclist later. - let g:ale_buffer_info[l:buffer].should_reset = 1 + " Clear the new loclist again, so we will work with all new items. + let g:ale_buffer_info[l:buffer].new_loclist = [] for l:linter in l:linters " Check if a given linter has a program which can be executed. diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 9af1f536..7acbeaa2 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -22,11 +22,15 @@ endfunction function! ale#engine#InitBufferInfo(buffer) abort if !has_key(g:ale_buffer_info, a:buffer) + " job_list will hold the list of jobs + " dummy_sign_set will tell us if we previously created a dummy sign. + " loclist holds the loclist items after all jobs have completed. + " new_loclist holds loclist items while jobs are being run. let g:ale_buffer_info[a:buffer] = { \ 'job_list': [], - \ 'should_reset': 1, \ 'dummy_sign_set': 0, \ 'loclist': [], + \ 'new_loclist': [], \} endif endfunction @@ -118,20 +122,23 @@ function! s:HandleExit(job) abort let l:item.linter_name = l:linter.name endfor - if g:ale_buffer_info[l:buffer].should_reset - " Set the flag for resetting the loclist to 0 again, so we won't - " empty the list later. - let g:ale_buffer_info[l:buffer].should_reset = 0 - let g:ale_buffer_info[l:buffer].loclist = [] - endif - " Add the loclist items from the linter. - call extend(g:ale_buffer_info[l:buffer].loclist, l:linter_loclist) + call extend(g:ale_buffer_info[l:buffer].new_loclist, l:linter_loclist) + + if !empty(g:ale_buffer_info[l:buffer].job_list) + " Wait for all jobs to complete before doing anything else. + return + endif " Sort the loclist again. " We need a sorted list so we can run a binary search against it " for efficient lookup of the messages in the cursor handler. - call sort(g:ale_buffer_info[l:buffer].loclist, 'ale#util#LocItemCompare') + call sort(g:ale_buffer_info[l:buffer].new_loclist, 'ale#util#LocItemCompare') + + " Now swap the old and new loclists, after we have collected everything + " and sorted the list again. + let g:ale_buffer_info[l:buffer].loclist = g:ale_buffer_info[l:buffer].new_loclist + let g:ale_buffer_info[l:buffer].new_loclist = [] if g:ale_set_loclist call setloclist(0, g:ale_buffer_info[l:buffer].loclist) |