aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/usercmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/usercmd.c')
-rw-r--r--src/nvim/usercmd.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c
index 0e045c773f..4c2ea75047 100644
--- a/src/nvim/usercmd.c
+++ b/src/nvim/usercmd.c
@@ -1236,8 +1236,18 @@ size_t add_win_cmd_modifers(char *buf, const cmdmod_T *cmod, bool *multi_mods)
// :tab
if (cmod->cmod_tab > 0) {
- result += add_cmd_modifier(buf, "tab", multi_mods);
+ int tabnr = cmod->cmod_tab - 1;
+ if (tabnr == tabpage_index(curtab)) {
+ // For compatibility, don't add a tabpage number if it is the same
+ // as the default number for :tab.
+ result += add_cmd_modifier(buf, "tab", multi_mods);
+ } else {
+ char tab_buf[NUMBUFLEN + 3];
+ snprintf(tab_buf, sizeof(tab_buf), "%dtab", tabnr);
+ result += add_cmd_modifier(buf, tab_buf, multi_mods);
+ }
}
+
// :topleft
if (cmod->cmod_split & WSP_TOP) {
result += add_cmd_modifier(buf, "topleft", multi_mods);
@@ -1307,7 +1317,7 @@ size_t uc_mods(char *buf, const cmdmod_T *cmod, bool quote)
result += add_cmd_modifier(buf, "verbose", &multi_mods);
} else {
char verbose_buf[NUMBUFLEN];
- snprintf(verbose_buf, NUMBUFLEN, "%dverbose", verbose_value);
+ snprintf(verbose_buf, sizeof(verbose_buf), "%dverbose", verbose_value);
result += add_cmd_modifier(buf, verbose_buf, &multi_mods);
}
}