Skip to content

Commit

Permalink
Merge pull request #17 from julienvincent/motions-bug
Browse files Browse the repository at this point in the history
fix #15 motions bug
  • Loading branch information
armed authored Aug 7, 2023
2 parents 5500eef + f467e46 commit d7eb67e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/nvim-paredit/api/motions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ function M._move_to_element(count, reversed)
end
end

if lang.node_is_comment(current_node) then
count = count + 1
end
local next_pos
if is_in_middle and count == 1 then
next_pos = node_edge
Expand Down
27 changes: 27 additions & 0 deletions tests/nvim-paredit/motion_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,33 @@ describe("motions", function()
})
end)

it("make an extra motion if cursor is in comment", function()
prepare_buffer({
content = { "(aa", ";; comment", "bb)" },
cursor = { 2, 3 },
})
paredit.move_to_next_element()
expect({
cursor = { 3, 1 },
})
paredit.move_to_prev_element()
expect({
cursor = { 3, 0 },
})
paredit.move_to_prev_element()
expect({
cursor = { 1, 1 },
})
prepare_buffer({
content = { "(aa", ";; comment", "bb)" },
cursor = { 2, 3 },
})
paredit.move_to_prev_element()
expect({
cursor = { 1, 1 },
})
end)

it("should move to the end of the current form before jumping to next", function()
expect_all(paredit.move_to_next_element, {
{
Expand Down

0 comments on commit d7eb67e

Please sign in to comment.