diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-11 17:16:57 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-11 17:16:57 +0800 |
commit | 4f98d5565b416f71d605cafcb22bd76cf697fd03 (patch) | |
tree | c31b78ccaab38f78f9ee6eb08970007d22211cbb | |
parent | 599065480e33e21e66d307b06e8f8deae101756e (diff) | |
download | lua-language-server-4f98d5565b416f71d605cafcb22bd76cf697fd03.zip |
fix #1035
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/code-action.lua | 6 | ||||
-rw-r--r-- | test/code_action/init.lua | 30 |
3 files changed, 37 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md index c4a13080..e204cd74 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## 3.0.1 * `FIX` [#1033](https://github.com/sumneko/lua-language-server/issues/1033) * `FIX` [#1034](https://github.com/sumneko/lua-language-server/issues/1034) +* `FIX` [#1035](https://github.com/sumneko/lua-language-server/issues/1035) ## 3.0.0 `2022-4-10` diff --git a/script/core/code-action.lua b/script/core/code-action.lua index 4b1ebd57..6bba0a82 100644 --- a/script/core/code-action.lua +++ b/script/core/code-action.lua @@ -415,6 +415,12 @@ local function checkSwapParams(results, uri, start, finish) elseif source.type == 'funcargs' then local var = source.parent.parent if guide.isSet(var) then + if var.type == 'tablefield' then + var = var.field + end + if var.type == 'tableindex' then + var = var.index + end node = text:sub( guide.positionToOffset(state, var.start) + 1, guide.positionToOffset(state, var.finish) diff --git a/test/code_action/init.lua b/test/code_action/init.lua index 01423850..67528d59 100644 --- a/test/code_action/init.lua +++ b/test/code_action/init.lua @@ -113,6 +113,36 @@ return function(<?a?>, b, c) end }, } +TEST [[ +f = function (<?a?>, b) end +]] +{ + { + title = lang.script('ACTION_SWAP_PARAMS', { + node = 'f', + index = 2, + }), + kind = 'refactor.rewrite', + edit = EXISTS, + }, +} + +TEST [[ +local t = { + f = function (<?a?>, b) end +} +]] +{ + { + title = lang.script('ACTION_SWAP_PARAMS', { + node = 'f', + index = 2, + }), + kind = 'refactor.rewrite', + edit = EXISTS, + }, +} + --TEST [[ --<?print(1) --print(2)?> |