diff options
-rw-r--r-- | src/nvim/textobject.c | 9 | ||||
-rw-r--r-- | test/old/testdir/test_textobjects.vim | 12 |
2 files changed, 19 insertions, 2 deletions
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; diff --git a/test/old/testdir/test_textobjects.vim b/test/old/testdir/test_textobjects.vim index a7840860c9..0f41f0a241 100644 --- a/test/old/testdir/test_textobjects.vim +++ b/test/old/testdir/test_textobjects.vim @@ -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 |