#1524 Do not try to check buffers with empty filetypes

This commit is contained in:
w0rp 2018-05-28 17:38:14 +01:00
parent ce89d93e1c
commit 18509195f5
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
9 changed files with 49 additions and 5 deletions

View File

@ -60,23 +60,31 @@ function! ale#ShouldDoNothing(buffer) abort
return 1
endif
" Do nothing for blacklisted files
if index(get(g:, 'ale_filetype_blacklist', []), getbufvar(a:buffer, '&filetype')) >= 0
let l:filetype = getbufvar(a:buffer, '&filetype')
" Do nothing when there's no filetype.
if l:filetype is# ''
return 1
endif
" Do nothing if running from command mode
" Do nothing for blacklisted files.
if index(get(g:, 'ale_filetype_blacklist', []), l:filetype) >= 0
return 1
endif
" Do nothing if running from command mode.
if s:getcmdwintype_exists && !empty(getcmdwintype())
return 1
endif
let l:filename = fnamemodify(bufname(a:buffer), ':t')
" Do nothing for directories.
if l:filename is# '.'
return 1
endif
" Do nothing if running in the sandbox
" Do nothing if running in the sandbox.
if ale#util#InSandbox()
return 1
endif

View File

@ -98,11 +98,13 @@ endfunction
" Register a temporary file to be managed with the ALE engine for
" a current job run.
function! ale#engine#ManageFile(buffer, filename) abort
call ale#engine#InitBufferInfo(a:buffer)
call add(g:ale_buffer_info[a:buffer].temporary_file_list, a:filename)
endfunction
" Same as the above, but manage an entire directory.
function! ale#engine#ManageDirectory(buffer, directory) abort
call ale#engine#InitBufferInfo(a:buffer)
call add(g:ale_buffer_info[a:buffer].temporary_directory_list, a:directory)
endfunction

View File

@ -1,7 +1,9 @@
Before:
Save g:ale_set_signs
Save g:ale_buffer_info
let g:ale_set_signs = 1
let g:ale_buffer_info = {}
call ale#linter#Reset()
sign unplace *

View File

@ -14,6 +14,7 @@ After:
catch
endtry
Given foobar(An empty file):
Execute(Run a lint cycle, and check that a variable is set in the autocmd):
augroup VaderTest
autocmd!

View File

@ -13,6 +13,7 @@ After:
call ale#linter#Reset()
call ale#engine#ClearLSPData()
Given foobar(An empty file):
Execute(tsserver syntax error responses should be handled correctly):
runtime ale_linters/typescript/tsserver.vim
call ale#test#SetFilename('filename.ts')

View File

@ -11,6 +11,7 @@ After:
call ale#ResetErrorDelays()
Given foobar(An empty file):
Execute(ALE should stop queuing for a while after exceptions are thrown):
AssertThrows call ale#Queue(100)
call ale#Queue(100)

View File

@ -26,6 +26,7 @@ After:
unlet! b:funky_command_created
Given foobar(An empty file):
Execute(ALE shouldn't do much of anything for ctrlp-funky buffers):
Assert !ale#ShouldDoNothing(bufnr('')), 'The preliminary check failed'
@ -43,6 +44,16 @@ Execute(ALE shouldn't try to check buffers with '.' as the filename):
Assert ale#ShouldDoNothing(bufnr(''))
Execute(DoNothing should return 0 when the filetype is empty):
AssertEqual
\ 0,
\ ale#ShouldDoNothing(bufnr('')),
\ 'ShouldDoNothing() was 1 for some other reason'
set filetype=
AssertEqual 1, ale#ShouldDoNothing(bufnr(''))
Execute(The DoNothing check should work if the ALE globals aren't defined):
unlet! g:ale_filetype_blacklist
unlet! g:ale_maximum_file_size

View File

@ -1,4 +1,7 @@
Before:
Save g:ale_buffer_info
let g:ale_buffer_info = {}
let g:ale_run_synchronously = 1
let g:command = 'echo test'
@ -41,6 +44,8 @@ Before:
\})
After:
Restore
if !empty(g:preserved_directory)
call delete(g:preserved_directory, 'rf')
endif
@ -111,3 +116,17 @@ Execute(ALE should create and delete directories for ale#engine#CreateDirectory(
Assert !isdirectory(b:dir), 'The directory was not deleted'
Assert !isdirectory(b:dir2), 'The second directory was not deleted'
Execute(ale#engine#ManageFile should add the file even if the buffer info hasn't be set yet):
let g:ale_buffer_info = {}
call ale#engine#ManageFile(bufnr(''), '/foo/bar')
AssertEqual
\ ['/foo/bar'],
\ g:ale_buffer_info[bufnr('')].temporary_file_list
Execute(ale#engine#ManageDirectory should add the directory even if the buffer info hasn't be set yet):
let g:ale_buffer_info = {}
call ale#engine#ManageDirectory(bufnr(''), '/foo/bar')
AssertEqual
\ ['/foo/bar'],
\ g:ale_buffer_info[bufnr('')].temporary_directory_list

View File

@ -22,4 +22,3 @@ Execute(Set Verilog Verilator linter additional options to `-sv --default-langua
\ g:matched ,
\ -1 ,
\ 'Additionnal arguments not found in the run command'