vim-patch:8.2.1850: "vat" does not select tags correctly over line break

Problem:    "vat" does not select tags correctly over line break.
Solution:   Adjust the search pattern. (Aufar Gilbran, closes vim/vim#7136)
a604ccc959

Use 'const char*' for spat,mpat,epat params of do_searchpair()
to reduce (char_u *) casts.

Cherry-pick Test_string_html_objects() changes from patch 8.2.0655.
This commit is contained in:
Jan Edmund Lazo
2020-10-15 19:04:25 -04:00
parent 3566244d0e
commit f319e4608e
3 changed files with 48 additions and 17 deletions

View File

@@ -3436,7 +3436,6 @@ current_tagblock(
pos_T start_pos;
pos_T end_pos;
pos_T old_start, old_end;
char_u *spat, *epat;
char_u *p;
char_u *cp;
int len;
@@ -3490,9 +3489,9 @@ again:
*/
for (long n = 0; n < count; n++) {
if (do_searchpair(
(char_u *)"<[^ \t>/!]\\+\\%(\\_s\\_[^>]\\{-}[^/]>\\|$\\|\\_s\\=>\\)",
(char_u *)"",
(char_u *)"</[^>]*>", BACKWARD, NULL, 0,
"<[^ \t>/!]\\+\\%(\\_s\\_[^>]\\{-}[^/]>\\|$\\|\\_s\\=>\\)",
"",
"</[^>]*>", BACKWARD, NULL, 0,
NULL, (linenr_T)0, 0L) <= 0) {
curwin->w_cursor = old_pos;
goto theend;
@@ -3514,12 +3513,15 @@ again:
curwin->w_cursor = old_pos;
goto theend;
}
spat = xmalloc(len + 31);
epat = xmalloc(len + 9);
sprintf((char *)spat, "<%.*s\\>\\%%(\\s\\_[^>]\\{-}[^/]>\\|>\\)\\c", len, p);
sprintf((char *)epat, "</%.*s>\\c", len, p);
const size_t spat_len = len + 39;
char *const spat = xmalloc(spat_len);
const size_t epat_len = len + 9;
char *const epat = xmalloc(epat_len);
snprintf(spat, spat_len,
"<%.*s\\>\\%%(\\_s\\_[^>]\\{-}\\_[^/]>\\|\\_s\\?>\\)\\c", len, p);
snprintf(epat, epat_len, "</%.*s>\\c", len, p);
const int r = do_searchpair(spat, (char_u *)"", epat, FORWARD, NULL,
const int r = do_searchpair(spat, "", epat, FORWARD, NULL,
0, NULL, (linenr_T)0, 0L);
xfree(spat);