Skip to content

Commit

Permalink
fix #612
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Jul 22, 2021
1 parent 48c5a0e commit 2cc3a20
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 2.3.3
* `NEW` config supports prop
* `FIX` [#612](https://github.com/sumneko/lua-language-server/issues/612)

## 2.3.2
`2021-7-21`
Expand Down
20 changes: 20 additions & 0 deletions script/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ function m.getOption(name)
return option
end

function m.getAbility(name)
local current = m.info.capabilities
while true do
local parent, nextPos = name:match '^([^%.]+)()'
if not parent then
break
end
current = current[parent]
if not current then
return nil
end
if nextPos > #name then
break
else
name = name:sub(nextPos + 1)
end
end
return current
end

local function packMessage(...)
local strs = table.pack(...)
for i = 1, strs.n do
Expand Down
32 changes: 22 additions & 10 deletions script/provider/provider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,17 @@ proto.on('textDocument/definition', function (params)
local targetUri = info.uri
if targetUri then
if files.exists(targetUri) then
response[i] = define.locationLink(targetUri
, files.range(targetUri, info.target.start, info.target.finish)
, files.range(targetUri, info.target.start, info.target.finish)
, files.range(uri, info.source.start, info.source.finish)
)
if client.getAbility 'textDocument.definition.linkSupport' then
response[i] = define.locationLink(targetUri
, files.range(targetUri, info.target.start, info.target.finish)
, files.range(targetUri, info.target.start, info.target.finish)
, files.range(uri, info.source.start, info.source.finish)
)
else
response[i] = define.location(targetUri
, files.range(targetUri, info.target.start, info.target.finish)
)
end
end
end
end
Expand All @@ -320,11 +326,17 @@ proto.on('textDocument/typeDefinition', function (params)
local targetUri = info.uri
if targetUri then
if files.exists(targetUri) then
response[i] = define.locationLink(targetUri
, files.range(targetUri, info.target.start, info.target.finish)
, files.range(targetUri, info.target.start, info.target.finish)
, files.range(uri, info.source.start, info.source.finish)
)
if client.getAbility 'textDocument.typeDefinition.linkSupport' then
response[i] = define.locationLink(targetUri
, files.range(targetUri, info.target.start, info.target.finish)
, files.range(targetUri, info.target.start, info.target.finish)
, files.range(uri, info.source.start, info.source.finish)
)
else
response[i] = define.location(targetUri
, files.range(targetUri, info.target.start, info.target.finish)
)
end
end
end
end
Expand Down

0 comments on commit 2cc3a20

Please sign in to comment.