--- ../vim-5.8/src/search.c Tue Jun 20 10:55:33 2000 +++ src/search.c Mon Nov 10 11:25:16 2003 @@ -1202,10 +1202,13 @@ int inquote = FALSE; /* TRUE when inside quotes */ char_u *linep; /* pointer to current line */ char_u *ptr; + char_u *html_tag_text_pos = NULL; int do_quotes; /* check for quotes in current line */ int at_start; /* do_quotes value at start position */ int hash_dir = 0; /* Direction searched for # things */ int comment_dir = 0; /* Direction searched for comments */ + int html_tag_dir = 0; /* Direction searched for HTML tags */ + int html_tag_text_len = 0; FPOS match_pos; /* Where last slash-star was found */ int start_in_quotes; /* start position is in quotes */ int traveled = 0; /* how far we've searched so far */ @@ -1373,9 +1376,150 @@ if (!cpo_match && *skipwhite(linep) == '#') hash_dir = 1; else + { + /* check if cursor inside HTML tag */ + + ptr = &linep[curwin->w_cursor.col]; + + /* find '<' to the left */ + + while (*ptr != '<' && ptr >= linep) + --ptr; + + if (ptr < linep) return NULL; + + ptr = skipwhite(ptr + 1); + + if (*ptr == '/') + { + ptr = skipwhite(ptr + 1); + html_tag_dir = -1; } + else + html_tag_dir = 1; + + /* save html tag text */ + + html_tag_text_len = 0; + html_tag_text_pos = ptr; + + while (isalnum(*ptr)) + { + ++ptr; + ++html_tag_text_len; + } + + if (html_tag_text_len == 0) + return NULL; + + /* find '>' to the right */ + + if (!vim_strchr(ptr, '>')) + return NULL; } + } + } + } + if (html_tag_dir) + { + char_u *prev_ptr; + + ptr = html_tag_text_pos; + + if (html_tag_dir < 0) + { + while (*ptr != '<') + --ptr; + + --ptr; + } + + while (!got_int) + { + for (;;) + { + while (ptr >= linep && *ptr != NUL && *ptr != '<') + ptr += html_tag_dir; + + if (*ptr == NUL || ptr < linep) + break; + + prev_ptr = ptr; + + ptr = skipwhite(ptr + 1); + + if (*ptr != '/') + { + /* opening tag */ + + if (!STRNICMP(ptr, html_tag_text_pos, + html_tag_text_len)) + { + if (html_tag_dir > 0) + ++count; + else + { + if (count == 0) + { + pos.col = ptr - linep; + return &pos; + } + --count; + } + } + } + else + { + /* closing tag */ + + ptr = skipwhite(ptr + 1); + + if (!STRNICMP(ptr, html_tag_text_pos, + html_tag_text_len)) + { + if (html_tag_dir > 0) + { + if (count == 0) + { + pos.col = ptr - linep; + return &pos; + } + --count; + } + else + ++count; + } + } + + if (html_tag_dir < 0) + { + if (prev_ptr == linep) + break; + + ptr = prev_ptr - 1; + } + } + + if (html_tag_dir > 0) + { + if (pos.lnum == curbuf->b_ml.ml_line_count) + break; + } + else if (pos.lnum == 1) + break; + + pos.lnum += html_tag_dir; + linep = ml_get(pos.lnum); + + if (html_tag_dir > 0) + ptr = linep; + else + ptr = linep + STRLEN(linep) - 1; + + line_breakcheck(); /* check for CTRL-C typed */ + } + return NULL; } if (hash_dir) {