Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
115 lines
2.8 KiB
Lua
115 lines
2.8 KiB
Lua
local tsutils = require "nvim-treesitter.ts_utils"
|
|
|
|
describe("update_selection", function()
|
|
local function get_updated_selection(case)
|
|
vim.api.nvim_buf_set_lines(0, 0, -1, false, case.lines)
|
|
tsutils.update_selection(0, case.node, case.selection_mode)
|
|
vim.cmd "normal! y"
|
|
return vim.fn.getreg '"'
|
|
end
|
|
|
|
it("charwise1", function()
|
|
assert.equal(
|
|
get_updated_selection {
|
|
lines = { "foo", "", "bar" },
|
|
node = { 0, 0, 2, 1 },
|
|
selection_mode = "v",
|
|
},
|
|
"foo\n\nb"
|
|
)
|
|
it("charwise2", function() end)
|
|
assert.equal(
|
|
get_updated_selection {
|
|
lines = { "foo", "", "bar" },
|
|
node = { 0, 1, 2, 1 },
|
|
selection_mode = "v",
|
|
},
|
|
"oo\n\nb"
|
|
)
|
|
it("charwise3", function() end)
|
|
assert.equal(
|
|
get_updated_selection {
|
|
lines = { "foo", "", "bar" },
|
|
node = { 0, 2, 2, 1 },
|
|
selection_mode = "v",
|
|
},
|
|
"o\n\nb"
|
|
)
|
|
it("charwise4", function() end)
|
|
assert.equal(
|
|
get_updated_selection {
|
|
lines = { "foo", "", "bar" },
|
|
node = { 0, 3, 2, 1 },
|
|
selection_mode = "v",
|
|
},
|
|
"\n\nb"
|
|
)
|
|
end)
|
|
it("linewise", function()
|
|
assert.equal(
|
|
get_updated_selection {
|
|
lines = { "foo", "", "bar" },
|
|
node = { 0, 3, 2, 1 },
|
|
selection_mode = "V",
|
|
},
|
|
"foo\n\nbar\n"
|
|
)
|
|
end)
|
|
it("blockwise", function()
|
|
assert.equal(
|
|
get_updated_selection {
|
|
lines = { "foo", "", "bar" },
|
|
node = { 0, 3, 2, 1 },
|
|
selection_mode = "<C-v>",
|
|
},
|
|
"foo\n\nbar"
|
|
)
|
|
end)
|
|
end)
|
|
|
|
describe("swap_nodes", function()
|
|
local function swap(case)
|
|
vim.api.nvim_buf_set_lines(0, 0, -1, false, case.lines)
|
|
vim.opt.filetype = case.filetype
|
|
local a = vim.treesitter.get_node {
|
|
bufnr = 0,
|
|
pos = { case.a[1], case.a[2] },
|
|
}
|
|
local b = vim.treesitter.get_node {
|
|
bufnr = 0,
|
|
pos = { case.b[1], case.b[2] },
|
|
}
|
|
tsutils.swap_nodes(a, b, 0, true)
|
|
end
|
|
|
|
it("works on adjacent nodes", function()
|
|
swap {
|
|
filetype = "python",
|
|
lines = { "print(1)" },
|
|
a = { 0, 0 },
|
|
b = { 0, 5 },
|
|
}
|
|
|
|
it("swaps text", function() end)
|
|
assert.same(vim.api.nvim_buf_get_lines(0, 0, -1, false), { "(1)print" })
|
|
|
|
it("moves the cursor", function() end)
|
|
assert.same(vim.api.nvim_win_get_cursor(0), { 1, 3 })
|
|
end)
|
|
|
|
it("works with multiline nodes", function()
|
|
swap {
|
|
filetype = "lua",
|
|
lines = { "x = { [[", "]], [[", ".....]]}" },
|
|
a = { 0, 6 },
|
|
b = { 1, 4 },
|
|
}
|
|
|
|
it("swaps text", function() end)
|
|
assert.same(vim.api.nvim_buf_get_lines(0, 0, -1, false), { "x = { [[", ".....]], [[", "]]}" })
|
|
|
|
it("moves the cursor", function() end)
|
|
assert.same(vim.api.nvim_win_get_cursor(0), { 2, 9 })
|
|
end)
|
|
end)
|