From 3317aa2f3756d21905b501a01d4f2b3203f60943 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 20 Jun 2024 09:57:00 +0800 Subject: vim-patch:9.1.0504: inner-tag textobject confused about ">" in attributes (#29420) Problem: inner-tag textobject confused about ">" in attributes Solution: Skip over quoted '>' when determining the start position fixes: vim/vim#15043 closes: vim/vim#15049 https://github.com/vim/vim/commit/ca7f93e6f351b310c17cfc8f88acf21c839d6116 Co-authored-by: Christian Brabandt --- src/nvim/textobject.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index 3c81a840ea..ffc5bc2cb2 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -1193,13 +1193,18 @@ again: pos_T end_pos = curwin->w_cursor; if (!do_include) { - // Exclude the start tag. + // Exclude the start tag, + // but skip over '>' if it appears in quotes + bool in_quotes = false; curwin->w_cursor = start_pos; while (inc_cursor() >= 0) { - if (*get_cursor_pos_ptr() == '>') { + p = get_cursor_pos_ptr(); + if (*p == '>' && !in_quotes) { inc_cursor(); start_pos = curwin->w_cursor; break; + } else if (*p == '"' || *p == '\'') { + in_quotes = !in_quotes; } } curwin->w_cursor = end_pos; -- cgit