-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into auto-indentation
- Loading branch information
Showing
4 changed files
with
126 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
local paredit = require("nvim-paredit") | ||
local ts = require("nvim-treesitter.ts_utils") | ||
local prepare_buffer = require("tests.nvim-paredit.utils").prepare_buffer | ||
|
||
describe("cursor pos api tests", function() | ||
vim.api.nvim_buf_set_option(0, "filetype", "clojure") | ||
|
||
it("should place cursor inside form at the beginning", function() | ||
prepare_buffer({ | ||
content = { "(a (b))" }, | ||
cursor = { 1, 0 }, | ||
}) | ||
|
||
local cursor_pos = paredit.cursor.get_cursor_pos({ 0, 0, 0, 6 }, { placement = "inner_start" }) | ||
|
||
assert.are.same({ 1, 1 }, cursor_pos) | ||
|
||
local node = ts.get_node_at_cursor() | ||
cursor_pos = paredit.cursor.get_cursor_pos(node, { placement = "inner_start" }) | ||
|
||
assert.are.same({ 1, 1 }, cursor_pos) | ||
end) | ||
|
||
it("should place cursor outside form at the beginning", function() | ||
prepare_buffer({ | ||
content = { "(a (b))" }, | ||
cursor = { 1, 0 }, | ||
}) | ||
|
||
local cursor_pos = paredit.cursor.get_cursor_pos({ 0, 0, 0, 6 }, { placement = "left_edge" }) | ||
|
||
assert.are.same({ 1, 0 }, cursor_pos) | ||
|
||
local node = ts.get_node_at_cursor() | ||
cursor_pos = paredit.cursor.get_cursor_pos(node, { placement = "left_edge" }) | ||
|
||
assert.are.same({ 1, 0 }, cursor_pos) | ||
end) | ||
|
||
it("should place cursor inside form at the end", function() | ||
prepare_buffer({ | ||
content = { "(a ", " (b))" }, | ||
cursor = { 1, 0 }, | ||
}) | ||
|
||
local cursor_pos = paredit.cursor.get_cursor_pos({ 0, 0, 1, 4 }, { placement = "inner_end" }) | ||
|
||
assert.are.same({ 2, 4 }, cursor_pos) | ||
|
||
local node = ts.get_node_at_cursor() | ||
cursor_pos = paredit.cursor.get_cursor_pos(node, { placement = "inner_end" }) | ||
|
||
assert.are.same({ 2, 4 }, cursor_pos) | ||
end) | ||
|
||
it("should place cursor outside form at the end", function() | ||
prepare_buffer({ | ||
content = { "(a ", " (b))" }, | ||
cursor = { 1, 0 }, | ||
}) | ||
|
||
local cursor_pos = paredit.cursor.get_cursor_pos({ 0, 0, 1, 4 }, { placement = "right_edge" }) | ||
|
||
assert.are.same({ 2, 5 }, cursor_pos) | ||
|
||
local node = ts.get_node_at_cursor() | ||
cursor_pos = paredit.cursor.get_cursor_pos(node, { placement = "right_edge" }) | ||
|
||
assert.are.same({ 2, 5 }, cursor_pos) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters