summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-28 16:01:17 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-28 16:01:17 +0800
commit6f3cb7196f0230f6cf18b21a1617d133d32d611c (patch)
tree1b97090f771957c0c48d3315f81ec98c313effcc /server/src
parentd0cad6f25ede39e95ae4486a24abba643b0860fb (diff)
downloadlua-language-server-6f3cb7196f0230f6cf18b21a1617d133d32d611c.zip
修正自动完成搜索require的bug
Diffstat (limited to 'server/src')
-rw-r--r--server/src/core/completion.lua9
-rw-r--r--server/src/workspace.lua2
2 files changed, 9 insertions, 2 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index cdb68580..29a3637e 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -257,7 +257,14 @@ local function searchInArg(vm, inCall, inString, callback)
end
for _, v in ipairs(results) do
if v ~= inString[1] then
- callback(v, CompletionItemKind.File)
+ local sep = inString[1]:find('[^%w_][%w_]-$')
+ local insertText
+ if sep then
+ --v = v:sub(sep+1)
+ end
+ callback(v, CompletionItemKind.File, {
+ insertText = insertText,
+ })
end
end
end
diff --git a/server/src/workspace.lua b/server/src/workspace.lua
index 9e9c03d2..aaa9a47d 100644
--- a/server/src/workspace.lua
+++ b/server/src/workspace.lua
@@ -181,7 +181,7 @@ function mt:matchPath(baseUri, input)
local list = self:convertPathAsRequire(filename, start + 1)
if list then
for _, str in ipairs(list) do
- if #str >= #input then
+ if #str >= #input and str:sub(1, #input) == input then
if not map[str]
or similarity(filename, baseName) > similarity(map[str], baseName)
then