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

ca7f93e6f3

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq 2024-06-20 09:57:00 +08:00 committed by GitHub
parent 38a1d41ac0
commit 3317aa2f37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View File

@ -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;

View File

@ -203,6 +203,18 @@ func Test_string_html_objects()
normal! 2k0vaty
call assert_equal("<div><div\nattr=\"attr\"\n></div></div>", @", e)
" tag, that includes a > in some attribute
let t = "<div attr=\"attr >> foo >> bar \">Hello</div>"
$put =t
normal! fHyit
call assert_equal("Hello", @", e)
" tag, that includes a > in some attribute
let t = "<div attr='attr >> foo >> bar '>Hello 123</div>"
$put =t
normal! fHyit
call assert_equal("Hello 123", @", e)
set quoteescape&
" this was going beyond the end of the line