summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/parser/guide.lua13
-rw-r--r--script/parser/luadoc.lua5
2 files changed, 11 insertions, 7 deletions
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 0ff77b4b..60ef1ee4 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -588,21 +588,20 @@ end
---@param lines table
---@return integer {name = 'row'}
---@return integer {name = 'col'}
----@return table {name = 'line'} 命中那一行的细节信息
function m.positionOf(lines, offset)
if offset < 1 then
- return 0, 0, nil
+ return 0, 0
end
local lastLine = lines[#lines]
if offset > lastLine.finish then
- return #lines, lastLine.finish - lastLine.start + 1, lastLine
+ return #lines, lastLine.finish - lastLine.start + 1
end
local min = 1
local max = #lines
for _ = 1, 100 do
if max <= min then
local line = lines[min]
- return min, offset - line.start + 1, line
+ return min, offset - line.start + 1
end
local row = (max - min) // 2 + min
local line = lines[row]
@@ -611,7 +610,7 @@ function m.positionOf(lines, offset)
elseif offset > line.finish then
min = row + 1
else
- return row, offset - line.start + 1, line
+ return row, offset - line.start + 1
end
end
error('Stack overflow!')
@@ -665,6 +664,10 @@ function m.lineRange(lines, row, ignoreNL)
end
end
+function m.lineData(lines, row)
+ return lines[row]
+end
+
function m.getKeyTypeOfLiteral(obj)
if not obj then
return nil
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 9a836da3..cd4e76a9 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -917,8 +917,9 @@ local function isNextLine(lns, binded, doc)
return false
end
local lastDoc = binded[#binded]
- local _, lastDocStartCol, lastDocStartLine = guide.positionOf(lns, lastDoc.originalComment.start)
- if haveCodeBeforeDocInCurLine(lastDocStartLine, lastDocStartCol) then
+ local lastDocStartRow, lastDocStartCol = guide.positionOf(lns, lastDoc.originalComment.start)
+ local lastDocStartLineData = guide.lineData(lns, lastDocStartRow)
+ if haveCodeBeforeDocInCurLine(lastDocStartLineData, lastDocStartCol) then
return false
end