Compare commits

...

2 Commits

Author SHA1 Message Date
Felix Maurer f0fa137721
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.
2022-04-01 10:42:40 +01:00
yoshi1123 7e2342ab52
Fix :ALEImport column position
Fix :ALEImport column position so it works with more language servers.

Co-authored-by: w0rp <devw0rp@gmail.com>
2022-03-20 13:21:21 +00:00
4 changed files with 28 additions and 20 deletions

View File

@ -911,7 +911,8 @@ function! ale#completion#Import() abort
endif
let [l:line, l:column] = getpos('.')[1:2]
let l:column = searchpos('\V' . escape(l:word, '/\'), 'bn', l:line)[1]
let l:column = searchpos('\V' . escape(l:word, '/\'), 'bnc', l:line)[1]
let l:column = l:column + len(l:word) - 1
if l:column isnot 0
let l:started = ale#completion#GetCompletions('ale-import', {

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')

View File

@ -187,7 +187,7 @@ Execute(ALEImport should request imports correctly for tsserver):
\ 'conn_id': 0,
\ 'request_id': 0,
\ 'source': 'ale-import',
\ 'column': 11,
\ 'column': 21,
\ 'line': 2,
\ 'line_length': 21,
\ 'prefix': 'missingword',
@ -206,7 +206,7 @@ Execute(ALEImport should request imports correctly for tsserver):
\ 'conn_id': 347,
\ 'request_id': 1,
\ 'source': 'ale-import',
\ 'column': 11,
\ 'column': 21,
\ 'line': 2,
\ 'line_length': 21,
\ 'prefix': 'missingword',
@ -229,14 +229,14 @@ Execute(ALEImport should request imports correctly for tsserver):
\ [0, 'ts@completions', {
\ 'file': expand('%:p'),
\ 'includeExternalModuleExports': 1,
\ 'offset': 11,
\ 'offset': 21,
\ 'line': 2,
\ 'prefix': 'missingword',
\ }],
\ [0, 'ts@completionEntryDetails', {
\ 'file': expand('%:p'),
\ 'entryNames': [{'name': 'missingword'}],
\ 'offset': 11,
\ 'offset': 21,
\ 'line': 2,
\ }]
\ ],
@ -282,7 +282,7 @@ Execute(ALEImport should tell the user when no completions were found from tsser
\ 'conn_id': 0,
\ 'request_id': 0,
\ 'source': 'ale-import',
\ 'column': 11,
\ 'column': 21,
\ 'line': 2,
\ 'line_length': 21,
\ 'prefix': 'missingword',
@ -301,7 +301,7 @@ Execute(ALEImport should tell the user when no completions were found from tsser
\ 'conn_id': 347,
\ 'request_id': 1,
\ 'source': 'ale-import',
\ 'column': 11,
\ 'column': 21,
\ 'line': 2,
\ 'line_length': 21,
\ 'prefix': 'missingword',
@ -336,7 +336,7 @@ Execute(ALEImport should request imports correctly for language servers):
\ 'conn_id': 0,
\ 'request_id': 0,
\ 'source': 'ale-import',
\ 'column': 7,
\ 'column': 17,
\ 'line': 2,
\ 'line_length': 17,
\ 'prefix': 'missingword',
@ -355,7 +355,7 @@ Execute(ALEImport should request imports correctly for language servers):
\ 'conn_id': 347,
\ 'request_id': 1,
\ 'source': 'ale-import',
\ 'column': 7,
\ 'column': 17,
\ 'line': 2,
\ 'line_length': 17,
\ 'prefix': 'missingword',
@ -369,7 +369,7 @@ Execute(ALEImport should request imports correctly for language servers):
\ [
\ [0, 'textDocument/completion', {
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'character': 6, 'line': 1}
\ 'position': {'character': 16, 'line': 1}
\ }],
\ ],
\ g:sent_message_list
@ -482,7 +482,7 @@ Execute(ALEImport should tell the user when no completions were found from a lan
\ 'conn_id': 0,
\ 'request_id': 0,
\ 'source': 'ale-import',
\ 'column': 7,
\ 'column': 17,
\ 'line': 2,
\ 'line_length': 17,
\ 'prefix': 'missingword',
@ -501,7 +501,7 @@ Execute(ALEImport should tell the user when no completions were found from a lan
\ 'conn_id': 347,
\ 'request_id': 1,
\ 'source': 'ale-import',
\ 'column': 7,
\ 'column': 17,
\ 'line': 2,
\ 'line_length': 17,
\ 'prefix': 'missingword',
@ -515,7 +515,7 @@ Execute(ALEImport should tell the user when no completions were found from a lan
\ [
\ [0, 'textDocument/completion', {
\ 'textDocument': {'uri': ale#path#ToFileURI(expand('%:p'))},
\ 'position': {'character': 6, 'line': 1}
\ 'position': {'character': 16, 'line': 1}
\ }],
\ ],
\ g:sent_message_list

View File

@ -124,6 +124,7 @@ Execute(FixLocList should set items with lines beyond the end to the last line):
\ 'text': 'a',
\ 'lnum': 10,
\ 'col': 0,
\ 'end_lnum': 10,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'type': 'E',
@ -135,7 +136,7 @@ Execute(FixLocList should set items with lines beyond the end to the last line):
\ bufnr('%'),
\ 'foobar',
\ 0,
\ [{'text': 'a', 'lnum': 11}],
\ [{'text': 'a', 'lnum': 11, 'end_lnum': 12}],
\ )
Execute(FixLocList should move line 0 to line 1):
@ -223,9 +224,9 @@ Execute(FixLocList should pass on end_lnum values):
\ [
\ {
\ 'text': 'a',
\ 'lnum': 10,
\ 'lnum': 7,
\ 'col': 10,
\ 'end_lnum': 13,
\ 'end_lnum': 10,
\ 'end_col': 12,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
@ -235,9 +236,9 @@ Execute(FixLocList should pass on end_lnum values):
\ },
\ {
\ 'text': 'a',
\ 'lnum': 10,
\ 'lnum': 7,
\ 'col': 11,
\ 'end_lnum': 13,
\ 'end_lnum': 10,
\ 'end_col': 12,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
@ -251,8 +252,8 @@ Execute(FixLocList should pass on end_lnum values):
\ 'foobar',
\ 0,
\ [
\ {'text': 'a', 'lnum': '010', 'col': '010', 'end_col': '012', 'end_lnum': '013'},
\ {'text': 'a', 'lnum': '010', 'col': '011', 'end_col': 12, 'end_lnum': 13},
\ {'text': 'a', 'lnum': '07', 'col': '010', 'end_col': '012', 'end_lnum': '010'},
\ {'text': 'a', 'lnum': '07', 'col': '011', 'end_col': 12, 'end_lnum': 10},
\ ],
\ )