Skip to content

Commit

Permalink
Send a single line block containing parenthesis (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgranstrom authored Sep 16, 2024
1 parent d5aa882 commit cb6a968
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/scnvim/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ end
function M.send_block(cb, flash)
flash = flash == nil and true or flash
local lstart, lend = unpack(vim.fn['scnvim#editor#get_block']())
if lstart == 0 or lend == 0 then
if lstart == lend or lstart == 0 or lend == 0 then
M.send_line(cb, flash)
return
end
Expand Down
12 changes: 12 additions & 0 deletions test/spec/automated/editor_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local editor = require 'scnvim.editor'

-- NOTE: only append to this data in order to not break existing tests
local content = [[
x = 123;
(
Expand All @@ -17,6 +18,7 @@ x * 2;
var y = 3;
y * 2;
)foo
(degree: 0).play;
]]

local buf = vim.api.nvim_create_buf(false, true)
Expand Down Expand Up @@ -106,6 +108,16 @@ y * 2;
return data
end)
end)

it('can send a single line containing parenthesis', function()
vim.api.nvim_win_set_cursor(0, { 17, 0 })
editor.send_block(function(data)
local block = table.concat(data, '\n')
local expected = [[(degree: 0).play;]]
assert.are.equal(expected, block)
return data
end)
end)
end)

describe('autocmds', function()
Expand Down

0 comments on commit cb6a968

Please sign in to comment.