From 7e2342ab524d42b09545a7a3231251bdfeeccab8 Mon Sep 17 00:00:00 2001 From: yoshi1123 <65735241+yoshi1123@users.noreply.github.com> Date: Sun, 20 Mar 2022 09:20:33 -0400 Subject: [PATCH] Fix :ALEImport column position Fix :ALEImport column position so it works with more language servers. Co-authored-by: w0rp --- autoload/ale/completion.vim | 3 ++- test/completion/test_ale_import_command.vader | 24 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/autoload/ale/completion.vim b/autoload/ale/completion.vim index b65338fc..512c42f2 100644 --- a/autoload/ale/completion.vim +++ b/autoload/ale/completion.vim @@ -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', { diff --git a/test/completion/test_ale_import_command.vader b/test/completion/test_ale_import_command.vader index 1ce3a2a2..4770466e 100644 --- a/test/completion/test_ale_import_command.vader +++ b/test/completion/test_ale_import_command.vader @@ -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