Fix end line number when it exceeds the file (#4130)

If the end of the error exceeds the file, set it to the last line,
similarly as it is done with the beginning of the error.
This commit is contained in:
Felix Maurer
2022-04-01 10:13:27 +02:00
committed by GitHub
parent 80dcd648d3
commit e81f005c78
2 changed files with 14 additions and 7 deletions

View File

@@ -347,6 +347,12 @@ function! ale#engine#FixLocList(buffer, linter_name, from_other_source, loclist)
if has_key(l:old_item, 'end_lnum')
let l:item.end_lnum = str2nr(l:old_item.end_lnum)
" When the error ends after the end of the file, put it at the
" end. This is only done for the current buffer.
if l:item.bufnr == a:buffer && l:item.end_lnum > l:last_line_number
let l:item.end_lnum = l:last_line_number
endif
endif
if has_key(l:old_item, 'sub_type')