fix: quote textobject selects wrong pair when cursor is on closing quote
This commit is contained in:
parent
76cc8260bb
commit
afeca37f10
1 changed files with 9 additions and 3 deletions
|
|
@ -4071,9 +4071,15 @@ pub const Editor = struct {
|
|||
quote: []const u8,
|
||||
) error{Stop}!struct { struct { usize, usize }, struct { usize, usize } } {
|
||||
|
||||
// Find nearest quote (prefer rightward)
|
||||
const anchor =
|
||||
find_unescaped_quote(root, original_cursor, metrics, .right, quote) catch find_unescaped_quote(root, original_cursor, metrics, .left, quote) catch return error.Stop;
|
||||
// If the cursor is already on a quote, use it directly as the anchor.
|
||||
// Otherwise find the nearest quote, preferring rightward.
|
||||
const cursor_egc, _, _ = root.egc_at(original_cursor.row, original_cursor.col, metrics) catch return error.Stop;
|
||||
const anchor = if (std.mem.eql(u8, cursor_egc, quote))
|
||||
original_cursor
|
||||
else
|
||||
find_unescaped_quote(root, original_cursor, metrics, .right, quote) catch
|
||||
find_unescaped_quote(root, original_cursor, metrics, .left, quote) catch
|
||||
return error.Stop;
|
||||
|
||||
const role = try quote_role_on_row(root, anchor, metrics, quote);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue