Skip to content

Commit cb6a968

Browse files
Send a single line block containing parenthesis (#250)
1 parent d5aa882 commit cb6a968

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lua/scnvim/editor.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ end
308308
function M.send_block(cb, flash)
309309
flash = flash == nil and true or flash
310310
local lstart, lend = unpack(vim.fn['scnvim#editor#get_block']())
311-
if lstart == 0 or lend == 0 then
311+
if lstart == lend or lstart == 0 or lend == 0 then
312312
M.send_line(cb, flash)
313313
return
314314
end

test/spec/automated/editor_spec.lua

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local editor = require 'scnvim.editor'
22

3+
-- NOTE: only append to this data in order to not break existing tests
34
local content = [[
45
x = 123;
56
(
@@ -17,6 +18,7 @@ x * 2;
1718
var y = 3;
1819
y * 2;
1920
)foo
21+
(degree: 0).play;
2022
]]
2123

2224
local buf = vim.api.nvim_create_buf(false, true)
@@ -106,6 +108,16 @@ y * 2;
106108
return data
107109
end)
108110
end)
111+
112+
it('can send a single line containing parenthesis', function()
113+
vim.api.nvim_win_set_cursor(0, { 17, 0 })
114+
editor.send_block(function(data)
115+
local block = table.concat(data, '\n')
116+
local expected = [[(degree: 0).play;]]
117+
assert.are.equal(expected, block)
118+
return data
119+
end)
120+
end)
109121
end)
110122

111123
describe('autocmds', function()

0 commit comments

Comments
 (0)