Skip to content

Commit

Permalink
fix #396 fix check of string and remove limit
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Feb 20, 2021
1 parent 28f066e commit 88b6118
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* `FIX` completion: may insert error text when continuous inputing
* `FIX` completion: may insert error text after resolve
* `FIX` [#349](https://github.com/sumneko/lua-language-server/issues/349)
* `FIX` [#396](https://github.com/sumneko/lua-language-server/issues/396)

## 1.15.1
`2021-2-18`
Expand Down
18 changes: 10 additions & 8 deletions script/parser/guide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2403,12 +2403,17 @@ function m.checkSameSimpleAsKeyOrValueInForParis(status, ref, start, pushQueue)
end

local function hasTypeName(doc, name)
if doc.type ~= 'doc.type' then
return false
if doc.type == 'doc.type' then
for _, tunit in ipairs(doc.types) do
if tunit.type == 'doc.type.name'
and tunit[1] == name then
return true
end
end
end
for _, tunit in ipairs(doc.types) do
if tunit.type == 'doc.type.name'
and tunit[1] == name then
if doc.type == 'doc.type.name'
or doc.type == 'doc.class.name' then
if doc[1] == name then
return true
end
end
Expand All @@ -2421,9 +2426,6 @@ function m.checkSameSimpleInString(status, ref, start, pushQueue, mode)
and not hasTypeName(ref, 'string') then
return
end
if status.depth > 5 then
return
end
if not status.interface.docType then
return
end
Expand Down
10 changes: 10 additions & 0 deletions test/completion/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2051,3 +2051,13 @@ f({
kind = define.CompletionItemKind.Property,
},
}

TEST [[
---@return string
local function f() end
local s = f()
s.$
]]
(EXISTS)

0 comments on commit 88b6118

Please sign in to comment.