Experimental code for showing results as soon as each linter completes
This commit is contained in:
		
							parent
							
								
									8ce6d47ef6
								
							
						
					
					
						commit
						62862c3347
					
				| @ -33,17 +33,12 @@ function! ale#engine#InitBufferInfo(buffer) abort | |||||||
|     if !has_key(g:ale_buffer_info, a:buffer) |     if !has_key(g:ale_buffer_info, a:buffer) | ||||||
|         " job_list will hold the list of jobs |         " job_list will hold the list of jobs | ||||||
|         " loclist holds the loclist items after all jobs have completed. |         " loclist holds the loclist items after all jobs have completed. | ||||||
|         " lint_file_loclist holds items from the last run including linters |  | ||||||
|         "   which use the lint_file option. |  | ||||||
|         " new_loclist holds loclist items while jobs are being run. |  | ||||||
|         " temporary_file_list holds temporary files to be cleaned up |         " temporary_file_list holds temporary files to be cleaned up | ||||||
|         " temporary_directory_list holds temporary directories to be cleaned up |         " temporary_directory_list holds temporary directories to be cleaned up | ||||||
|         " history holds a list of previously run commands for this buffer |         " history holds a list of previously run commands for this buffer | ||||||
|         let g:ale_buffer_info[a:buffer] = { |         let g:ale_buffer_info[a:buffer] = { | ||||||
|         \   'job_list': [], |         \   'job_list': [], | ||||||
|         \   'loclist': [], |         \   'loclist': [], | ||||||
|         \   'lint_file_loclist': [], |  | ||||||
|         \   'new_loclist': [], |  | ||||||
|         \   'temporary_file_list': [], |         \   'temporary_file_list': [], | ||||||
|         \   'temporary_directory_list': [], |         \   'temporary_directory_list': [], | ||||||
|         \   'history': [], |         \   'history': [], | ||||||
| @ -154,53 +149,66 @@ function! s:HandleExit(job_id, exit_code) abort | |||||||
|     " to set default values for loclist items. |     " to set default values for loclist items. | ||||||
|     let l:linter_loclist = ale#engine#FixLocList(l:buffer, l:linter, l:linter_loclist) |     let l:linter_loclist = ale#engine#FixLocList(l:buffer, l:linter, l:linter_loclist) | ||||||
| 
 | 
 | ||||||
|     " Add the loclist items from the linter. |     " Remove previous items for this linter. | ||||||
|     " loclist items for files which are checked go into a different list, |     call filter(g:ale_buffer_info[l:buffer].loclist, 'v:val.linter_name !=# l:linter.name') | ||||||
|     " and are kept between runs. |     " Add the new items. | ||||||
|     if l:linter.lint_file |     call extend(g:ale_buffer_info[l:buffer].loclist, l:linter_loclist) | ||||||
|         call extend(g:ale_buffer_info[l:buffer].lint_file_loclist, l:linter_loclist) |  | ||||||
|     else |  | ||||||
|         call extend(g:ale_buffer_info[l:buffer].new_loclist, l:linter_loclist) |  | ||||||
|     endif |  | ||||||
| 
 |  | ||||||
|     if !empty(g:ale_buffer_info[l:buffer].job_list) |  | ||||||
|         " Wait for all jobs to complete before doing anything else. |  | ||||||
|         return |  | ||||||
|     endif |  | ||||||
| 
 |  | ||||||
|     " Automatically remove all managed temporary files and directories |  | ||||||
|     " now that all jobs have completed. |  | ||||||
|     call ale#engine#RemoveManagedFiles(l:buffer) |  | ||||||
| 
 |  | ||||||
|     " Combine the lint_file List and the List for everything else. |  | ||||||
|     let l:combined_list = g:ale_buffer_info[l:buffer].lint_file_loclist |  | ||||||
|     \   + g:ale_buffer_info[l:buffer].new_loclist |  | ||||||
| 
 | 
 | ||||||
|     " Sort the loclist again. |     " Sort the loclist again. | ||||||
|     " We need a sorted list so we can run a binary search against it |     " We need a sorted list so we can run a binary search against it | ||||||
|     " for efficient lookup of the messages in the cursor handler. |     " for efficient lookup of the messages in the cursor handler. | ||||||
|     call sort(l:combined_list, 'ale#util#LocItemCompare') |     call sort(g:ale_buffer_info[l:buffer].loclist, 'ale#util#LocItemCompare') | ||||||
| 
 | 
 | ||||||
|     " Now swap the old and new loclists, after we have collected everything |     let l:linting_is_done = empty(g:ale_buffer_info[l:buffer].job_list) | ||||||
|     " and sorted the list again. | 
 | ||||||
|     let g:ale_buffer_info[l:buffer].loclist = l:combined_list |     if l:linting_is_done | ||||||
|     let g:ale_buffer_info[l:buffer].new_loclist = [] |         " Automatically remove all managed temporary files and directories | ||||||
|  |         " now that all jobs have completed. | ||||||
|  |         call ale#engine#RemoveManagedFiles(l:buffer) | ||||||
|  | 
 | ||||||
|  |         " Figure out which linters are still enabled, and remove | ||||||
|  |         " problems for linters which are no longer enabled. | ||||||
|  |         let l:name_map = {} | ||||||
|  | 
 | ||||||
|  |         for l:linter in ale#linter#Get(getbufvar(l:buffer, '&filetype')) | ||||||
|  |             let l:name_map[l:linter.name] = 1 | ||||||
|  |         endfor | ||||||
|  | 
 | ||||||
|  |         call filter( | ||||||
|  |         \   g:ale_buffer_info[l:buffer].loclist, | ||||||
|  |         \   'get(l:name_map, v:val.linter_name)', | ||||||
|  |         \) | ||||||
|  |     endif | ||||||
| 
 | 
 | ||||||
|     call ale#engine#SetResults(l:buffer, g:ale_buffer_info[l:buffer].loclist) |     call ale#engine#SetResults(l:buffer, g:ale_buffer_info[l:buffer].loclist) | ||||||
| 
 | 
 | ||||||
|     " Call user autocommands. This allows users to hook into ALE's lint cycle. |     if l:linting_is_done | ||||||
|     silent doautocmd User ALELint |         " Call user autocommands. This allows users to hook into ALE's lint cycle. | ||||||
|  |         silent doautocmd User ALELint | ||||||
|  |     endif | ||||||
| endfunction | endfunction | ||||||
| 
 | 
 | ||||||
| function! ale#engine#SetResults(buffer, loclist) abort | function! ale#engine#SetResults(buffer, loclist) abort | ||||||
|  |     let l:info = get(g:ale_buffer_info, a:buffer, {}) | ||||||
|  |     let l:job_list = get(l:info, 'job_list', []) | ||||||
|  |     let l:linting_is_done = empty(l:job_list) | ||||||
|  | 
 | ||||||
|     " Set signs first. This could potentially fix some line numbers. |     " Set signs first. This could potentially fix some line numbers. | ||||||
|     " The List could be sorted again here by SetSigns. |     " The List could be sorted again here by SetSigns. | ||||||
|     if g:ale_set_signs |     if g:ale_set_signs | ||||||
|         call ale#sign#SetSigns(a:buffer, a:loclist) |         call ale#sign#SetSigns(a:buffer, a:loclist) | ||||||
|  | 
 | ||||||
|  |         if l:linting_is_done | ||||||
|  |             call ale#sign#RemoveDummySignIfNeeded(a:buffer) | ||||||
|  |         endif | ||||||
|     endif |     endif | ||||||
| 
 | 
 | ||||||
|     if g:ale_set_quickfix || g:ale_set_loclist |     if g:ale_set_quickfix || g:ale_set_loclist | ||||||
|         call ale#list#SetLists(a:buffer, a:loclist) |         call ale#list#SetLists(a:buffer, a:loclist) | ||||||
|  | 
 | ||||||
|  |         if l:linting_is_done | ||||||
|  |             call ale#list#CloseWindowIfNeeded(a:buffer) | ||||||
|  |         endif | ||||||
|     endif |     endif | ||||||
| 
 | 
 | ||||||
|     if exists('*ale#statusline#Update') |     if exists('*ale#statusline#Update') | ||||||
|  | |||||||
| @ -35,13 +35,8 @@ function! ale#list#SetLists(buffer, loclist) abort | |||||||
|         endif |         endif | ||||||
|     endif |     endif | ||||||
| 
 | 
 | ||||||
|     " If we don't auto-open lists, bail out here. |  | ||||||
|     if !g:ale_open_list && !g:ale_keep_list_window_open |  | ||||||
|         return |  | ||||||
|     endif |  | ||||||
| 
 |  | ||||||
|     " If we have errors in our list, open the list. Only if it isn't already open |     " If we have errors in our list, open the list. Only if it isn't already open | ||||||
|     if len(a:loclist) > 0 || g:ale_keep_list_window_open |     if (g:ale_open_list && !empty(a:loclist)) || g:ale_keep_list_window_open | ||||||
|         let l:winnr = winnr() |         let l:winnr = winnr() | ||||||
| 
 | 
 | ||||||
|         if g:ale_set_quickfix |         if g:ale_set_quickfix | ||||||
| @ -56,13 +51,21 @@ function! ale#list#SetLists(buffer, loclist) abort | |||||||
|         if l:winnr !=# winnr() |         if l:winnr !=# winnr() | ||||||
|             wincmd p |             wincmd p | ||||||
|         endif |         endif | ||||||
|  |     endif | ||||||
|  | endfunction | ||||||
| 
 | 
 | ||||||
|         " Only close if the list is totally empty (relying on Vim's state, not our | function! ale#list#CloseWindowIfNeeded(buffer) abort | ||||||
|         " own). This keeps us from closing the window when other plugins have |     if g:ale_keep_list_window_open || !g:ale_open_list | ||||||
|         " populated it. |         return | ||||||
|     elseif !g:ale_keep_list_window_open && g:ale_set_quickfix && len(getqflist()) == 0 |     endif | ||||||
|         cclose | 
 | ||||||
|     elseif !g:ale_keep_list_window_open && len(getloclist(0)) == 0 |     " Only close windows if the quickfix list or loclist is completely empty, | ||||||
|  |     " including errors set through other means. | ||||||
|  |     if g:ale_set_quickfix | ||||||
|  |         if empty(getqflist()) | ||||||
|  |             cclose | ||||||
|  |         endif | ||||||
|  |     elseif g:ale_set_loclist && empty(getloclist(0)) | ||||||
|         lclose |         lclose | ||||||
|     endif |     endif | ||||||
| endfunction | endfunction | ||||||
|  | |||||||
| @ -118,7 +118,20 @@ function! s:GroupLoclistItems(loclist) abort | |||||||
|         let l:last_lnum = l:obj.lnum |         let l:last_lnum = l:obj.lnum | ||||||
|     endfor |     endfor | ||||||
| 
 | 
 | ||||||
|     return l:grouped_items |     " Now we've gathered the items in groups, filter the groups down to | ||||||
|  |     " the groups containing at least one new item. | ||||||
|  |     let l:new_grouped_items = [] | ||||||
|  | 
 | ||||||
|  |     for l:group in l:grouped_items | ||||||
|  |         for l:obj in l:group | ||||||
|  |             if !has_key(l:obj, 'sign_id') | ||||||
|  |                 call add(l:new_grouped_items, l:group) | ||||||
|  |                 break | ||||||
|  |             endif | ||||||
|  |         endfor | ||||||
|  |     endfor | ||||||
|  | 
 | ||||||
|  |     return l:new_grouped_items | ||||||
| endfunction | endfunction | ||||||
| 
 | 
 | ||||||
| function! s:IsDummySignSet(current_id_list) abort | function! s:IsDummySignSet(current_id_list) abort | ||||||
| @ -189,14 +202,18 @@ function! ale#sign#SetSignColumnHighlight(has_problems) abort | |||||||
|     endif |     endif | ||||||
| endfunction | endfunction | ||||||
| 
 | 
 | ||||||
| function! s:PlaceNewSigns(buffer, grouped_items) abort | function! s:PlaceNewSigns(buffer, grouped_items, current_sign_offset) abort | ||||||
|     if g:ale_change_sign_column_color |     if g:ale_change_sign_column_color | ||||||
|         call ale#sign#SetSignColumnHighlight(!empty(a:grouped_items)) |         call ale#sign#SetSignColumnHighlight(!empty(a:grouped_items)) | ||||||
|     endif |     endif | ||||||
| 
 | 
 | ||||||
|  |     let l:offset = a:current_sign_offset > 0 | ||||||
|  |     \   ? a:current_sign_offset | ||||||
|  |     \   : g:ale_sign_offset | ||||||
|  | 
 | ||||||
|     " Add the new signs, |     " Add the new signs, | ||||||
|     for l:index in range(0, len(a:grouped_items) - 1) |     for l:index in range(0, len(a:grouped_items) - 1) | ||||||
|         let l:sign_id = l:index + g:ale_sign_offset + 1 |         let l:sign_id = l:offset + l:index + 1 | ||||||
|         let l:sublist = a:grouped_items[l:index] |         let l:sublist = a:grouped_items[l:index] | ||||||
|         let l:type = ale#sign#GetSignType(a:grouped_items[l:index]) |         let l:type = ale#sign#GetSignType(a:grouped_items[l:index]) | ||||||
| 
 | 
 | ||||||
| @ -232,22 +249,17 @@ endfunction | |||||||
| 
 | 
 | ||||||
| " Given some current signs and a loclist, look for items with sign IDs, | " Given some current signs and a loclist, look for items with sign IDs, | ||||||
| " and change the line numbers for loclist items to match the signs. | " and change the line numbers for loclist items to match the signs. | ||||||
| function! s:UpdateLineNumbers(current_sign_list, loclist) abort | function! s:UpdateLineNumbers(current_sign_list, items_by_sign_id) abort | ||||||
|     let l:items_by_sign_id = s:GetItemsWithSignIDs(a:loclist) |  | ||||||
| 
 |  | ||||||
|     " Do nothing if there's nothing to work with. |     " Do nothing if there's nothing to work with. | ||||||
|     if empty(l:items_by_sign_id) |     if empty(a:items_by_sign_id) | ||||||
|         return |         return | ||||||
|     endif |     endif | ||||||
| 
 | 
 | ||||||
|     for [l:line, l:sign_id, l:name] in a:current_sign_list |     for [l:line, l:sign_id, l:name] in a:current_sign_list | ||||||
|         for l:obj in get(l:items_by_sign_id, l:sign_id, []) |         for l:obj in get(a:items_by_sign_id, l:sign_id, []) | ||||||
|             let l:obj.lnum = l:line |             let l:obj.lnum = l:line | ||||||
|         endfor |         endfor | ||||||
|     endfor |     endfor | ||||||
| 
 |  | ||||||
|     " Sort items again. |  | ||||||
|     call sort(a:loclist, 'ale#util#LocItemCompare') |  | ||||||
| endfunction | endfunction | ||||||
| 
 | 
 | ||||||
| " This function will set the signs which show up on the left. | " This function will set the signs which show up on the left. | ||||||
| @ -260,8 +272,13 @@ function! ale#sign#SetSigns(buffer, loclist) abort | |||||||
| 
 | 
 | ||||||
|     " Find the current markers |     " Find the current markers | ||||||
|     let l:current_sign_list = ale#sign#FindCurrentSigns(a:buffer) |     let l:current_sign_list = ale#sign#FindCurrentSigns(a:buffer) | ||||||
|  |     " Get a mapping from sign IDs to current loclist items which have them. | ||||||
|  |     let l:items_by_sign_id = s:GetItemsWithSignIDs(a:loclist) | ||||||
| 
 | 
 | ||||||
|     call s:UpdateLineNumbers(l:current_sign_list, a:loclist) |     " Use sign information to update the line numbers for the loclist items. | ||||||
|  |     call s:UpdateLineNumbers(l:current_sign_list, l:items_by_sign_id) | ||||||
|  |     " Sort items again, as the line numbers could have changed. | ||||||
|  |     call sort(a:loclist, 'ale#util#LocItemCompare') | ||||||
| 
 | 
 | ||||||
|     let l:grouped_items = s:GroupLoclistItems(a:loclist) |     let l:grouped_items = s:GroupLoclistItems(a:loclist) | ||||||
| 
 | 
 | ||||||
| @ -277,16 +294,19 @@ function! ale#sign#SetSigns(buffer, loclist) abort | |||||||
|     " while we add the new signs, if we had signs before. |     " while we add the new signs, if we had signs before. | ||||||
|     for [l:line, l:sign_id, l:name] in l:current_sign_list |     for [l:line, l:sign_id, l:name] in l:current_sign_list | ||||||
|         if l:sign_id != g:ale_sign_offset |         if l:sign_id != g:ale_sign_offset | ||||||
|  |         \&& !has_key(l:items_by_sign_id, l:sign_id) | ||||||
|             exec 'sign unplace ' . l:sign_id . ' buffer=' . a:buffer |             exec 'sign unplace ' . l:sign_id . ' buffer=' . a:buffer | ||||||
|         endif |         endif | ||||||
|     endfor |     endfor | ||||||
| 
 | 
 | ||||||
|     call s:PlaceNewSigns(a:buffer, l:grouped_items) |     " Compute a sign ID offset so we don't hit the same sign IDs again. | ||||||
|  |     let l:current_sign_offset = max(map(keys(l:items_by_sign_id), 'str2nr(v:val)')) | ||||||
| 
 | 
 | ||||||
|     " Remove the dummy sign now we've updated the signs, unless we want |     call s:PlaceNewSigns(a:buffer, l:grouped_items, l:current_sign_offset) | ||||||
|     " to keep it, which will keep the sign column open even when there are | endfunction | ||||||
|     " no warnings or errors. | 
 | ||||||
|     if l:is_dummy_sign_set && !g:ale_sign_column_always | function! ale#sign#RemoveDummySignIfNeeded(buffer) abort | ||||||
|  |     if !g:ale_sign_column_always | ||||||
|         execute 'sign unplace ' . g:ale_sign_offset . ' buffer=' . a:buffer |         execute 'sign unplace ' . g:ale_sign_offset . ' buffer=' . a:buffer | ||||||
|     endif |     endif | ||||||
| endfunction | endfunction | ||||||
|  | |||||||
| @ -126,30 +126,32 @@ Execute(The current signs should be set for running a job): | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Execute(Loclist items with sign_id values should be kept): | Execute(Loclist items with sign_id values should be kept): | ||||||
|   exec 'sign place 1000347 line=15 name=ALEErrorSign buffer=' . bufnr('%') |   exec 'sign place 1000347 line=3 name=ALEErrorSign buffer=' . bufnr('%') | ||||||
|   exec 'sign place 1000348 line=16 name=ALEWarningSign buffer=' . bufnr('%') |   exec 'sign place 1000348 line=15 name=ALEErrorSign buffer=' . bufnr('%') | ||||||
|  |   exec 'sign place 1000349 line=16 name=ALEWarningSign buffer=' . bufnr('%') | ||||||
| 
 | 
 | ||||||
|   let g:loclist = [ |   let g:loclist = [ | ||||||
|   \ {'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000347}, |   \ {'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000348}, | ||||||
|   \ {'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000348}, |   \ {'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000349}, | ||||||
|   \ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c'}, |   \ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347}, | ||||||
|   \ {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'}, |   \ {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'}, | ||||||
|   \ {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}, |   \ {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}, | ||||||
|   \ {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'}, |   \ {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'}, | ||||||
|   \] |   \] | ||||||
| 
 | 
 | ||||||
|   call ale#sign#SetSigns(bufnr('%'), g:loclist) |   call ale#sign#SetSigns(bufnr('%'), g:loclist) | ||||||
|  |   call ale#sign#RemoveDummySignIfNeeded(bufnr('%')) | ||||||
| 
 | 
 | ||||||
|   " Line numbers should be changed, sign_id values should be replaced, |   " Sign IDs from before should be kept, and new signs should use | ||||||
|   " and items should be sorted again. |   " IDs that haven't been used yet. | ||||||
|   AssertEqual |   AssertEqual | ||||||
|   \ [ |   \ [ | ||||||
|   \   {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000001}, |   \   {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000347}, | ||||||
|   \   {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000002}, |   \   {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000350}, | ||||||
|   \   {'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000003}, |   \   {'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000351}, | ||||||
|   \   {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000003}, |   \   {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000351}, | ||||||
|   \   {'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000004}, |   \   {'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000352}, | ||||||
|   \   {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000004}, |   \   {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000352}, | ||||||
|   \ ], |   \ ], | ||||||
|   \ g:loclist |   \ g:loclist | ||||||
| 
 | 
 | ||||||
| @ -158,12 +160,14 @@ Execute(Loclist items with sign_id values should be kept): | |||||||
|   " now have new warnings. |   " now have new warnings. | ||||||
|   AssertEqual |   AssertEqual | ||||||
|   \ [ |   \ [ | ||||||
|   \   ['3', '1000001', 'ALEErrorSign'], |   \   ['15', '1000348', 'ALEErrorSign'], | ||||||
|   \   ['4', '1000002', 'ALEWarningSign'], |   \   ['15', '1000351', 'ALEErrorSign'], | ||||||
|   \   ['15', '1000003', 'ALEErrorSign'], |   \   ['16', '1000349', 'ALEWarningSign'], | ||||||
|   \   ['16', '1000004', 'ALEErrorSign'], |   \   ['16', '1000352', 'ALEErrorSign'], | ||||||
|  |   \   ['3', '1000347', 'ALEErrorSign'], | ||||||
|  |   \   ['4', '1000350', 'ALEWarningSign'], | ||||||
|   \ ], |   \ ], | ||||||
|   \ ParseSigns() |   \ sort(ParseSigns()) | ||||||
| 
 | 
 | ||||||
| Execute(No excpetions should be thrown when setting signs for invalid buffers): | Execute(No excpetions should be thrown when setting signs for invalid buffers): | ||||||
|   call ale#sign#SetSigns(123456789, [{'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}]) |   call ale#sign#SetSigns(123456789, [{'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}]) | ||||||
|  | |||||||
| @ -1,13 +1,16 @@ | |||||||
| Before: | Before: | ||||||
|   function! TestCallback(buffer, output) |   function! TestCallback(buffer, output) | ||||||
|     return [{ |     return [{ | ||||||
|     \ 'bufnr': a:buffer, |  | ||||||
|     \ 'lnum': 2, |     \ 'lnum': 2, | ||||||
|     \ 'vcol': 0, |  | ||||||
|     \ 'col': 3, |     \ 'col': 3, | ||||||
|     \ 'text': a:output[0], |     \ 'text': a:output[0], | ||||||
|     \ 'type': 'E', |     \}] | ||||||
|     \ 'nr': -1, |   endfunction | ||||||
|  |   function! TestCallback2(buffer, output) | ||||||
|  |     return [{ | ||||||
|  |     \ 'lnum': 3, | ||||||
|  |     \ 'col': 4, | ||||||
|  |     \ 'text': a:output[0], | ||||||
|     \}] |     \}] | ||||||
|   endfunction |   endfunction | ||||||
| 
 | 
 | ||||||
| @ -22,6 +25,7 @@ Before: | |||||||
| After: | After: | ||||||
|   let g:ale_buffer_info = {} |   let g:ale_buffer_info = {} | ||||||
|   delfunction TestCallback |   delfunction TestCallback | ||||||
|  |   delfunction TestCallback2 | ||||||
|   call ale#linter#Reset() |   call ale#linter#Reset() | ||||||
| 
 | 
 | ||||||
| Given foobar (Some imaginary filetype): | Given foobar (Some imaginary filetype): | ||||||
| @ -46,3 +50,31 @@ Execute(Linters should run with the default options): | |||||||
|   \   'pattern': '', |   \   'pattern': '', | ||||||
|   \   'valid': 1, |   \   'valid': 1, | ||||||
|   \ }], getloclist(0) |   \ }], getloclist(0) | ||||||
|  | 
 | ||||||
|  | Execute(Previous errors should be removed when linters change): | ||||||
|  |   call ale#Lint() | ||||||
|  |   call ale#engine#WaitForJobs(2000) | ||||||
|  | 
 | ||||||
|  |   call ale#linter#Reset() | ||||||
|  | 
 | ||||||
|  |   call ale#linter#Define('foobar', { | ||||||
|  |   \ 'name': 'testlinter2', | ||||||
|  |   \ 'callback': 'TestCallback2', | ||||||
|  |   \ 'executable': 'echo', | ||||||
|  |   \ 'command': '/bin/sh -c ''echo baz boz''', | ||||||
|  |   \}) | ||||||
|  | 
 | ||||||
|  |   call ale#Lint() | ||||||
|  |   call ale#engine#WaitForJobs(2000) | ||||||
|  | 
 | ||||||
|  |   AssertEqual [{ | ||||||
|  |   \   'bufnr': bufnr('%'), | ||||||
|  |   \   'lnum': 3, | ||||||
|  |   \   'vcol': 0, | ||||||
|  |   \   'col': 4, | ||||||
|  |   \   'text': 'baz boz', | ||||||
|  |   \   'type': 'E', | ||||||
|  |   \   'nr': -1, | ||||||
|  |   \   'pattern': '', | ||||||
|  |   \   'valid': 1, | ||||||
|  |   \ }], getloclist(0) | ||||||
|  | |||||||
| @ -64,14 +64,17 @@ Execute(The quickfix window should open for just the loclist): | |||||||
| 
 | 
 | ||||||
|   " It should not open for an empty list. |   " It should not open for an empty list. | ||||||
|   call ale#list#SetLists(bufnr('%'), []) |   call ale#list#SetLists(bufnr('%'), []) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|   Assert !ale#list#IsQuickfixOpen() |   Assert !ale#list#IsQuickfixOpen() | ||||||
| 
 | 
 | ||||||
|   " With a non-empty loclist, the window must open. |   " With a non-empty loclist, the window must open. | ||||||
|   call ale#list#SetLists(bufnr('%'), g:loclist) |   call ale#list#SetLists(bufnr('%'), g:loclist) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|   Assert ale#list#IsQuickfixOpen() |   Assert ale#list#IsQuickfixOpen() | ||||||
| 
 | 
 | ||||||
|   " Clear the list and it should close again. |   " Clear the list and it should close again. | ||||||
|   call ale#list#SetLists(bufnr('%'), []) |   call ale#list#SetLists(bufnr('%'), []) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|   Assert !ale#list#IsQuickfixOpen() |   Assert !ale#list#IsQuickfixOpen() | ||||||
| 
 | 
 | ||||||
| Execute(The quickfix window height should be correct for the loclist): | Execute(The quickfix window height should be correct for the loclist): | ||||||
| @ -79,6 +82,7 @@ Execute(The quickfix window height should be correct for the loclist): | |||||||
|   let g:ale_list_window_size = 7 |   let g:ale_list_window_size = 7 | ||||||
| 
 | 
 | ||||||
|   call ale#list#SetLists(bufnr('%'), g:loclist) |   call ale#list#SetLists(bufnr('%'), g:loclist) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
| 
 | 
 | ||||||
|   AssertEqual 7, GetQuickfixHeight() |   AssertEqual 7, GetQuickfixHeight() | ||||||
| 
 | 
 | ||||||
| @ -87,6 +91,7 @@ Execute(The quickfix window height should be correct for the loclist with buffer | |||||||
|   let b:ale_list_window_size = 8 |   let b:ale_list_window_size = 8 | ||||||
| 
 | 
 | ||||||
|   call ale#list#SetLists(bufnr('%'), g:loclist) |   call ale#list#SetLists(bufnr('%'), g:loclist) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
| 
 | 
 | ||||||
|   AssertEqual 8, GetQuickfixHeight() |   AssertEqual 8, GetQuickfixHeight() | ||||||
| 
 | 
 | ||||||
| @ -96,13 +101,16 @@ Execute(The quickfix window should stay open for just the loclist): | |||||||
| 
 | 
 | ||||||
|   " The window should stay open after even after it is made blank again. |   " The window should stay open after even after it is made blank again. | ||||||
|   call ale#list#SetLists(bufnr('%'), g:loclist) |   call ale#list#SetLists(bufnr('%'), g:loclist) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|   call ale#list#SetLists(bufnr('%'), []) |   call ale#list#SetLists(bufnr('%'), []) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|   Assert ale#list#IsQuickfixOpen() |   Assert ale#list#IsQuickfixOpen() | ||||||
| 
 | 
 | ||||||
| Execute(The quickfix window should not open by default when quickfix is on): | Execute(The quickfix window should not open by default when quickfix is on): | ||||||
|   let g:ale_set_quickfix = 1 |   let g:ale_set_quickfix = 1 | ||||||
| 
 | 
 | ||||||
|   call ale#list#SetLists(bufnr('%'), g:loclist) |   call ale#list#SetLists(bufnr('%'), g:loclist) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|   Assert !ale#list#IsQuickfixOpen() |   Assert !ale#list#IsQuickfixOpen() | ||||||
| 
 | 
 | ||||||
| Execute(The quickfix window should open for the quickfix list): | Execute(The quickfix window should open for the quickfix list): | ||||||
| @ -111,15 +119,18 @@ Execute(The quickfix window should open for the quickfix list): | |||||||
| 
 | 
 | ||||||
|   " It should not open for an empty list. |   " It should not open for an empty list. | ||||||
|   call ale#list#SetLists(bufnr('%'), []) |   call ale#list#SetLists(bufnr('%'), []) | ||||||
|   Assert !ale#list#IsQuickfixOpen() |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|  |   Assert !ale#list#IsQuickfixOpen(), 'The quickfix window was opened when the list was empty' | ||||||
| 
 | 
 | ||||||
|   " With a non-empty quickfix list, the window must open. |   " With a non-empty quickfix list, the window must open. | ||||||
|   call ale#list#SetLists(bufnr('%'), g:loclist) |   call ale#list#SetLists(bufnr('%'), g:loclist) | ||||||
|   Assert ale#list#IsQuickfixOpen() |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|  |   Assert ale#list#IsQuickfixOpen(), 'The quickfix window was closed when the list was not empty' | ||||||
| 
 | 
 | ||||||
|   " Clear the list and it should close again. |   " Clear the list and it should close again. | ||||||
|   call ale#list#SetLists(bufnr('%'), []) |   call ale#list#SetLists(bufnr('%'), []) | ||||||
|   Assert !ale#list#IsQuickfixOpen() |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|  |   Assert !ale#list#IsQuickfixOpen(), 'The quickfix window was not closed when the list was empty' | ||||||
| 
 | 
 | ||||||
| Execute(The quickfix window should stay open for the quickfix list): | Execute(The quickfix window should stay open for the quickfix list): | ||||||
|   let g:ale_set_quickfix = 1 |   let g:ale_set_quickfix = 1 | ||||||
| @ -128,7 +139,9 @@ Execute(The quickfix window should stay open for the quickfix list): | |||||||
| 
 | 
 | ||||||
|   " The window should stay open after even after it is made blank again. |   " The window should stay open after even after it is made blank again. | ||||||
|   call ale#list#SetLists(bufnr('%'), g:loclist) |   call ale#list#SetLists(bufnr('%'), g:loclist) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|   call ale#list#SetLists(bufnr('%'), []) |   call ale#list#SetLists(bufnr('%'), []) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
|   Assert ale#list#IsQuickfixOpen() |   Assert ale#list#IsQuickfixOpen() | ||||||
| 
 | 
 | ||||||
| Execute(The quickfix window height should be correct for the quickfix list): | Execute(The quickfix window height should be correct for the quickfix list): | ||||||
| @ -137,6 +150,7 @@ Execute(The quickfix window height should be correct for the quickfix list): | |||||||
|   let g:ale_list_window_size = 7 |   let g:ale_list_window_size = 7 | ||||||
| 
 | 
 | ||||||
|   call ale#list#SetLists(bufnr('%'), g:loclist) |   call ale#list#SetLists(bufnr('%'), g:loclist) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
| 
 | 
 | ||||||
|   AssertEqual 7, GetQuickfixHeight() |   AssertEqual 7, GetQuickfixHeight() | ||||||
| 
 | 
 | ||||||
| @ -146,5 +160,6 @@ Execute(The quickfix window height should be correct for the quickfix list with | |||||||
|   let b:ale_list_window_size = 8 |   let b:ale_list_window_size = 8 | ||||||
| 
 | 
 | ||||||
|   call ale#list#SetLists(bufnr('%'), g:loclist) |   call ale#list#SetLists(bufnr('%'), g:loclist) | ||||||
|  |   call ale#list#CloseWindowIfNeeded(bufnr('')) | ||||||
| 
 | 
 | ||||||
|   AssertEqual 8, GetQuickfixHeight() |   AssertEqual 8, GetQuickfixHeight() | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 w0rp
						w0rp