summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-30 15:25:56 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-30 15:25:56 +0800
commitf0f9a4ea4509dfb764a5dfebd5e86e679c8f4b03 (patch)
tree5e2c7fcd5acb1598d4398f29a6d48c4e4d834be8 /script/core
parent789cb1598a53c615164a5df7a1c4056f7d4130eb (diff)
parent820aa1a56a8a4bdd8fc7098b1e7cff5dd190b2eb (diff)
downloadlua-language-server-f0f9a4ea4509dfb764a5dfebd5e86e679c8f4b03.zip
Merge remote-tracking branch 'origin/master' into multi-workspace
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 21f6ea0c..9a7847f8 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