mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-14 17:30:08 -04:00
Textobject goto: treat end differently that start
This commit is contained in:
parent
be2cfc1bca
commit
f3ed370643
1 changed files with 12 additions and 13 deletions
|
|
@ -87,17 +87,17 @@ local function swap_textobject(query_string, direction)
|
||||||
local overlapping_range_ok = false
|
local overlapping_range_ok = false
|
||||||
local same_parent = true
|
local same_parent = true
|
||||||
for _ = 1, math.abs(direction), step do
|
for _ = 1, math.abs(direction), step do
|
||||||
if direction > 0 then
|
if direction > 0 then
|
||||||
ts_utils.swap_nodes(textobject_range,
|
ts_utils.swap_nodes(textobject_range,
|
||||||
M.next_textobject(node, query_string, same_parent, overlapping_range_ok, bufnr),
|
M.next_textobject(node, query_string, same_parent, overlapping_range_ok, bufnr),
|
||||||
bufnr,
|
bufnr,
|
||||||
"yes, set cursor!")
|
"yes, set cursor!")
|
||||||
else
|
else
|
||||||
ts_utils.swap_nodes(textobject_range,
|
ts_utils.swap_nodes(textobject_range,
|
||||||
M.previous_textobject(node, query_string, same_parent, overlapping_range_ok, bufnr),
|
M.previous_textobject(node, query_string, same_parent, overlapping_range_ok, bufnr),
|
||||||
bufnr,
|
bufnr,
|
||||||
"yes, set cursor!")
|
"yes, set cursor!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -146,7 +146,6 @@ function M.next_textobject(node, query_string, same_parent, overlapping_range_ok
|
||||||
local search_start, _
|
local search_start, _
|
||||||
if overlapping_range_ok then
|
if overlapping_range_ok then
|
||||||
_, _, search_start = node:start()
|
_, _, search_start = node:start()
|
||||||
search_start = search_start - 1
|
|
||||||
else
|
else
|
||||||
_, _, search_start = node:end_()
|
_, _, search_start = node:end_()
|
||||||
end
|
end
|
||||||
|
|
@ -159,7 +158,7 @@ function M.next_textobject(node, query_string, same_parent, overlapping_range_ok
|
||||||
if not same_parent or node:parent() == match.node:parent() then
|
if not same_parent or node:parent() == match.node:parent() then
|
||||||
local _, _, start = match.node:start()
|
local _, _, start = match.node:start()
|
||||||
local _, _, end_ = match.node:end_()
|
local _, _, end_ = match.node:end_()
|
||||||
return start > search_start and end_ > node_end
|
return start > search_start and end_ >= node_end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
function(match)
|
function(match)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue