summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorChristian Keil <keil@dfn-cert.de>2020-09-09 17:30:41 +0200
committerChristian Keil <keil@dfn-cert.de>2020-09-09 17:30:41 +0200
commit20f6bebdf22afca71b136a1ce8cff9f8b5ec7410 (patch)
treee2af7f9452026544febecc78ab207f4c674222aa /autoload
parent6a367e44aa0feddd63b0e6d9505e21ca4442247e (diff)
downloadale-20f6bebdf22afca71b136a1ce8cff9f8b5ec7410.zip
Fix handling of ranges at file end.
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/code_action.vim14
1 files changed, 12 insertions, 2 deletions
diff --git a/autoload/ale/code_action.vim b/autoload/ale/code_action.vim
index 8c7263f3..849942ca 100644
--- a/autoload/ale/code_action.vim
+++ b/autoload/ale/code_action.vim
@@ -127,10 +127,20 @@ function! ale#code_action#ApplyChanges(filename, changes, should_save) abort
endif
call extend(l:middle, l:insertions[1:])
- let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :]
+ if l:end_line <= len(l:lines)
+ " Only extend the last line if end_line is within the range of
+ " lines.
+ let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :]
+ endif
let l:lines_before_change = len(l:lines)
- let l:lines = l:start + l:middle + l:lines[l:end_line :]
+
+ if l:end_line < len(l:lines)
+ let l:end = l:lines[l:end_line :]
+ else
+ let l:end = []
+ endif
+ let l:lines = l:start + l:middle + l:end
let l:current_line_offset = len(l:lines) - l:lines_before_change
let l:line_offset += l:current_line_offset