Skip to content

Commit

Permalink
lock parsing resume
Browse files Browse the repository at this point in the history
fix #2056
  • Loading branch information
sumneko committed Apr 26, 2023
1 parent 881e16b commit 76c7098
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
* `FIX` commandline parameter `checklevel` may not work
* `FIX` [#2036]
* `FIX` [#2037]
* `FIX` [#2056]
* `FIX` [#2077]
* `FIX` [#2081]

[#2036]: https://github.com/LuaLS/lua-language-server/issues/2036
[#2037]: https://github.com/LuaLS/lua-language-server/issues/2037
[#2056]: https://github.com/LuaLS/lua-language-server/issues/2056
[#2077]: https://github.com/LuaLS/lua-language-server/issues/2077
[#2081]: https://github.com/LuaLS/lua-language-server/issues/2081

Expand Down
19 changes: 6 additions & 13 deletions script/parser/luadoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@ local function parseResume(parent)
return result
end

local lockResume = false

function parseType(parent)
local result = {
type = 'doc.type',
Expand Down Expand Up @@ -778,20 +780,10 @@ function parseType(parent)
return false
end

local checkResume = true
local nsymbol, ncontent = peekToken()
if nsymbol == 'symbol' then
if ncontent == ','
or ncontent == ':'
or ncontent == '|'
or ncontent == ')'
or ncontent == '}' then
checkResume = false
end
end

if checkResume then
if not lockResume then
lockResume = true
while pushResume() do end
lockResume = false
end

if #result.types == 0 then
Expand Down Expand Up @@ -2051,6 +2043,7 @@ return function (state)
if not comment then
break
end
lockResume = false
local doc, rests = buildLuaDoc(comment)
if doc then
insertDoc(doc, comment)
Expand Down
10 changes: 10 additions & 0 deletions test/type_inference/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4268,3 +4268,13 @@ local b = '2';
local <?c?> = a .. b;
]]

TEST 'number|{ [1]: string }' [[
---@alias Some
---| { [1]: string }
---| number
local x ---@type Some
print(<?x?>)
]]

0 comments on commit 76c7098

Please sign in to comment.