summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-08 15:51:43 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-08 15:51:43 +0800
commit46069db446bd54fc3b3ee5d7e1a80d35ec3240b7 (patch)
treecbeaeeecf68366d4236b2a88e886796e058d14a6
parent419052ee299b2b9c23dfd644fea1ae92d197a633 (diff)
downloadlua-language-server-46069db446bd54fc3b3ee5d7e1a80d35ec3240b7.zip
fix #443
-rw-r--r--changelog.md1
-rw-r--r--script/core/completion.lua2
-rw-r--r--test/completion/init.lua22
3 files changed, 24 insertions, 1 deletions
diff --git a/changelog.md b/changelog.md
index f966aa35..ee96e079 100644
--- a/changelog.md
+++ b/changelog.md
@@ -5,6 +5,7 @@
* `CHG` `Windows`: dose not provide `ucrt` any more
* `CHG` `Lua.workspace.library`: use `path[]` instead of `<path, true>`
* `FIX` missed syntax error `local a <const>= 1`
+* `FIX` [#443](https://github.com/sumneko/lua-language-server/issues/443)
## 1.17.4
`2021-3-4`
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 613ca062..f9fe7686 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -198,7 +198,7 @@ local function findParentInStringIndex(ast, text, offset)
end
local function buildFunctionSnip(source, oop)
- local name = getName(source):gsub('^.-[$.:]', '')
+ local name = getName(source):gsub('^.+[$.:]', '')
local defs = vm.getDefs(source, 0)
local args = ''
for _, def in ipairs(defs) do
diff --git a/test/completion/init.lua b/test/completion/init.lua
index e0ac1a2d..930bc92f 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -2203,3 +2203,25 @@ local x = {
kind = define.CompletionItemKind.EnumMember,
},
}
+
+Cared['insertText'] = true
+TEST [[
+---@class A.B.C
+local m
+
+function m.f()
+end
+
+m.f$
+]]{
+ {
+ label = "f",
+ kind = define.CompletionItemKind.Function,
+ },
+ {
+ label = "f()",
+ kind = define.CompletionItemKind.Snippet,
+ insertText = 'f()',
+ },
+}
+Cared['insertText'] = nil