diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/rename.lua | 10 | ||||
-rw-r--r-- | test/crossfile/references.lua | 19 | ||||
-rw-r--r-- | test/rename/init.lua | 3 |
4 files changed, 22 insertions, 11 deletions
diff --git a/changelog.md b/changelog.md index 82f8351c..595dfe93 100644 --- a/changelog.md +++ b/changelog.md @@ -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` diff --git a/script/core/rename.lua b/script/core/rename.lua index 0c48dbc4..d90a49bb 100644 --- a/script/core/rename.lua +++ b/script/core/rename.lua @@ -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 @@ -276,7 +269,6 @@ local function rename(source, newname, callback) return ofField(parent, newname, callback) end end - return end local function prepareRename(source) diff --git a/test/crossfile/references.lua b/test/crossfile/references.lua index 145792b5..cd7689ed 100644 --- a/test/crossfile/references.lua +++ b/test/crossfile/references.lua @@ -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!>) + ]] + } +} diff --git a/test/rename/init.lua b/test/rename/init.lua index 774c86d2..f9f0c13d 100644 --- a/test/rename/init.lua +++ b/test/rename/init.lua @@ -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 @@ -118,7 +118,6 @@ t = { t["!!!"] = 1 a = t["!!!"] ]] -config.set('Lua.IntelliSense.traceBeSetted', false) TEST ('a', '"') [[ print(t[ "a" ]) |