summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-24 14:54:16 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-24 14:54:16 +0800
commitfbf9084fbd5e96eb9bd5854871495423184d507b (patch)
treecd97af0d31f2f2ee3a9f78adf86ad6246421f59d /script/core
parentc8e9a4a665da5e8dd73fb7cfb1a94b98f0e45c65 (diff)
downloadlua-language-server-fbf9084fbd5e96eb9bd5854871495423184d507b.zip
fix
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion/completion.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua
index d98a7c3d..425c8026 100644
--- a/script/core/completion/completion.lua
+++ b/script/core/completion/completion.lua
@@ -1525,8 +1525,14 @@ local function tryTable(state, position, results)
end
local function getComment(state, position)
+ local offset = guide.positionToOffset(state, position)
+ local symbolOffset = lookBackward.findAnyOffset(state.lua, offset)
+ if not symbolOffset then
+ return
+ end
+ local symbolPosition = guide.offsetToPosition(state, symbolOffset)
for _, comm in ipairs(state.comms) do
- if position > comm.start and position <= comm.finish then
+ if symbolPosition > comm.start and symbolPosition <= comm.finish then
return comm
end
end
@@ -1534,8 +1540,14 @@ local function getComment(state, position)
end
local function getluaDoc(state, position)
+ local offset = guide.positionToOffset(state, position)
+ local symbolOffset = lookBackward.findAnyOffset(state.lua, offset)
+ if not symbolOffset then
+ return
+ end
+ local symbolPosition = guide.offsetToPosition(state, symbolOffset)
for _, doc in ipairs(state.ast.docs) do
- if position >= doc.start and position <= doc.range then
+ if symbolPosition >= doc.start and symbolPosition <= doc.range then
return doc
end
end