Merge pull request #17460 from seandewar/vim-8.2.4419

vim-patch:8.2.{4403,4418,4419,4422}
This commit is contained in:
Sean Dewar 2022-02-19 22:59:15 +00:00 committed by GitHub
commit 8b3799e2c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 10 deletions

View File

@ -3438,8 +3438,12 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
if (stl_items == NULL) { if (stl_items == NULL) {
stl_items = xmalloc(sizeof(stl_item_t) * stl_items_len); stl_items = xmalloc(sizeof(stl_item_t) * stl_items_len);
stl_groupitems = xmalloc(sizeof(int) * stl_items_len); stl_groupitems = xmalloc(sizeof(int) * stl_items_len);
stl_hltab = xmalloc(sizeof(stl_hlrec_t) * stl_items_len);
stl_tabtab = xmalloc(sizeof(StlClickRecord) * stl_items_len); // Allocate one more, because the last element is used to indicate the
// end of the list.
stl_hltab = xmalloc(sizeof(stl_hlrec_t) * (stl_items_len + 1));
stl_tabtab = xmalloc(sizeof(StlClickRecord) * (stl_items_len + 1));
stl_separator_locations = xmalloc(sizeof(int) * stl_items_len); stl_separator_locations = xmalloc(sizeof(int) * stl_items_len);
} }
@ -3514,8 +3518,8 @@ int build_stl_str_hl(win_T *wp, char_u *out, size_t outlen, char_u *fmt, int use
stl_items = xrealloc(stl_items, sizeof(stl_item_t) * new_len); stl_items = xrealloc(stl_items, sizeof(stl_item_t) * new_len);
stl_groupitems = xrealloc(stl_groupitems, sizeof(int) * new_len); stl_groupitems = xrealloc(stl_groupitems, sizeof(int) * new_len);
stl_hltab = xrealloc(stl_hltab, sizeof(stl_hlrec_t) * new_len); stl_hltab = xrealloc(stl_hltab, sizeof(stl_hlrec_t) * (new_len + 1));
stl_tabtab = xrealloc(stl_tabtab, sizeof(StlClickRecord) * new_len); stl_tabtab = xrealloc(stl_tabtab, sizeof(StlClickRecord) * (new_len + 1));
stl_separator_locations = stl_separator_locations =
xrealloc(stl_separator_locations, sizeof(int) * new_len); xrealloc(stl_separator_locations, sizeof(int) * new_len);

View File

@ -223,19 +223,20 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra
// values for the cursor. // values for the cursor.
// Update the folds for this window. Can't postpone this, because // Update the folds for this window. Can't postpone this, because
// a following operator might work on the whole fold: ">>dd". // a following operator might work on the whole fold: ">>dd".
foldUpdate(wp, lnum, lnume + xtra - 1); linenr_T last = lnume + xtra - 1; // last line after the change
foldUpdate(wp, lnum, last);
// The change may cause lines above or below the change to become // The change may cause lines above or below the change to become
// included in a fold. Set lnum/lnume to the first/last line that // included in a fold. Set lnum/lnume to the first/last line that
// might be displayed differently. // might be displayed differently.
// Set w_cline_folded here as an efficient way to update it when // Set w_cline_folded here as an efficient way to update it when
// inserting lines just above a closed fold. */ // inserting lines just above a closed fold.
bool folded = hasFoldingWin(wp, lnum, &lnum, NULL, false, NULL); bool folded = hasFoldingWin(wp, lnum, &lnum, NULL, false, NULL);
if (wp->w_cursor.lnum == lnum) { if (wp->w_cursor.lnum == lnum) {
wp->w_cline_folded = folded; wp->w_cline_folded = folded;
} }
folded = hasFoldingWin(wp, lnume, NULL, &lnume, false, NULL); folded = hasFoldingWin(wp, last, NULL, &last, false, NULL);
if (wp->w_cursor.lnum == lnume) { if (wp->w_cursor.lnum == last) {
wp->w_cline_folded = folded; wp->w_cline_folded = folded;
} }

View File

@ -1317,6 +1317,12 @@ bool mb_isupper(int a)
return mb_tolower(a) != a; return mb_tolower(a) != a;
} }
bool mb_isalpha(int a)
FUNC_ATTR_WARN_UNUSED_RESULT
{
return mb_islower(a) || mb_isupper(a);
}
static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, size_t n2) static int utf_strnicmp(const char_u *s1, const char_u *s2, size_t n1, size_t n2)
{ {
int c1, c2, cdiff; int c1, c2, cdiff;

View File

@ -642,8 +642,7 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, size_t wildoff,
} else if (path_end >= path + wildoff } else if (path_end >= path + wildoff
&& (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL && (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL
#ifndef WIN32 #ifndef WIN32
|| (!p_fic && (flags & EW_ICASE) || (!p_fic && (flags & EW_ICASE) && mb_isalpha(utf_ptr2char(path_end)))
&& isalpha(utf_ptr2char(path_end)))
#endif #endif
)) { )) {
e = p; e = p;

View File

@ -64,4 +64,14 @@ func Test_verbose_pwd()
call delete('Xautodir', 'rf') call delete('Xautodir', 'rf')
endfunc endfunc
func Test_multibyte()
" using an invalid character should not cause a crash
set wic
" Except on Windows, E472 is also thrown last, but v8.1.1183 isn't ported yet
" call assert_fails('tc û<><C3BB><EFBFBD>¦*', has('win32') ? 'E480:' : 'E344:')
call assert_fails('tc û<><C3BB><EFBFBD>¦*', has('win32') ? 'E480:' : 'E472:')
set nowic
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@ -86,6 +86,17 @@ func Test_tabline_empty_group()
set tabline= set tabline=
endfunc endfunc
" When there are exactly 20 tabline format items (the exact size of the
" initial tabline items array), test that we don't write beyond the size
" of the array.
func Test_tabline_20_format_items_no_overrun()
set showtabline=2
let tabline = repeat('%#StatColorHi2#', 20)
let &tabline = tabline
redrawtabline
set showtabline& tabline&
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab