Skip to content

Commit

Permalink
fix #886
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Jan 4, 2022
1 parent 820aa1a commit 2d37173
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 2.5.7
* `FIX` [#879](https://github.com/sumneko/lua-language-server/issues/879)
* `FIX` [#884](https://github.com/sumneko/lua-language-server/issues/884)
* `FIX` [#886](https://github.com/sumneko/lua-language-server/issues/886)

## 2.5.6
`2021-12-27`
Expand Down
10 changes: 1 addition & 9 deletions script/core/rename.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,7 @@ end

local function ofField(source, newname, callback)
local key = guide.getKeyName(source)
local node
if source.type == 'tablefield'
or source.type == 'tableindex' then
node = source.parent
else
node = source.node
end
for _, src in ipairs(vm.getAllRefs(node, '*')) do
for _, src in ipairs(vm.getAllRefs(source)) do
ofFieldThen(key, src, newname, callback)
end
end
Expand Down Expand Up @@ -276,7 +269,6 @@ local function rename(source, newname, callback)
return ofField(parent, newname, callback)
end
end
return
end

local function prepareRename(source)
Expand Down
19 changes: 19 additions & 0 deletions test/crossfile/references.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,22 @@ TEST {
]]
}
}

TEST {
{
path = 'a.lua',
content = [[
local t = {}
t.<~x~> = 1
return t
]]
},
{
path = 'b.lua',
content = [[
local t = require 'a'
print(t.<!x!>)
]]
}
}
3 changes: 1 addition & 2 deletions test/rename/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ local function f(b)
end
]]

config.set('Lua.IntelliSense.traceBeSetted', true)
--config.set('Lua.IntelliSense.traceBeSetted', true)
TEST ('a', '!!!') [[
t = {
a = 0
Expand Down Expand Up @@ -118,7 +118,6 @@ t = {
t["!!!"] = 1
a = t["!!!"]
]]
config.set('Lua.IntelliSense.traceBeSetted', false)

TEST ('a', '"') [[
print(t[ "a" ])
Expand Down

0 comments on commit 2d37173

Please sign in to comment.