summaryrefslogtreecommitdiff
path: root/script/parser/luadoc.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-26 10:32:30 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-26 10:32:30 +0800
commitcac8e5971b885a8a4dd865713bf0cd2972b1f011 (patch)
tree5a34314ec10603591a38c5f9c86ffd4c994a29df /script/parser/luadoc.lua
parent5c9c05ef68f781d95a967aa42c66696121df14fe (diff)
downloadlua-language-server-cac8e5971b885a8a4dd865713bf0cd2972b1f011.zip
fix tail doc
Diffstat (limited to 'script/parser/luadoc.lua')
-rw-r--r--script/parser/luadoc.lua45
1 files changed, 26 insertions, 19 deletions
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index fdf640ee..2b2396ec 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -905,25 +905,9 @@ local function bindGeneric(binded)
end
end
-local function bindDoc(state, lns, binded)
- if not binded then
- return
- end
- local lastDoc = binded[#binded]
- if not lastDoc then
- return
- end
- local bindSources = {}
- for _, doc in ipairs(binded) do
- doc.bindGroup = binded
- doc.bindSources = bindSources
- end
- bindGeneric(binded)
- local row = guide.positionOf(lns, lastDoc.finish)
- local cstart, _ = guide.lineRange(lns, row)
- local _, nfinish = guide.lineRange(lns, row + 1)
- guide.eachSourceBetween(state.ast, cstart, nfinish, function (src)
- if src.start and src.start < cstart then
+local function bindDocsBetween(state, binded, bindSources, start, finish)
+ guide.eachSourceBetween(state.ast, start, finish, function (src)
+ if src.start and src.start < start then
return
end
if src.type == 'local'
@@ -942,6 +926,29 @@ local function bindDoc(state, lns, binded)
end)
end
+local function bindDoc(state, lns, binded)
+ if not binded then
+ return
+ end
+ local lastDoc = binded[#binded]
+ if not lastDoc then
+ return
+ end
+ local bindSources = {}
+ for _, doc in ipairs(binded) do
+ doc.bindGroup = binded
+ doc.bindSources = bindSources
+ end
+ bindGeneric(binded)
+ local row = guide.positionOf(lns, lastDoc.finish)
+ local cstart, cfinish = guide.lineRange(lns, row)
+ local nstart, nfinish = guide.lineRange(lns, row + 1)
+ bindDocsBetween(state, binded, bindSources, cstart, cfinish)
+ if #bindSources == 0 then
+ bindDocsBetween(state, binded, bindSources, nstart, nfinish)
+ end
+end
+
local function bindDocs(state)
local lns = lines(nil, state.lua)
local binded