Skip to content

Commit

Permalink
test and readme update for motion count change
Browse files Browse the repository at this point in the history
  • Loading branch information
alex.tylor committed Jun 2, 2021
1 parent e7de7ab commit 61a81d7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Or use the defualt mappings:
** `gcc` comment/uncomment current line
** `gcip` comment/uncomment a paragraph
** `gc4w` comment/uncomment current line
** `gc4l` comment/uncomment 4 lines down, starting with current line

## Configure

Expand Down
1 change: 1 addition & 0 deletions lua/nvim_comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function M.operator(mode)
end

function M.comment_toggle(line_start, line_end)
line_end = vim.v.count ~= 0 and line_end + vim.v.count - 1 or line_end
local left, right = M.get_comment_wrapper()
if not left or not right then return end

Expand Down
20 changes: 20 additions & 0 deletions tests/comment_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ end
runCommandAndAssert(1, ".", expected)
end)

it("Should comment/uncomment motion with count and dot", function()
local expected = [[
-- local function dummy_func()
-- print("This is a dummy func")
end
local function another_dummy_func()
print("This is a another dummy func")
end
]]

setUpBuffer(input, "lua")
-- comment
runCommandAndAssert(1, "gc2l", expected)
-- uncomment
runCommandAndAssert(1, "gc2l", input)
-- comment, via dot
runCommandAndAssert(1, ".", expected)
end)

it("Should comment out another pararaph via dot", function()
local first_expected = [[
-- local function dummy_func()
Expand Down

0 comments on commit 61a81d7

Please sign in to comment.