Merge pull request #13172 from janlazo/vim-8.2.1910

vim-patch:8.1.{2034,2050},8.2.{131,913,929,1521,1910,1913,1922}
This commit is contained in:
Jan Edmund Lazo 2020-10-30 08:56:38 -04:00 committed by GitHub
commit 9fee5f1423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 240 additions and 82 deletions

View File

@ -2918,6 +2918,8 @@ A jump table for the options with a short description can be found at |Q_op|.
*'go-c'* *'go-c'*
'c' Use console dialogs instead of popup dialogs for simple 'c' Use console dialogs instead of popup dialogs for simple
choices. choices.
*'go-d'*
'd' Use dark theme variant if available.
*'go-e'* *'go-e'*
'e' Add tab pages when indicated with 'showtabline'. 'e' Add tab pages when indicated with 'showtabline'.
'guitablabel' can be used to change the text in the labels. 'guitablabel' can be used to change the text in the labels.

View File

@ -1251,7 +1251,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
char_u *errormsg = NULL; // error message char_u *errormsg = NULL; // error message
char_u *after_modifier = NULL; char_u *after_modifier = NULL;
exarg_T ea; exarg_T ea;
int save_msg_scroll = msg_scroll; const int save_msg_scroll = msg_scroll;
cmdmod_T save_cmdmod; cmdmod_T save_cmdmod;
const int save_reg_executing = reg_executing; const int save_reg_executing = reg_executing;
char_u *cmd; char_u *cmd;
@ -2003,34 +2003,10 @@ doend:
? cmdnames[(int)ea.cmdidx].cmd_name ? cmdnames[(int)ea.cmdidx].cmd_name
: (char_u *)NULL); : (char_u *)NULL);
if (ea.verbose_save >= 0) { undo_cmdmod(&ea, save_msg_scroll);
p_verbose = ea.verbose_save;
}
free_cmdmod();
cmdmod = save_cmdmod; cmdmod = save_cmdmod;
reg_executing = save_reg_executing; reg_executing = save_reg_executing;
if (ea.save_msg_silent != -1) {
// messages could be enabled for a serious error, need to check if the
// counters don't become negative
if (!did_emsg || msg_silent > ea.save_msg_silent) {
msg_silent = ea.save_msg_silent;
}
emsg_silent -= ea.did_esilent;
if (emsg_silent < 0) {
emsg_silent = 0;
}
// Restore msg_scroll, it's set by file I/O commands, even when no
// message is actually displayed.
msg_scroll = save_msg_scroll;
/* "silent reg" or "silent echo x" inside "redir" leaves msg_col
* somewhere in the line. Put it back in the first column. */
if (redirecting())
msg_col = 0;
}
if (ea.did_sandbox) { if (ea.did_sandbox) {
sandbox--; sandbox--;
} }
@ -2298,9 +2274,14 @@ int parse_command_modifiers(exarg_T *eap, char_u **errormsg, bool skip_only)
return OK; return OK;
} }
// Free contents of "cmdmod". // Undo and free contents of "cmdmod".
static void free_cmdmod(void) static void undo_cmdmod(const exarg_T *eap, int save_msg_scroll)
FUNC_ATTR_NONNULL_ALL
{ {
if (eap->verbose_save >= 0) {
p_verbose = eap->verbose_save;
}
if (cmdmod.save_ei != NULL) { if (cmdmod.save_ei != NULL) {
/* Restore 'eventignore' to the value before ":noautocmd". */ /* Restore 'eventignore' to the value before ":noautocmd". */
set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei, set_string_option_direct((char_u *)"ei", -1, cmdmod.save_ei,
@ -2308,8 +2289,27 @@ static void free_cmdmod(void)
free_string_option(cmdmod.save_ei); free_string_option(cmdmod.save_ei);
} }
if (cmdmod.filter_regmatch.regprog != NULL) { vim_regfree(cmdmod.filter_regmatch.regprog);
vim_regfree(cmdmod.filter_regmatch.regprog);
if (eap->save_msg_silent != -1) {
// messages could be enabled for a serious error, need to check if the
// counters don't become negative
if (!did_emsg || msg_silent > eap->save_msg_silent) {
msg_silent = eap->save_msg_silent;
}
emsg_silent -= eap->did_esilent;
if (emsg_silent < 0) {
emsg_silent = 0;
}
// Restore msg_scroll, it's set by file I/O commands, even when no
// message is actually displayed.
msg_scroll = save_msg_scroll;
// "silent reg" or "silent echo x" inside "redir" leaves msg_col
// somewhere in the line. Put it back in the first column.
if (redirecting()) {
msg_col = 0;
}
} }
} }
@ -4446,6 +4446,9 @@ void separate_nextcmd(exarg_T *eap)
else if (p[0] == '`' && p[1] == '=' && (eap->argt & XFILE)) { else if (p[0] == '`' && p[1] == '=' && (eap->argt & XFILE)) {
p += 2; p += 2;
(void)skip_expr(&p); (void)skip_expr(&p);
if (*p == NUL) { // stop at NUL after CTRL-V
break;
}
} }
/* Check for '"': start of comment or '|': next command */ /* Check for '"': start of comment or '|': next command */
/* :@" does not start a comment! /* :@" does not start a comment!

View File

@ -903,6 +903,10 @@ normal_end:
msg_nowait = false; msg_nowait = false;
if (finish_op) {
set_reg_var(get_default_register_name());
}
// Reset finish_op, in case it was set // Reset finish_op, in case it was set
s->c = finish_op; s->c = finish_op;
finish_op = false; finish_op = false;

View File

@ -188,6 +188,7 @@ enum {
#define GO_ASELML 'A' // autoselect modeless selection #define GO_ASELML 'A' // autoselect modeless selection
#define GO_BOT 'b' // use bottom scrollbar #define GO_BOT 'b' // use bottom scrollbar
#define GO_CONDIALOG 'c' // use console dialog #define GO_CONDIALOG 'c' // use console dialog
#define GO_DARKTHEME 'd' // use dark theme variant
#define GO_TABLINE 'e' // may show tabline #define GO_TABLINE 'e' // may show tabline
#define GO_FORG 'f' // start GUI in foreground #define GO_FORG 'f' // start GUI in foreground
#define GO_GREY 'g' // use grey menu items #define GO_GREY 'g' // use grey menu items
@ -205,7 +206,7 @@ enum {
#define GO_FOOTER 'F' // add footer #define GO_FOOTER 'F' // add footer
#define GO_VERTICAL 'v' // arrange dialog buttons vertically #define GO_VERTICAL 'v' // arrange dialog buttons vertically
#define GO_KEEPWINSIZE 'k' // keep GUI window size #define GO_KEEPWINSIZE 'k' // keep GUI window size
#define GO_ALL "aAbcefFghilmMprTvk" // all possible flags for 'go' #define GO_ALL "aAbcdefFghilmMprTvk" // all possible flags for 'go'
// flags for 'comments' option // flags for 'comments' option
#define COM_NEST 'n' // comments strings nest #define COM_NEST 'n' // comments strings nest

View File

@ -119,6 +119,7 @@ struct slang_S {
bool sl_add; // true if it's a .add file. bool sl_add; // true if it's a .add file.
char_u *sl_fbyts; // case-folded word bytes char_u *sl_fbyts; // case-folded word bytes
long sl_fbyts_len; // length of sl_fbyts
idx_T *sl_fidxs; // case-folded word indexes idx_T *sl_fidxs; // case-folded word indexes
char_u *sl_kbyts; // keep-case word bytes char_u *sl_kbyts; // keep-case word bytes
idx_T *sl_kidxs; // keep-case word indexes idx_T *sl_kidxs; // keep-case word indexes

View File

@ -764,20 +764,24 @@ truncerr:
} }
// <LWORDTREE> // <LWORDTREE>
res = spell_read_tree(fd, &lp->sl_fbyts, &lp->sl_fidxs, false, 0); res = spell_read_tree(fd, &lp->sl_fbyts, &lp->sl_fbyts_len,
if (res != 0) &lp->sl_fidxs, false, 0);
if (res != 0) {
goto someerror; goto someerror;
}
// <KWORDTREE> // <KWORDTREE>
res = spell_read_tree(fd, &lp->sl_kbyts, &lp->sl_kidxs, false, 0); res = spell_read_tree(fd, &lp->sl_kbyts, NULL, &lp->sl_kidxs, false, 0);
if (res != 0) if (res != 0) {
goto someerror; goto someerror;
}
// <PREFIXTREE> // <PREFIXTREE>
res = spell_read_tree(fd, &lp->sl_pbyts, &lp->sl_pidxs, true, res = spell_read_tree(fd, &lp->sl_pbyts, NULL, &lp->sl_pidxs, true,
lp->sl_prefixcnt); lp->sl_prefixcnt);
if (res != 0) if (res != 0) {
goto someerror; goto someerror;
}
// For a new file link it in the list of spell files. // For a new file link it in the list of spell files.
if (old_lp == NULL && lang != NULL) { if (old_lp == NULL && lang != NULL) {
@ -920,8 +924,8 @@ void suggest_load_files(void)
// <SUGWORDTREE>: <wordtree> // <SUGWORDTREE>: <wordtree>
// Read the trie with the soundfolded words. // Read the trie with the soundfolded words.
if (spell_read_tree(fd, &slang->sl_sbyts, &slang->sl_sidxs, if (spell_read_tree(fd, &slang->sl_sbyts, NULL, &slang->sl_sidxs,
false, 0) != 0) { false, 0) != 0) {
someerror: someerror:
EMSG2(_("E782: error while reading .sug file: %s"), EMSG2(_("E782: error while reading .sug file: %s"),
slang->sl_fname); slang->sl_fname);
@ -1630,10 +1634,12 @@ static int
spell_read_tree ( spell_read_tree (
FILE *fd, FILE *fd,
char_u **bytsp, char_u **bytsp,
long *bytsp_len,
idx_T **idxsp, idx_T **idxsp,
bool prefixtree, // true for the prefix tree bool prefixtree, // true for the prefix tree
int prefixcnt // when "prefixtree" is true: prefix count int prefixcnt // when "prefixtree" is true: prefix count
) )
FUNC_ATTR_NONNULL_ARG(1, 2, 4)
{ {
int idx; int idx;
char_u *bp; char_u *bp;
@ -1653,6 +1659,9 @@ spell_read_tree (
// Allocate the byte array. // Allocate the byte array.
bp = xmalloc(len); bp = xmalloc(len);
*bytsp = bp; *bytsp = bp;
if (bytsp_len != NULL) {
*bytsp_len = len;
}
// Allocate the index array. // Allocate the index array.
ip = xcalloc(len, sizeof(*ip)); ip = xcalloc(len, sizeof(*ip));
@ -4850,10 +4859,10 @@ static int sug_filltree(spellinfo_T *spin, slang_T *slang)
spin->si_blocks_cnt = 0; spin->si_blocks_cnt = 0;
// Skip over any other NUL bytes (same word with different // Skip over any other NUL bytes (same word with different
// flags). // flags). But don't go over the end.
while (byts[n + 1] == 0) { while (n + 1 < slang->sl_fbyts_len && byts[n + 1] == 0) {
++n; n++;
++curi[depth]; curi[depth]++;
} }
} else { } else {
// Normal char, go one level deeper. // Normal char, go one level deeper.

View File

@ -722,7 +722,7 @@ func Test_verbosefile()
endfunc endfunc
func Test_verbose_option() func Test_verbose_option()
" See test/functional/ui/cmdline_spec.lua " See test/functional/legacy/cmdline_spec.lua
CheckScreendump CheckScreendump
let lines =<< trim [SCRIPT] let lines =<< trim [SCRIPT]
@ -842,6 +842,25 @@ func Test_buffers_lastused()
bwipeout bufc bwipeout bufc
endfunc endfunc
func Test_cmdlineclear_tabenter()
" See test/functional/legacy/cmdline_spec.lua
CheckScreendump
let lines =<< trim [SCRIPT]
call setline(1, range(30))
[SCRIPT]
call writefile(lines, 'XtestCmdlineClearTabenter')
let buf = RunVimInTerminal('-S XtestCmdlineClearTabenter', #{rows: 10})
call term_wait(buf, 50)
" in one tab make the command line higher with CTRL-W -
call term_sendkeys(buf, ":tabnew\<cr>\<C-w>-\<C-w>-gtgt")
call VerifyScreenDump(buf, 'Test_cmdlineclear_tabenter', {})
call StopVimInTerminal(buf)
call delete('XtestCmdlineClearTabenter')
endfunc
" test that ";" works to find a match at the start of the first line " test that ";" works to find a match at the start of the first line
func Test_zero_line_search() func Test_zero_line_search()
new new

View File

@ -1587,4 +1587,11 @@ func Test_edit_browse()
bwipe! bwipe!
endfunc endfunc
func Test_read_invalid()
" set encoding=latin1
" This was not properly checking for going past the end.
call assert_fails('r`=', 'E484')
set encoding=utf-8
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@ -167,6 +167,75 @@ func Test_set_register()
enew! enew!
endfunc endfunc
func Test_v_register()
enew
call setline(1, 'nothing')
func s:Put()
let s:register = v:register
exec 'normal! "' .. v:register .. 'P'
endfunc
nnoremap <buffer> <plug>(test) :<c-u>call s:Put()<cr>
nmap <buffer> S <plug>(test)
let @z = "testz\n"
let @" = "test@\n"
let s:register = ''
call feedkeys('"_ddS', 'mx')
call assert_equal('test@', getline('.')) " fails before 8.2.0929
call assert_equal('"', s:register) " fails before 8.2.0929
let s:register = ''
call feedkeys('"zS', 'mx')
call assert_equal('z', s:register)
let s:register = ''
call feedkeys('"zSS', 'mx')
call assert_equal('"', s:register)
let s:register = ''
call feedkeys('"_S', 'mx')
call assert_equal('_', s:register)
let s:register = ''
normal "_ddS
call assert_equal('"', s:register) " fails before 8.2.0929
call assert_equal('test@', getline('.')) " fails before 8.2.0929
let s:register = ''
execute 'normal "z:call' "s:Put()\n"
call assert_equal('z', s:register)
call assert_equal('testz', getline('.'))
" Test operator and omap
let @b = 'testb'
func s:OpFunc(...)
let s:register2 = v:register
endfunc
set opfunc=s:OpFunc
normal "bg@l
normal S
call assert_equal('"', s:register) " fails before 8.2.0929
call assert_equal('b', s:register2)
func s:Motion()
let s:register1 = v:register
normal! l
endfunc
onoremap <buffer> Q :<c-u>call s:Motion()<cr>
normal "bg@Q
normal S
call assert_equal('"', s:register)
call assert_equal('b', s:register1)
call assert_equal('"', s:register2)
set opfunc&
bwipe!
endfunc
func Test_ve_blockpaste() func Test_ve_blockpaste()
new new
set ve=all set ve=all

View File

@ -4049,7 +4049,7 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au
prevwin = next_prevwin; prevwin = next_prevwin;
last_status(false); // status line may appear or disappear last_status(false); // status line may appear or disappear
(void)win_comp_pos(); // recompute w_winrow for all windows const int row = win_comp_pos(); // recompute w_winrow for all windows
diff_need_scrollbind = true; diff_need_scrollbind = true;
/* The tabpage line may have appeared or disappeared, may need to resize /* The tabpage line may have appeared or disappeared, may need to resize
@ -4060,11 +4060,20 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au
clear_cmdline = true; clear_cmdline = true;
} }
p_ch = curtab->tp_ch_used; p_ch = curtab->tp_ch_used;
if (curtab->tp_old_Rows != Rows || (old_off != firstwin->w_winrow
)) // When cmdheight is changed in a tab page with '<C-w>-', cmdline_row is
// changed but p_ch and tp_ch_used are not changed. Thus we also need to
// check cmdline_row.
if ((row < cmdline_row) && (cmdline_row <= Rows - p_ch)) {
clear_cmdline = true;
}
if (curtab->tp_old_Rows != Rows || (old_off != firstwin->w_winrow)) {
shell_new_rows(); shell_new_rows();
if (curtab->tp_old_Columns != Columns && starting == 0) }
shell_new_columns(); /* update window widths */ if (curtab->tp_old_Columns != Columns && starting == 0) {
shell_new_columns(); // update window widths
}
lastused_tabpage = old_curtab; lastused_tabpage = old_curtab;

View File

@ -0,0 +1,66 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local feed = helpers.feed
local feed_command = helpers.feed_command
local source = helpers.source
describe('cmdline', function()
before_each(clear)
it('is cleared when switching tabs', function()
local screen = Screen.new(30, 10)
screen:attach()
feed_command([[call setline(1, range(30))]])
screen:expect([[
^0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
:call setline(1, range(30)) |
]])
feed([[:tabnew<cr><C-w>-<C-w>-gtgt]])
screen:expect([[
+ [No Name] [No Name] X|
^ |
~ |
~ |
~ |
~ |
~ |
6 |
7 |
|
]])
end)
it('prints every executed Ex command if verbose >= 16', function()
local screen = Screen.new(60, 12)
screen:attach()
source([[
command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v
call feedkeys("\r", 't') " for the hit-enter prompt
set verbose=20
]])
feed_command('DoSomething')
screen:expect([[
|
~ |
~ |
|
Executing: DoSomething |
Executing: echo 'hello' |set ts=4 |let v = '123' |echo v |
hello |
Executing: set ts=4 |let v = '123' |echo v |
Executing: let v = '123' |echo v |
Executing: echo v |
123 |
Press ENTER or type command to continue^ |
]])
end)
end)

View File

@ -3,7 +3,6 @@ local Screen = require('test.functional.ui.screen')
local clear, feed = helpers.clear, helpers.feed local clear, feed = helpers.clear, helpers.feed
local source = helpers.source local source = helpers.source
local command = helpers.command local command = helpers.command
local feed_command = helpers.feed_command
local function new_screen(opt) local function new_screen(opt)
local screen = Screen.new(25, 5) local screen = Screen.new(25, 5)
@ -843,34 +842,3 @@ describe('cmdline redraw', function()
]], unchanged=true} ]], unchanged=true}
end) end)
end) end)
describe('cmdline', function()
before_each(function()
clear()
end)
it('prints every executed Ex command if verbose >= 16', function()
local screen = Screen.new(50, 12)
screen:attach()
source([[
command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v
call feedkeys("\r", 't') " for the hit-enter prompt
set verbose=20
]])
feed_command('DoSomething')
screen:expect([[
|
~ |
|
Executing: DoSomething |
Executing: echo 'hello' |set ts=4 |let v = '123' ||
echo v |
hello |
Executing: set ts=4 |let v = '123' |echo v |
Executing: let v = '123' |echo v |
Executing: echo v |
123 |
Press ENTER or type command to continue^ |
]])
end)
end)