Skip to content

Commit 4f98d55

Browse files
committed
fix #1035
1 parent 5990654 commit 4f98d55

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 3.0.1
44
* `FIX` [#1033](https://github.com./sumneko/lua-language-server/issues/1033)
55
* `FIX` [#1034](https://github.com./sumneko/lua-language-server/issues/1034)
6+
* `FIX` [#1035](https://github.com./sumneko/lua-language-server/issues/1035)
67

78
## 3.0.0
89
`2022-4-10`

script/core/code-action.lua

+6
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,12 @@ local function checkSwapParams(results, uri, start, finish)
415415
elseif source.type == 'funcargs' then
416416
local var = source.parent.parent
417417
if guide.isSet(var) then
418+
if var.type == 'tablefield' then
419+
var = var.field
420+
end
421+
if var.type == 'tableindex' then
422+
var = var.index
423+
end
418424
node = text:sub(
419425
guide.positionToOffset(state, var.start) + 1,
420426
guide.positionToOffset(state, var.finish)

test/code_action/init.lua

+30
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,36 @@ return function(<?a?>, b, c) end
113113
},
114114
}
115115

116+
TEST [[
117+
f = function (<?a?>, b) end
118+
]]
119+
{
120+
{
121+
title = lang.script('ACTION_SWAP_PARAMS', {
122+
node = 'f',
123+
index = 2,
124+
}),
125+
kind = 'refactor.rewrite',
126+
edit = EXISTS,
127+
},
128+
}
129+
130+
TEST [[
131+
local t = {
132+
f = function (<?a?>, b) end
133+
}
134+
]]
135+
{
136+
{
137+
title = lang.script('ACTION_SWAP_PARAMS', {
138+
node = 'f',
139+
index = 2,
140+
}),
141+
kind = 'refactor.rewrite',
142+
edit = EXISTS,
143+
},
144+
}
145+
116146
--TEST [[
117147
--<?print(1)
118148
--print(2)?>

0 commit comments

Comments
 (0)