Fix handling of ranges at file end.
This commit is contained in:
parent
6a367e44aa
commit
20f6bebdf2
1 changed files with 12 additions and 2 deletions
|
@ -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
|
||||
|
|
Reference in a new issue