summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-22 20:29:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-22 20:29:22 +0800
commit22cfc98fa8684002e6ab8a8279e898862ba0f494 (patch)
tree19d5ab0c9948d0e0ebacee72cd4689aad4b8cee6
parent928b40c6f186c4692212ff1f9751da4755aa6841 (diff)
downloadlua-language-server-22cfc98fa8684002e6ab8a8279e898862ba0f494.zip
fix
-rw-r--r--script/core/completion.lua2
-rw-r--r--test/completion/common.lua16
2 files changed, 17 insertions, 1 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index f7464064..4f666847 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -70,7 +70,7 @@ local function findNearestTableField(state, position)
local uri = state.uri
local text = files.getText(uri)
local offset = guide.positionToOffset(state, position)
- local soffset = lookBackward.findAnyOffset(text, offset - 1)
+ local soffset = lookBackward.findAnyOffset(text, offset)
if not soffset then
return nil
end
diff --git a/test/completion/common.lua b/test/completion/common.lua
index a01b2d10..00a3d56d 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -2739,3 +2739,19 @@ f({zzz<??>})
kind = define.CompletionItemKind.Property,
}
}
+
+TEST [[
+---@class A
+---@field zzzz number
+
+---@param y A
+local function f(x, y) end
+
+f(1, {<??>})
+]]
+{
+ [1] = {
+ label = 'zzzz',
+ kind = define.CompletionItemKind.Property,
+ }
+}