Merge pull request #13293 from janlazo/vim-8.2.1976

vim-patch:8.2.{1979,1981,1982,1985,1987}
This commit is contained in:
Matthieu Coudron
2020-11-15 18:18:12 +01:00
committed by GitHub
9 changed files with 36 additions and 38 deletions

View File

@@ -530,12 +530,8 @@ void ins_bytes_len(char_u *p, size_t len)
{
size_t n;
for (size_t i = 0; i < len; i += n) {
if (enc_utf8) {
// avoid reading past p[len]
n = (size_t)utfc_ptr2len_len(p + i, (int)(len - i));
} else {
n = (size_t)(*mb_ptr2len)(p + i);
}
// avoid reading past p[len]
n = (size_t)utfc_ptr2len_len(p + i, (int)(len - i));
ins_char_bytes(p + i, n);
}
}
@@ -761,7 +757,7 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
// If 'delcombine' is set and deleting (less than) one character, only
// delete the last combining character.
if (p_deco && use_delcombine && enc_utf8
if (p_deco && use_delcombine
&& utfc_ptr2len(oldp + col) >= count) {
int cc[MAX_MCO];
int n;

View File

@@ -1310,14 +1310,11 @@ retry:
char_u *dest;
char_u *tail = NULL;
/*
* "enc_utf8" set: Convert Unicode or Latin1 to UTF-8.
* "enc_utf8" not set: Convert Unicode to Latin1.
* Go from end to start through the buffer, because the number
* of bytes may increase.
* "dest" points to after where the UTF-8 bytes go, "p" points
* to after the next character to convert.
*/
// Convert Unicode or Latin1 to UTF-8.
// Go from end to start through the buffer, because the number
// of bytes may increase.
// "dest" points to after where the UTF-8 bytes go, "p" points
// to after the next character to convert.
dest = ptr + real_size;
if (fio_flags == FIO_LATIN1 || fio_flags == FIO_UTF8) {
p = ptr + size;

View File

@@ -585,8 +585,8 @@ EXTERN int vr_lines_changed INIT(= 0); // #Lines changed by "gR" so far
EXTERN int inhibit_delete_count INIT(= 0);
// These flags are set based upon 'fileencoding'.
// Note that "enc_utf8" is also set for "unicode", because the characters are
// internally stored as UTF-8 (to avoid trouble with NUL bytes).
// The characters are internally stored as UTF-8
// to avoid trouble with NUL bytes.
# define DBCS_JPN 932 // japan
# define DBCS_JPNU 9932 // euc-jp
# define DBCS_KOR 949 // korea
@@ -598,12 +598,6 @@ EXTERN int inhibit_delete_count INIT(= 0);
# define DBCS_2BYTE 1 // 2byte-
# define DBCS_DEBUG -1
// mbyte flags that used to depend on 'encoding'. These are now deprecated, as
// 'encoding' is always "utf-8". Code that use them can be refactored to
// remove dead code.
#define enc_utf8 true
#define has_mbyte true
/// Encoding used when 'fencs' is set to "default"
EXTERN char_u *fenc_default INIT(= NULL);

View File

@@ -188,9 +188,6 @@ void early_init(mparm_T *paramp)
global_alist.id = 0;
// Set the default values for the options.
// NOTE: Non-latin1 translated messages are working only after this,
// because this is where "has_mbyte" will be set, which is used by
// msg_outtrans_len_attr().
// First find out the home directory, needed to expand "~" in options.
init_homedir(); // find real value of $HOME
set_init_1(paramp != NULL ? paramp->clean : false);

View File

@@ -3975,11 +3975,15 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last)
*dirname = NUL;
// Add one line for each error
if (old_last == NULL || old_last->qf_next == NULL) {
if (old_last == NULL) {
qfp = qfl->qf_start;
lnum = 0;
} else {
qfp = old_last->qf_next;
if (old_last->qf_next != NULL) {
qfp = old_last->qf_next;
} else {
qfp = old_last;
}
lnum = buf->b_ml.ml_line_count;
}
while (lnum < qfl->qf_count) {

View File

@@ -162,7 +162,7 @@ struct slang_S {
bool sl_collapse; // SAL collapse_result
bool sl_rem_accents; // SAL remove_accents
bool sl_sofo; // SOFOFROM and SOFOTO instead of SAL items:
// "sl_sal_first" maps chars, when has_mbyte
// "sl_sal_first" maps chars
// "sl_sal" is a list of wide char lists.
garray_T sl_repsal; // list of fromto_T entries from REPSAL lines
int16_t sl_repsal_first[256]; // sl_rep_first for REPSAL lines

View File

@@ -4410,4 +4410,17 @@ func Test_search_in_dirstack()
call delete('Xtestdir', 'rf')
endfunc
" Test for adding an invalid entry with the quickfix window open and making
" sure that the window contents are not changed
func Test_add_invalid_entry_with_qf_window()
call setqflist([], 'f')
cexpr "Xfile1:10:aa"
copen
call setqflist(['bb'], 'a')
call assert_equal(1, line('$'))
call assert_equal(['Xfile1|10| aa'], getline(1, '$'))
call assert_equal([{'lnum': 10, 'bufnr': bufnr('Xfile1'), 'col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'aa'}], getqflist())
cclose
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -2301,14 +2301,11 @@ static void do_intro_line(long row, char_u *mesg, int attr)
for (p = mesg; *p != NUL; p += l) {
clen = 0;
for (l = 0; p[l] != NUL
&& (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l) {
if (has_mbyte) {
clen += ptr2cells(p + l);
l += (*mb_ptr2len)(p + l) - 1;
} else {
clen += byte2cells(p[l]);
}
for (l = 0;
p[l] != NUL && (l == 0 || (p[l] != '<' && p[l - 1] != '>'));
l++) {
clen += ptr2cells(p + l);
l += utfc_ptr2len(p + l) - 1;
}
assert(row <= INT_MAX && col <= INT_MAX);
grid_puts_len(&default_grid, p, l, (int)row, (int)col,

View File

@@ -545,7 +545,7 @@ unsigned int trans_special(const char_u **srcp, const size_t src_len,
dst[dlen++] = K_SPECIAL;
dst[dlen++] = (char_u)KEY2TERMCAP0(key);
dst[dlen++] = KEY2TERMCAP1(key);
} else if (has_mbyte && !keycode) {
} else if (!keycode) {
dlen += (unsigned int)(*mb_char2bytes)(key, dst + dlen);
} else if (keycode) {
char_u *after = add_char2buf(key, dst + dlen);