mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-09 21:12:31 +08:00
Fix #3312 - Fix a false positive for auto imports
ALE was incorrectly detecting completion results from servers such as rust-analyzer as wanting to add import lines when additionalTextEdits was present, but empty. Now ALE only filters out completion results if the autoimport setting is off, and one of the additionalTextEdits starts on some line other than the current line. If any additionalTextEdits happen to be identical to the change from completion anyway, ALE will skip them.
This commit is contained in:
@@ -537,6 +537,7 @@ Execute(Should handle completion messages with the deprecated insertText attribu
|
||||
|
||||
Execute(Should handle completion messages with additionalTextEdits when ale_completion_autoimport is turned on):
|
||||
let g:ale_completion_autoimport = 1
|
||||
let b:ale_completion_info = {'line': 30}
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
@@ -591,6 +592,19 @@ Execute(Should handle completion messages with additionalTextEdits when ale_comp
|
||||
\ {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 29,
|
||||
\ 'character': 10,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 29,
|
||||
\ 'character': 10,
|
||||
\ },
|
||||
\ },
|
||||
\ 'newText': 'next_callback',
|
||||
\ },
|
||||
\ {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 10,
|
||||
\ 'character': 1,
|
||||
\ },
|
||||
@@ -609,6 +623,7 @@ Execute(Should handle completion messages with additionalTextEdits when ale_comp
|
||||
|
||||
Execute(Should not handle completion messages with additionalTextEdits when ale_completion_autoimport is turned off):
|
||||
let g:ale_completion_autoimport = 0
|
||||
let b:ale_completion_info = {'line': 30}
|
||||
|
||||
AssertEqual
|
||||
\ [],
|
||||
@@ -630,6 +645,19 @@ Execute(Should not handle completion messages with additionalTextEdits when ale_
|
||||
\ {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 29,
|
||||
\ 'character': 10,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 29,
|
||||
\ 'character': 10,
|
||||
\ },
|
||||
\ },
|
||||
\ 'newText': 'next_callback',
|
||||
\ },
|
||||
\ {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 10,
|
||||
\ 'character': 1,
|
||||
\ },
|
||||
@@ -645,3 +673,51 @@ Execute(Should not handle completion messages with additionalTextEdits when ale_
|
||||
\ ],
|
||||
\ },
|
||||
\ })
|
||||
|
||||
Execute(Should still handle completion messages with additionalTextEdits with ale_completion_autoimport turned off, if edits all start on the line):
|
||||
let g:ale_completion_autoimport = 0
|
||||
let b:ale_completion_info = {'line': 30}
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'word': 'next_callback',
|
||||
\ 'menu': 'PlayTimeCallback',
|
||||
\ 'info': '',
|
||||
\ 'kind': 'v',
|
||||
\ 'icase': 1,
|
||||
\ }
|
||||
\ ],
|
||||
\ ale#completion#ParseLSPCompletions({
|
||||
\ 'id': 226,
|
||||
\ 'jsonrpc': '2.0',
|
||||
\ 'result': {
|
||||
\ 'isIncomplete': v:false,
|
||||
\ 'items': [
|
||||
\ {
|
||||
\ 'detail': 'PlayTimeCallback',
|
||||
\ 'filterText': 'next_callback',
|
||||
\ 'insertText': 'next_callback',
|
||||
\ 'insertTextFormat': 1,
|
||||
\ 'kind': 6,
|
||||
\ 'label': ' next_callback',
|
||||
\ 'sortText': '3ee19999next_callback',
|
||||
\ 'additionalTextEdits': [
|
||||
\ {
|
||||
\ 'range': {
|
||||
\ 'start': {
|
||||
\ 'line': 29,
|
||||
\ 'character': 10,
|
||||
\ },
|
||||
\ 'end': {
|
||||
\ 'line': 29,
|
||||
\ 'character': 10,
|
||||
\ },
|
||||
\ },
|
||||
\ 'newText': 'next_callback',
|
||||
\ },
|
||||
\ ],
|
||||
\ },
|
||||
\ ],
|
||||
\ },
|
||||
\ })
|
||||
|
||||
Reference in New Issue
Block a user