diff options
-rw-r--r-- | autoload/ale/fix.vim | 2 | ||||
-rw-r--r-- | test/test_ale_fix.vader | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim index b2ca2575..a674e75c 100644 --- a/autoload/ale/fix.vim +++ b/autoload/ale/fix.vim @@ -31,7 +31,7 @@ function! ale#fix#ApplyQueuedFixes() abort let l:start_line = len(l:data.output) + 1 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() silent execute l:start_line . ',' . l:end_line . 'd' call winrestview(l:save) diff --git a/test/test_ale_fix.vader b/test/test_ale_fix.vader index 8e61aefe..71fd84fe 100644 --- a/test/test_ale_fix.vader +++ b/test/test_ale_fix.vader @@ -28,6 +28,9 @@ Before: return {'command': 'echo x > %t', 'read_temporary_file': 1} endfunction + function RemoveLastLine(buffer, lines) abort + return ['a', 'b'] + endfunction After: Restore unlet! g:ale_run_synchronously @@ -37,6 +40,7 @@ After: delfunction DoNothing delfunction CatLine delfunction ReplaceWithTempFile + delfunction RemoveLastLine call ale#fix#registry#ResetToDefaults() Given testft (A file with three lines): @@ -137,3 +141,11 @@ Expect(The registry function should be used): ^a ^b ^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 |