Skip to content

Commit

Permalink
Continuing iteration
Browse files Browse the repository at this point in the history
Currently it's looking at lines. It's not working fully,
          something wrong in the swap logic. But it's looking at lines.
          It might be nice to do this by nodes, so instead of
          highest_coincident starting on the same line, looking at
          the highest coincident on the same line and col. And
          swapping like that as well.
  • Loading branch information
aaronik committed Dec 18, 2024
1 parent 25492c2 commit ce584e9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 166 deletions.
42 changes: 29 additions & 13 deletions lua/treewalker/swapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,12 @@ function M.swap_in()
end
end

---@return nil
function M.swap_up()
local target, row, line = targets.up()

if target and row and line then
--util.log("no up candidate")
ops.jump(row, target)
end
end

---@return nil
function M.swap_down()
---@param target TSNode
---@param row integer
---@param line string
local function swap(target, row, line)
local current = nodes.get_current()
local target, row, line = targets.down()
current = nodes.get_highest_coincident(current)

if not target or not row or not line then
--util.log("no down candidate")
Expand All @@ -55,4 +47,28 @@ function M.swap_down()
)
end

---@return nil
function M.swap_down()
local target, row, line = targets.down()

if not target or not row or not line then
--util.log("no down candidate")
return
end

swap(target, row, line)
end

---@return nil
function M.swap_up()
local target, row, line = targets.up()

if not target or not row or not line then
--util.log("no down candidate")
return
end

swap(target, row, line)
end

return M
153 changes: 0 additions & 153 deletions tests/treewalker/acceptance_spec.lua

This file was deleted.

0 comments on commit ce584e9

Please sign in to comment.