summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/workspace.lua14
-rw-r--r--server/test/crossfile/completion.lua8
2 files changed, 15 insertions, 7 deletions
diff --git a/server/src/workspace.lua b/server/src/workspace.lua
index fe1289f4..b05105a0 100644
--- a/server/src/workspace.lua
+++ b/server/src/workspace.lua
@@ -225,10 +225,18 @@ function mt:matchPath(baseUri, input)
if list then
for _, str in ipairs(list) do
if #str >= #input and str:sub(1, #input) == input then
- if not map[str]
- or similarity(filename, baseName) > similarity(map[str], baseName)
- then
+ if not map[str] then
map[str] = filename
+ else
+ local s1 = similarity(filename, baseName)
+ local s2 = similarity(map[str], baseName)
+ if s1 > s2 then
+ map[str] = filename
+ elseif s1 == s2 then
+ if filename < map[str] then
+ map[str] = filename
+ end
+ end
end
end
end
diff --git a/server/test/crossfile/completion.lua b/server/test/crossfile/completion.lua
index b5c3bc1b..16d1460f 100644
--- a/server/test/crossfile/completion.lua
+++ b/server/test/crossfile/completion.lua
@@ -298,15 +298,15 @@ TEST {
},
completion = {
{
- label = 'x111',
+ label = 'x000',
kind = CompletionItemKind.File,
- documentation = 'abc/x111.lua',
+ documentation = 'x000.lua',
textEdit = EXISTS,
},
{
- label = 'x000',
+ label = 'x111',
kind = CompletionItemKind.File,
- documentation = 'x000.lua',
+ documentation = 'abc/x111.lua',
textEdit = EXISTS,
},
}