mirror of
https://github.com/neovim/neovim.git
synced 2026-01-06 13:27:43 +00:00
Merge pull request #14592 from janlazo/vim-8.2.2869
vim-patch:8.2.{2869,2871}
This commit is contained in:
@@ -1619,7 +1619,7 @@ void list_hashtable_vars(hashtab_T *ht, const char *prefix, int empty,
|
||||
char buf[IOSIZE];
|
||||
|
||||
// apply :filter /pat/ to variable name
|
||||
xstrlcpy(buf, prefix, IOSIZE - 1);
|
||||
xstrlcpy(buf, prefix, IOSIZE);
|
||||
xstrlcat(buf, (char *)di->di_key, IOSIZE);
|
||||
if (message_filtered((char_u *)buf)) {
|
||||
continue;
|
||||
|
||||
@@ -1772,7 +1772,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
|
||||
// count, it's a buffer name.
|
||||
///
|
||||
if ((ea.argt & EX_COUNT) && ascii_isdigit(*ea.arg)
|
||||
&& (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg)) == NUL
|
||||
&& (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg + 1)) == NUL
|
||||
|| ascii_iswhite(*p))) {
|
||||
n = getdigits_long(&ea.arg, false, -1);
|
||||
ea.arg = skipwhite(ea.arg);
|
||||
@@ -2790,15 +2790,18 @@ static struct cmdmod {
|
||||
*/
|
||||
int modifier_len(char_u *cmd)
|
||||
{
|
||||
int i, j;
|
||||
char_u *p = cmd;
|
||||
|
||||
if (ascii_isdigit(*cmd))
|
||||
p = skipwhite(skipdigits(cmd));
|
||||
for (i = 0; i < (int)ARRAY_SIZE(cmdmods); ++i) {
|
||||
for (j = 0; p[j] != NUL; ++j)
|
||||
if (p[j] != cmdmods[i].name[j])
|
||||
if (ascii_isdigit(*cmd)) {
|
||||
p = skipwhite(skipdigits(cmd + 1));
|
||||
}
|
||||
for (int i = 0; i < (int)ARRAY_SIZE(cmdmods); i++) {
|
||||
int j;
|
||||
for (j = 0; p[j] != NUL; j++) {
|
||||
if (p[j] != cmdmods[i].name[j]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j >= cmdmods[i].minlen
|
||||
&& !ASCII_ISALPHA(p[j])
|
||||
&& (p == cmd || cmdmods[i].has_count)) {
|
||||
|
||||
@@ -1069,7 +1069,7 @@ char_u *get_menu_names(expand_T *xp, int idx)
|
||||
#define TBUFFER_LEN 256
|
||||
static char_u tbuffer[TBUFFER_LEN]; /*hack*/
|
||||
char_u *str;
|
||||
static int should_advance = FALSE;
|
||||
static bool should_advance = false;
|
||||
|
||||
if (idx == 0) { /* first call: start at first item */
|
||||
menu = expand_menu;
|
||||
@@ -1089,12 +1089,13 @@ char_u *get_menu_names(expand_T *xp, int idx)
|
||||
|
||||
if (menu->modes & expand_modes) {
|
||||
if (menu->children != NULL) {
|
||||
if (should_advance)
|
||||
STRLCPY(tbuffer, menu->en_dname, TBUFFER_LEN - 1);
|
||||
else {
|
||||
STRLCPY(tbuffer, menu->dname, TBUFFER_LEN - 1);
|
||||
if (menu->en_dname == NULL)
|
||||
should_advance = TRUE;
|
||||
if (should_advance) {
|
||||
STRLCPY(tbuffer, menu->en_dname, TBUFFER_LEN);
|
||||
} else {
|
||||
STRLCPY(tbuffer, menu->dname, TBUFFER_LEN);
|
||||
if (menu->en_dname == NULL) {
|
||||
should_advance = true;
|
||||
}
|
||||
}
|
||||
/* hack on menu separators: use a 'magic' char for the separator
|
||||
* so that '.' in names gets escaped properly */
|
||||
@@ -1105,8 +1106,9 @@ char_u *get_menu_names(expand_T *xp, int idx)
|
||||
str = menu->en_dname;
|
||||
else {
|
||||
str = menu->dname;
|
||||
if (menu->en_dname == NULL)
|
||||
should_advance = TRUE;
|
||||
if (menu->en_dname == NULL) {
|
||||
should_advance = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
||||
@@ -1942,10 +1942,12 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
||||
case OP_FORMAT:
|
||||
if (*curbuf->b_p_fex != NUL) {
|
||||
op_formatexpr(oap); // use expression
|
||||
} else if (*p_fp != NUL || *curbuf->b_p_fp != NUL) {
|
||||
op_colon(oap); // use external command
|
||||
} else {
|
||||
op_format(oap, false); // use internal function
|
||||
if (*p_fp != NUL || *curbuf->b_p_fp != NUL) {
|
||||
op_colon(oap); // use external command
|
||||
} else {
|
||||
op_format(oap, false); // use internal function
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ FileComparison path_full_compare(char_u *const s1, char_u *const s2,
|
||||
if (expandenv) {
|
||||
expand_env(s1, exp1, MAXPATHL);
|
||||
} else {
|
||||
xstrlcpy((char *)exp1, (const char *)s1, MAXPATHL - 1);
|
||||
xstrlcpy((char *)exp1, (const char *)s1, MAXPATHL);
|
||||
}
|
||||
bool id_ok_1 = os_fileid((char *)exp1, &file_id_1);
|
||||
bool id_ok_2 = os_fileid((char *)s2, &file_id_2);
|
||||
|
||||
@@ -3919,13 +3919,13 @@ static int qf_buf_add_line(buf_T *buf, linenr_T lnum, const qfline_T *qfp,
|
||||
buf_T *errbuf;
|
||||
|
||||
if (qfp->qf_module != NULL) {
|
||||
STRLCPY(IObuff, qfp->qf_module, IOSIZE - 1);
|
||||
STRLCPY(IObuff, qfp->qf_module, IOSIZE);
|
||||
len = (int)STRLEN(IObuff);
|
||||
} else if (qfp->qf_fnum != 0
|
||||
&& (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL
|
||||
&& errbuf->b_fname != NULL) {
|
||||
if (qfp->qf_type == 1) { // :helpgrep
|
||||
STRLCPY(IObuff, path_tail(errbuf->b_fname), IOSIZE - 1);
|
||||
STRLCPY(IObuff, path_tail(errbuf->b_fname), IOSIZE);
|
||||
} else {
|
||||
// Shorten the file name if not done already.
|
||||
// For optimization, do this only for the first entry in a
|
||||
@@ -3938,7 +3938,7 @@ static int qf_buf_add_line(buf_T *buf, linenr_T lnum, const qfline_T *qfp,
|
||||
}
|
||||
shorten_buf_fname(errbuf, dirname, false);
|
||||
}
|
||||
STRLCPY(IObuff, errbuf->b_fname, IOSIZE - 1);
|
||||
STRLCPY(IObuff, errbuf->b_fname, IOSIZE);
|
||||
}
|
||||
len = (int)STRLEN(IObuff);
|
||||
} else {
|
||||
|
||||
@@ -3010,7 +3010,7 @@ static int find_extra(char_u **pp)
|
||||
// Repeat for addresses separated with ';'
|
||||
for (;; ) {
|
||||
if (ascii_isdigit(*str)) {
|
||||
str = skipdigits(str);
|
||||
str = skipdigits(str + 1);
|
||||
} else if (*str == '/' || *str == '?') {
|
||||
str = skip_regexp(str + 1, *str, false, NULL);
|
||||
if (*str != first_char) {
|
||||
|
||||
@@ -781,17 +781,66 @@ func Test_diff_lastline()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func WriteDiffFiles(buf, list1, list2)
|
||||
call writefile(a:list1, 'Xfile1')
|
||||
call writefile(a:list2, 'Xfile2')
|
||||
if a:buf
|
||||
call term_sendkeys(a:buf, ":checktime\<CR>")
|
||||
endif
|
||||
endfunc
|
||||
" Verify a screendump with both the internal and external diff.
|
||||
func VerifyBoth(buf, dumpfile, extra)
|
||||
" trailing : for leaving the cursor on the command line
|
||||
for cmd in [":set diffopt=filler" . a:extra . "\<CR>:", ":set diffopt+=internal\<CR>:"]
|
||||
call term_sendkeys(a:buf, cmd)
|
||||
if VerifyScreenDump(a:buf, a:dumpfile, {}, cmd =~ 'internal' ? 'internal' : 'external')
|
||||
break " don't let the next iteration overwrite the "failed" file.
|
||||
" don't let the next iteration overwrite the "failed" file.
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
|
||||
" also test unified diff
|
||||
call term_sendkeys(a:buf, ":call SetupUnified()\<CR>:")
|
||||
call VerifyScreenDump(a:buf, a:dumpfile, {}, 'unified')
|
||||
call term_sendkeys(a:buf, ":call StopUnified()\<CR>:")
|
||||
endfunc
|
||||
|
||||
" Verify a screendump with the internal diff only.
|
||||
func VerifyInternal(buf, dumpfile, extra)
|
||||
call term_sendkeys(a:buf, ":diffupdate!\<CR>")
|
||||
" trailing : for leaving the cursor on the command line
|
||||
call term_sendkeys(a:buf, ":set diffopt=internal,filler" . a:extra . "\<CR>:")
|
||||
call TermWait(a:buf)
|
||||
call VerifyScreenDump(a:buf, a:dumpfile, {})
|
||||
endfunc
|
||||
|
||||
func Test_diff_screen()
|
||||
CheckScreendump
|
||||
CheckFeature menu
|
||||
|
||||
let lines =<< trim END
|
||||
func UnifiedDiffExpr()
|
||||
" Prepend some text to check diff type detection
|
||||
call writefile(['warning', ' message'], v:fname_out)
|
||||
silent exe '!diff -u ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out
|
||||
endfunc
|
||||
func SetupUnified()
|
||||
set diffexpr=UnifiedDiffExpr()
|
||||
endfunc
|
||||
func StopUnified()
|
||||
set diffexpr=
|
||||
endfunc
|
||||
END
|
||||
call writefile(lines, 'XdiffSetup')
|
||||
|
||||
" clean up already existing swap files, just in case
|
||||
call delete('.Xfile1.swp')
|
||||
call delete('.Xfile2.swp')
|
||||
|
||||
" Test 1: Add a line in beginning of file 2
|
||||
call WriteDiffFiles(0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
let buf = RunVimInTerminal('-d Xfile1 Xfile2', {})
|
||||
let buf = RunVimInTerminal('-d -S XdiffSetup Xfile1 Xfile2', {})
|
||||
" Set autoread mode, so that Vim won't complain once we re-write the test
|
||||
" files
|
||||
call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
|
||||
@@ -911,6 +960,7 @@ func Test_diff_screen()
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('Xfile1')
|
||||
call delete('Xfile2')
|
||||
call delete('XdiffSetup')
|
||||
endfunc
|
||||
|
||||
func Test_diff_with_cursorline()
|
||||
|
||||
Reference in New Issue
Block a user