summaryrefslogtreecommitdiff
path: root/script/core/completion/completion.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/core/completion/completion.lua')
-rw-r--r--script/core/completion/completion.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index 866d6590..43b5d5ce 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -78,7 +78,9 @@ local function findNearestSource(state, position)
---@type parser.object
local source
guide.eachSourceContain(state.ast, position, function (src)
- source = src
+ if not source or source.start <= src.start then
+ source = src
+ end
end)
return source
end