diff options
author | Sean Dewar <seandewar@users.noreply.github.com> | 2022-03-14 12:16:12 +0000 |
---|---|---|
committer | Sean Dewar <seandewar@users.noreply.github.com> | 2022-03-14 13:10:57 +0000 |
commit | 365a9b074f2df3c573ae4a520084818bdd46cd3d (patch) | |
tree | 7da2a639663d6c46e57766b5e9cb70a6ccd63c39 /src/nvim/ex_docmd.c | |
parent | c5f190e0c21b4e8465502fd9f260c3d49a4102ab (diff) | |
download | rneovim-365a9b074f2df3c573ae4a520084818bdd46cd3d.tar.gz rneovim-365a9b074f2df3c573ae4a520084818bdd46cd3d.tar.bz2 rneovim-365a9b074f2df3c573ae4a520084818bdd46cd3d.zip |
vim-patch:8.2.1413: previous tab page not usable from an Ex command
Problem: Previous tab page not usable from an Ex command.
Solution: Add the "#" argument for :tabnext et al. (Yegappan Lakshmanan,
closes vim/vim#6677)
https://github.com/vim/vim/commit/94f4ffa7704921a3634e56b878e6dc362bc3d508
Do not rename old_curtab to prev_tp in win_new_tabpage, this can be confused
with the previous tabpage (`:tabprevious`).
Cherry-pick ex_errmsg from v8.2.1280.
https://github.com/vim/vim/commit/8930caaa1a283092aca81fdbc3fcf15c7eadb197
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 6bd465e6ee..09cf6601ee 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2036,6 +2036,18 @@ doend: return ea.nextcmd; } +static char ex_error_buf[MSG_BUF_LEN]; + +/// @return an error message with argument included. +/// Uses a static buffer, only the last error will be kept. +/// "msg" will be translated, caller should use N_(). +char *ex_errmsg(const char *const msg, const char_u *const arg) + FUNC_ATTR_NONNULL_ALL +{ + vim_snprintf(ex_error_buf, MSG_BUF_LEN, _(msg), arg); + return ex_error_buf; +} + // Parse and skip over command modifiers: // - update eap->cmd // - store flags in "cmdmod". @@ -4861,7 +4873,13 @@ static int get_tabpage_arg(exarg_T *eap) if (STRCMP(p, "$") == 0) { tab_number = LAST_TAB_NR; } else if (STRCMP(p, "#") == 0) { - tab_number = tabpage_index(lastused_tabpage); + if (valid_tabpage(lastused_tabpage)) { + tab_number = tabpage_index(lastused_tabpage); + } else { + eap->errmsg = ex_errmsg(e_invargval, eap->arg); + tab_number = 0; + goto theend; + } } else if (p == p_save || *p_save == '-' || *p != NUL || tab_number > LAST_TAB_NR) { // No numbers as argument. |