summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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