Skip to content

Commit

Permalink
quick test (#27)
Browse files Browse the repository at this point in the history
block select fix
  • Loading branch information
terrortylor authored Jul 23, 2021
1 parent 05feb57 commit 8780a53
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lua/nvim_comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function M.operator(mode)
if not mode then
line1 = api.nvim_win_get_cursor(0)[1]
line2 = line1
elseif mode:match("[vV]") then
elseif mode:match("[vV]") then
line1 = api.nvim_buf_get_mark(0, "<")[1]
line2 = api.nvim_buf_get_mark(0, ">")[1]
else
Expand Down
44 changes: 39 additions & 5 deletions tests/comment_spec.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
local function setUpBuffer(input, filetype)
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_option(buf, 'filetype', filetype)
vim.api.nvim_command("sbuffer " .. buf)
vim.api.nvim_command("buffer " .. buf)

vim.api.nvim_buf_set_lines(0, 0, -1, true, vim.split(input, "\n"))
end

local function goToLineRunReturn(line, feedkeys)
local function goToLineRunKeys(line, feedkeys)
vim.api.nvim_win_set_cursor(0, {line,0})
vim.api.nvim_feedkeys(feedkeys, "x", false)

local keys = vim.api.nvim_replace_termcodes(feedkeys, true, false, true)
vim.api.nvim_feedkeys(keys, "x", false)
end
local function getBufLines()
local result = vim.api.nvim_buf_get_lines(
0, 0, vim.api.nvim_buf_line_count(0), false
)
return result
end

local function runCommandAndAssert(line, feedkeys, expected)
local result = goToLineRunReturn(line, feedkeys)
goToLineRunKeys(line, feedkeys)
local result = getBufLines()
assert.are.same(vim.split(expected, "\n"), result)
end

Expand Down Expand Up @@ -277,3 +280,34 @@ end]]
end)
end)

describe('issues', function()

before_each(function()
local testModule = require('nvim_comment')
testModule.setup({
marker_padding = true
})
end)

it("issue 22", function()
local input = [[
local foo = 'foo'
local bar = 'bar'
local baz = 'baz'
local foo = 'foo'
local bar = 'bar'
local baz = 'baz'
]]
local expected = [[
-- local foo = 'foo'
-- local bar = 'bar'
-- local baz = 'baz'
local foo = 'foo'
local bar = 'bar'
local baz = 'baz'
]]

setUpBuffer(input, "lua")
runCommandAndAssert(1, "gg0<c-v>jjgc", expected)
end)
end)

0 comments on commit 8780a53

Please sign in to comment.