# HG changeset patch # User Bram Moolenaar # Date 1630681205 -7200 # Node ID 2dd3007f902dadb8cd4951da8d765bb58cbb3384 # Parent 719f8313894139cfc568ff692a0bfea967f31f3f patch 8.2.3398: html text objects are not fully tested Commit: https://github.com/vim/vim/commit/af631f61bc42d0dddafe1bc0c06872cf3aaeb239 Author: Dominique Pelle Date: Fri Sep 3 16:50:16 2021 +0200 patch 8.2.3398: html text objects are not fully tested Problem: Html text objects are not fully tested. Solution: Add tests for dbcs encoding and different number of backslashes. (Dominique Pell?, closes #8831) diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim --- a/src/testdir/test_textobjects.vim +++ b/src/testdir/test_textobjects.vim @@ -88,101 +88,107 @@ endfunc " Tests for string and html text objects func Test_string_html_objects() - enew! + + for e in ['utf-8', 'latin1', 'cp932'] + enew! + exe 'set enc=' .. e - let t = '"wo\"rd\\" foo' - put =t - normal! da" - call assert_equal('foo', getline('.')) + let t = '"wo\"rd\\" foo' + put =t + normal! da" + call assert_equal('foo', getline('.'), e) - let t = "'foo' 'bar' 'piep'" - put =t - normal! 0va'a'rx - call assert_equal("xxxxxxxxxxxx'piep'", getline('.')) + let t = "'foo' 'bar' 'piep'" + put =t + normal! 0va'a'rx + call assert_equal("xxxxxxxxxxxx'piep'", getline('.'), e) - let t = "bla bla `quote` blah" - put =t - normal! 02f`da` - call assert_equal("bla bla blah", getline('.')) + let t = "bla bla `quote` blah" + put =t + normal! 02f`da` + call assert_equal("bla bla blah", getline('.'), e) - let t = 'out " in "noXno"' - put =t - normal! 0fXdi" - call assert_equal('out " in ""', getline('.')) + let t = 'out " in "noXno"' + put =t + normal! 0fXdi" + call assert_equal('out " in ""', getline('.'), e) - let t = "\"'\" 'blah' rep 'buh'" - put =t - normal! 03f'vi'ry - call assert_equal("\"'\" 'blah'yyyyy'buh'", getline('.')) + let t = "\"'\" 'blah' rep 'buh'" + put =t + normal! 03f'vi'ry + call assert_equal("\"'\" 'blah'yyyyy'buh'", getline('.'), e) - set quoteescape=+*- - let t = "bla `s*`d-`+++`l**` b`la" - put =t - normal! di` - call assert_equal("bla `` b`la", getline('.')) + set quoteescape=+*- + let t = "bla `s*`d-`+++`l**` b`la" + put =t + normal! di` + call assert_equal("bla `` b`la", getline('.'), e) - let t = 'voo "nah" sdf " asdf" sdf " sdf" sd' - put =t - normal! $F"va"oha"i"rz - call assert_equal('voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd', getline('.')) + let t = 'voo "nah" sdf " asdf" sdf " sdf" sd' + put =t + normal! $F"va"oha"i"rz + call assert_equal('voo "zzzzzzzzzzzzzzzzzzzzzzzzzzzzsd', getline('.'), e) - let t = "-asdfXasdfasdf-" - put =t - normal! fXdit - call assert_equal('-asdfasdf-', getline('.')) + let t = "-asdfXasdfasdf-" + put =t + normal! fXdit + call assert_equal('-asdfasdf-', getline('.'), e) - let t = "-asdXasdfasdf-" - put =t - normal! 0fXdit - call assert_equal('--', getline('.')) + let t = "-asdXasdfasdf-" + put =t + normal! 0fXdit + call assert_equal('--', getline('.'), e) - let t = "-asdfXasdfasdf-" - put =t - normal! fXdat - call assert_equal('-asdfasdf-', getline('.')) + let t = "-asdfXasdfasdf-" + put =t + normal! fXdat + call assert_equal('-asdfasdf-', getline('.'), e) - let t = "-asdXasdfasdf-" - put =t - normal! 0fXdat - call assert_equal('--', getline('.')) + let t = "-asdXasdfasdf-" + put =t + normal! 0fXdat + call assert_equal('--', getline('.'), e) - let t = "-\ninnertext object\n" - put =t - normal! dit - call assert_equal('-', getline('.')) + let t = "-\ninnertext object\n" + put =t + normal! dit + call assert_equal('-', getline('.'), e) - " copy the tag block from leading indentation before the start tag - let t = " \ntext\n" - $put =t - normal! 2kvaty - call assert_equal("\ntext\n", @") + " copy the tag block from leading indentation before the start tag + let t = " \ntext\n" + $put =t + normal! 2kvaty + call assert_equal("\ntext\n", @", e) - " copy the tag block from the end tag - let t = "\nwelcome\n" - $put =t - normal! $vaty - call assert_equal("\nwelcome\n", @") + " copy the tag block from the end tag + let t = "\nwelcome\n" + $put =t + normal! $vaty + call assert_equal("\nwelcome\n", @", e) - " copy the outer tag block from a tag without an end tag - let t = "\nwelcome\n</html>" - $put =t - normal! k$vaty - call assert_equal("<html>\n<title>welcome\n</html>", @") + " copy the outer tag block from a tag without an end tag + let t = "<html>\n<title>welcome\n</html>" + $put =t + normal! k$vaty + call assert_equal("<html>\n<title>welcome\n</html>", @", e) - " nested tag that has < in a different line from > - let t = "<div><div\n></div></div>" - $put =t - normal! k0vaty - call assert_equal("<div><div\n></div></div>", @") + " nested tag that has < in a different line from > + let t = "<div><div\n></div></div>" + $put =t + normal! k0vaty + call assert_equal("<div><div\n></div></div>", @", e) - " nested tag with attribute that has < in a different line from > - let t = "<div><div\nattr=\"attr\"\n></div></div>" - $put =t - normal! 2k0vaty - call assert_equal("<div><div\nattr=\"attr\"\n></div></div>", @") + " nested tag with attribute that has < in a different line from > + let t = "<div><div\nattr=\"attr\"\n></div></div>" + $put =t + normal! 2k0vaty + call assert_equal("<div><div\nattr=\"attr\"\n></div></div>", @", e) - set quoteescape& - enew! + set quoteescape& + endfor + + set enc=utf-8 + bwipe! endfunc func Test_empty_html_tag() @@ -561,6 +567,20 @@ func Test_textobj_quote() normal 0ya' call assert_equal(" 'special'", @") + " quoted string with odd or even number of backslashes. + call setline(1, 'char *s = "foo\"bar"') + normal $hhyi" + call assert_equal('foo\"bar', @") + call setline(1, 'char *s = "foo\\"bar"') + normal $hhyi" + call assert_equal('bar', @") + call setline(1, 'char *s = "foo\\\"bar"') + normal $hhyi" + call assert_equal('foo\\\"bar', @") + call setline(1, 'char *s = "foo\\\\"bar"') + normal $hhyi" + call assert_equal('bar', @") + close! endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3398, +/**/ 3397, /**/ 3396,