Skip to content

Commit f1c0f6b

Browse files
committed
Continue refactor of swap.lua
1 parent dc2eb65 commit f1c0f6b

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lua/treewalker/swap.lua

+8-10
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ local function is_supported_ft()
2828
return not unsupported_filetypes[ft]
2929
end
3030

31+
-- pipes follow a specific pattern of taking a node and always returning a
32+
-- node: either the hopeful that it found, or the passed in original
3133
---@param node TSNode
3234
---@return TSNode
3335
local function get_highest_coincident_pipe(node)
3436
local candidate = nodes.get_highest_coincident(node)
3537
return candidate or node
3638
end
3739

40+
-- pipes follow a specific pattern of taking a node and always returning a
41+
-- node: either the hopeful that it found, or the passed in original
3842
---@param node TSNode
3943
---@return TSNode
4044
local function get_highest_string_node_pipe(node)
@@ -46,11 +50,8 @@ function M.swap_down()
4650
if not is_on_target_node() then return end
4751
if not is_supported_ft() then return end
4852

49-
local target, row, line = targets.down()
50-
51-
if not target or not row or not line then
52-
return
53-
end
53+
local target = targets.down()
54+
if not target then return end
5455

5556
local current = nodes.get_current()
5657
current = get_highest_coincident_pipe(current)
@@ -80,11 +81,8 @@ function M.swap_up()
8081
if not is_on_target_node() then return end
8182
if not is_supported_ft() then return end
8283

83-
local target, row, line = targets.up()
84-
85-
if not target or not row or not line then
86-
return
87-
end
84+
local target = targets.up()
85+
if not target then return end
8886

8987
local current = nodes.get_current()
9088
current = get_highest_coincident_pipe(current)

0 commit comments

Comments
 (0)