Fix an off-by-one bug in ALEFix
This commit is contained in:
parent
4214832ae2
commit
e6b132c915
@ -31,7 +31,7 @@ function! ale#fix#ApplyQueuedFixes() abort
|
|||||||
let l:start_line = len(l:data.output) + 1
|
let l:start_line = len(l:data.output) + 1
|
||||||
let l:end_line = len(l:lines)
|
let l:end_line = len(l:lines)
|
||||||
|
|
||||||
if l:end_line > l:start_line
|
if l:end_line >= l:start_line
|
||||||
let l:save = winsaveview()
|
let l:save = winsaveview()
|
||||||
silent execute l:start_line . ',' . l:end_line . 'd'
|
silent execute l:start_line . ',' . l:end_line . 'd'
|
||||||
call winrestview(l:save)
|
call winrestview(l:save)
|
||||||
|
@ -28,6 +28,9 @@ Before:
|
|||||||
return {'command': 'echo x > %t', 'read_temporary_file': 1}
|
return {'command': 'echo x > %t', 'read_temporary_file': 1}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function RemoveLastLine(buffer, lines) abort
|
||||||
|
return ['a', 'b']
|
||||||
|
endfunction
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
unlet! g:ale_run_synchronously
|
unlet! g:ale_run_synchronously
|
||||||
@ -37,6 +40,7 @@ After:
|
|||||||
delfunction DoNothing
|
delfunction DoNothing
|
||||||
delfunction CatLine
|
delfunction CatLine
|
||||||
delfunction ReplaceWithTempFile
|
delfunction ReplaceWithTempFile
|
||||||
|
delfunction RemoveLastLine
|
||||||
call ale#fix#registry#ResetToDefaults()
|
call ale#fix#registry#ResetToDefaults()
|
||||||
|
|
||||||
Given testft (A file with three lines):
|
Given testft (A file with three lines):
|
||||||
@ -137,3 +141,11 @@ Expect(The registry function should be used):
|
|||||||
^a
|
^a
|
||||||
^b
|
^b
|
||||||
^c
|
^c
|
||||||
|
|
||||||
|
Execute(ALEFix should be able to remove the last line for files):
|
||||||
|
let g:ale_fixers.testft = ['RemoveLastLine']
|
||||||
|
ALEFix
|
||||||
|
|
||||||
|
Expect(There should be only two lines):
|
||||||
|
a
|
||||||
|
b
|
||||||
|
Loading…
Reference in New Issue
Block a user