Skip to content

Commit fbf9084

Browse files
committed
fix
1 parent c8e9a4a commit fbf9084

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

script/core/completion/completion.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,17 +1525,29 @@ local function tryTable(state, position, results)
15251525
end
15261526

15271527
local function getComment(state, position)
1528+
local offset = guide.positionToOffset(state, position)
1529+
local symbolOffset = lookBackward.findAnyOffset(state.lua, offset)
1530+
if not symbolOffset then
1531+
return
1532+
end
1533+
local symbolPosition = guide.offsetToPosition(state, symbolOffset)
15281534
for _, comm in ipairs(state.comms) do
1529-
if position > comm.start and position <= comm.finish then
1535+
if symbolPosition > comm.start and symbolPosition <= comm.finish then
15301536
return comm
15311537
end
15321538
end
15331539
return nil
15341540
end
15351541

15361542
local function getluaDoc(state, position)
1543+
local offset = guide.positionToOffset(state, position)
1544+
local symbolOffset = lookBackward.findAnyOffset(state.lua, offset)
1545+
if not symbolOffset then
1546+
return
1547+
end
1548+
local symbolPosition = guide.offsetToPosition(state, symbolOffset)
15371549
for _, doc in ipairs(state.ast.docs) do
1538-
if position >= doc.start and position <= doc.range then
1550+
if symbolPosition >= doc.start and symbolPosition <= doc.range then
15391551
return doc
15401552
end
15411553
end

0 commit comments

Comments
 (0)