summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/core/completion.lua2
-rw-r--r--test/completion/init.lua26
3 files changed, 28 insertions, 1 deletions
diff --git a/changelog.md b/changelog.md
index 300b0287..2d7ff239 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,7 @@
## 2.2.3
* `FIX` incorrect doc: `debug.getlocal`
+* `FIX` completion: incorrect callback
* `FIX` [#592](https://github.com/sumneko/lua-language-server/issues/592)
## 2.2.2
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 860126b9..17c4611f 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1037,7 +1037,7 @@ local function mergeEnums(a, b, source)
textEdit = source and {
start = source.start,
finish = source.finish,
- newText = label,
+ newText = enum.insertText or label,
},
}
a[#a+1] = result
diff --git a/test/completion/init.lua b/test/completion/init.lua
index 327d72a4..9b1c55c1 100644
--- a/test/completion/init.lua
+++ b/test/completion/init.lua
@@ -2588,3 +2588,29 @@ t.GGG$
kind = define.CompletionItemKind.Function,
},
}
+
+TEST [[
+---@param f fun(a: any, b: any):boolean
+local function f(f) end
+
+f(fun$)
+]]
+{
+ {
+ label = 'fun(a: any, b: any):boolean',
+ kind = define.CompletionItemKind.Function,
+ textEdit = {
+ newText = 'function (${1:a}, ${2:b})\n\t$0\nend',
+ start = 68,
+ finish = 70,
+ }
+ },
+ {
+ label = 'function',
+ kind = define.CompletionItemKind.Keyword,
+ },
+ {
+ label = 'function ()',
+ kind = define.CompletionItemKind.Snippet,
+ }
+}