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