diff options
author | Bram Moolenaar <Bram@vim.org> | 2004-12-27 21:59:20 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2004-12-27 21:59:20 +0000 |
commit | 86b68359978c933419279e599d0a8cf536095d77 (patch) | |
tree | 4291920506f596f1c934c9cf3af5641bdc63b900 /src/misc1.c | |
parent | b5bf5b8fae9ff5e2f7704686efae2814be1e18f7 (diff) | |
download | vim-git-86b68359978c933419279e599d0a8cf536095d77.tar.gz |
updated for version 7.0025v7.0025
Diffstat (limited to 'src/misc1.c')
-rw-r--r-- | src/misc1.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/misc1.c b/src/misc1.c index 891fbb5cc..0bdcce8b1 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -382,30 +382,36 @@ copy_indent(size, src) /* * Return the indent of the current line after a number. Return -1 if no * number was found. Used for 'n' in 'formatoptions': numbered list. + * Since a pattern is used it can actually handle more than numbers. */ int get_number_indent(lnum) linenr_T lnum; { - char_u *line; - char_u *p; colnr_T col; pos_T pos; + regmmatch_T regmatch; if (lnum > curbuf->b_ml.ml_line_count) return -1; - line = ml_get(lnum); - p = skipwhite(line); - if (!VIM_ISDIGIT(*p)) - return -1; - p = skipdigits(p); - if (vim_strchr((char_u *)":.)]}\t ", *p) == NULL) - return -1; - p = skipwhite(p + 1); - if (*p == NUL) + pos.lnum = 0; + regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC); + if (regmatch.regprog != NULL) + { + regmatch.rmm_ic = FALSE; + if (vim_regexec_multi(®match, curwin, curbuf, lnum, (colnr_T)0)) + { + pos.lnum = regmatch.endpos[0].lnum + lnum; + pos.col = regmatch.endpos[0].col; +#ifdef FEAT_VIRTUALEDIT + pos.coladd = 0; +#endif + } + vim_free(regmatch.regprog); + } + + if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL) return -1; - pos.lnum = lnum; - pos.col = (colnr_T)(p - line); getvcol(curwin, &pos, &col, NULL, NULL); return (int)col; } @@ -3804,9 +3810,9 @@ remove_tail_with_ext(p, pend, ext) char_u *newend = pend - len; if (newend >= p && fnamencmp(newend, ext, len - 1) == 0) - while (newend != p && !after_pathsep(newend)) - mb_ptr_back(newend); - if (newend == p || after_pathsep(newend)) + while (newend > p && !after_pathsep(p, newend)) + mb_ptr_back(p, newend); + if (newend == p || after_pathsep(p, newend)) return newend; return pend; } @@ -8447,7 +8453,6 @@ addfile(gap, f, flags) add_pathsep(p); #endif ((char_u **)gap->ga_data)[gap->ga_len++] = p; - --gap->ga_room; } #endif /* !NO_EXPANDPATH */ |