mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-26 05:51:08 +08:00
Allow ALEFix functions to be defined with only the buffer argument
This commit is contained in:
@@ -35,6 +35,10 @@ Before:
|
||||
return {'command': 'cat - <(echo d)'}
|
||||
endfunction
|
||||
|
||||
function CatLineOneArg(buffer) abort
|
||||
return {'command': 'cat - <(echo d)'}
|
||||
endfunction
|
||||
|
||||
function ReplaceWithTempFile(buffer, lines) abort
|
||||
return {'command': 'echo x > %t', 'read_temporary_file': 1}
|
||||
endfunction
|
||||
@@ -43,6 +47,10 @@ Before:
|
||||
return ['a', 'b']
|
||||
endfunction
|
||||
|
||||
function RemoveLastLineOneArg(buffer) abort
|
||||
return ['a', 'b']
|
||||
endfunction
|
||||
|
||||
function! TestCallback(buffer, output)
|
||||
return [{'lnum': 1, 'col': 1, 'text': 'xxx'}]
|
||||
endfunction
|
||||
@@ -65,8 +73,10 @@ After:
|
||||
delfunction AddDollars
|
||||
delfunction DoNothing
|
||||
delfunction CatLine
|
||||
delfunction CatLineOneArg
|
||||
delfunction ReplaceWithTempFile
|
||||
delfunction RemoveLastLine
|
||||
delfunction RemoveLastLineOneArg
|
||||
delfunction TestCallback
|
||||
delfunction SetUpLinters
|
||||
call ale#fix#registry#ResetToDefaults()
|
||||
@@ -315,3 +325,21 @@ Execute(ale#fix#InitBufferData() should set up the correct data):
|
||||
\ 'should_save': 1,
|
||||
\ },
|
||||
\}, g:ale_fix_buffer_data
|
||||
|
||||
Execute(ALEFix simple functions should be able to accept one argument, the buffer):
|
||||
let g:ale_fixers.testft = ['RemoveLastLineOneArg']
|
||||
ALEFix
|
||||
|
||||
Expect(There should be only two lines):
|
||||
a
|
||||
b
|
||||
|
||||
Execute(ALEFix functions returning jobs should be able to accept one argument):
|
||||
let g:ale_fixers.testft = ['CatLine']
|
||||
ALEFix
|
||||
|
||||
Expect(An extra line should be added):
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
|
||||
Reference in New Issue
Block a user