diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/core/completion.lua | 12 | ||||
-rw-r--r-- | server/test/crossfile/completion.lua | 16 |
2 files changed, 20 insertions, 8 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index 07b46402..8fe3888e 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -257,11 +257,13 @@ local function searchInArg(vm, inCall, inString, callback) end for _, v in ipairs(results) do if v ~= inString[1] then - local sep = inString[1]:find('[^%w_][%w_]-$') - if sep then - v = v:sub(sep+1) - end - callback(v, CompletionItemKind.File) + callback(v, CompletionItemKind.File, { + textEdit = { + start = inString.start+1, + finish = inString.finish-1, + newText = ('%q'):format(v):sub(2, -2), + } + }) end end end diff --git a/server/test/crossfile/completion.lua b/server/test/crossfile/completion.lua index 73d60d5b..6976fd7f 100644 --- a/server/test/crossfile/completion.lua +++ b/server/test/crossfile/completion.lua @@ -118,14 +118,17 @@ TEST { { label = 'abc', kind = CompletionItemKind.File, + textEdit = EXISTS, }, { label = 'abc.aaa', kind = CompletionItemKind.File, + textEdit = EXISTS, }, { label = 'abcde', kind = CompletionItemKind.File, + textEdit = EXISTS, }, } } @@ -144,6 +147,7 @@ TEST { { label = 'abc', kind = CompletionItemKind.File, + textEdit = EXISTS, }, } } @@ -166,6 +170,7 @@ TEST { { label = 'abc.init', kind = CompletionItemKind.File, + textEdit = EXISTS, }, } } @@ -186,8 +191,9 @@ TEST { }, completion = { { - label = 'init', + label = 'abc.init', kind = CompletionItemKind.File, + textEdit = EXISTS, }, } } @@ -208,8 +214,9 @@ TEST { }, completion = { { - label = 'init', + label = 'abc.init', kind = CompletionItemKind.File, + textEdit = EXISTS, }, } } @@ -230,8 +237,9 @@ TEST { }, completion = { { - label = 'core', + label = 'core.core', kind = CompletionItemKind.File, + textEdit = EXISTS, }, } } @@ -254,10 +262,12 @@ TEST { { label = 'x111', kind = CompletionItemKind.File, + textEdit = EXISTS, }, { label = 'x000', kind = CompletionItemKind.File, + textEdit = EXISTS, }, } } |