summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-05-28 17:38:14 +0100
committerw0rp <devw0rp@gmail.com>2018-05-28 17:38:14 +0100
commit18509195f575c5753d3b30ff87040674cca6ce01 (patch)
tree01cdfa7745491fe8664fdb8b2cfa26e8f1a05d13
parentce89d93e1c7b0e135ad88414fe1c556b4a4b3c3e (diff)
downloadale-18509195f575c5753d3b30ff87040674cca6ce01.zip
#1524 Do not try to check buffers with empty filetypes
-rw-r--r--autoload/ale.vim16
-rw-r--r--autoload/ale/engine.vim2
-rw-r--r--test/sign/test_sign_placement.vader2
-rw-r--r--test/test_alelint_autocmd.vader1
-rw-r--r--test/test_engine_lsp_response_handling.vader1
-rw-r--r--test/test_lint_error_delay.vader1
-rw-r--r--test/test_should_do_nothing_conditions.vader11
-rw-r--r--test/test_temporary_file_management.vader19
-rw-r--r--test/test_verilog_verilator_options.vader1
9 files changed, 49 insertions, 5 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim
index 5c4a0f55..725a3958 100644
--- a/autoload/ale.vim
+++ b/autoload/ale.vim
@@ -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 for blacklisted files.
+ if index(get(g:, 'ale_filetype_blacklist', []), l:filetype) >= 0
return 1
endif
- " Do nothing if running from command mode
+ " 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
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 5cd12187..f988d1b8 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -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
diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader
index 36f34e16..19267fe7 100644
--- a/test/sign/test_sign_placement.vader
+++ b/test/sign/test_sign_placement.vader
@@ -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 *
diff --git a/test/test_alelint_autocmd.vader b/test/test_alelint_autocmd.vader
index d51694ff..5af1cd47 100644
--- a/test/test_alelint_autocmd.vader
+++ b/test/test_alelint_autocmd.vader
@@ -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!
diff --git a/test/test_engine_lsp_response_handling.vader b/test/test_engine_lsp_response_handling.vader
index 4c6fe637..3d317e9c 100644
--- a/test/test_engine_lsp_response_handling.vader
+++ b/test/test_engine_lsp_response_handling.vader
@@ -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')
diff --git a/test/test_lint_error_delay.vader b/test/test_lint_error_delay.vader
index 05664899..d5397087 100644
--- a/test/test_lint_error_delay.vader
+++ b/test/test_lint_error_delay.vader
@@ -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)
diff --git a/test/test_should_do_nothing_conditions.vader b/test/test_should_do_nothing_conditions.vader
index 85874e53..062ab875 100644
--- a/test/test_should_do_nothing_conditions.vader
+++ b/test/test_should_do_nothing_conditions.vader
@@ -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
diff --git a/test/test_temporary_file_management.vader b/test/test_temporary_file_management.vader
index ae2bf251..e248331c 100644
--- a/test/test_temporary_file_management.vader
+++ b/test/test_temporary_file_management.vader
@@ -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
diff --git a/test/test_verilog_verilator_options.vader b/test/test_verilog_verilator_options.vader
index 561786ee..e53037b1 100644
--- a/test/test_verilog_verilator_options.vader
+++ b/test/test_verilog_verilator_options.vader
@@ -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'
-