aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/ex_cmds.c6
-rw-r--r--src/nvim/ex_docmd.c1
-rw-r--r--src/nvim/quickfix.c76
-rw-r--r--src/nvim/testdir/test_cmdline.vim32
-rw-r--r--src/nvim/version.c455
-rw-r--r--src/nvim/window.c26
7 files changed, 411 insertions, 187 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index c0daac8085..172f2ce18e 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -929,7 +929,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack;
/// starting column and ending column (latter exclusive:
/// one should highlight region [start_col, end_col)).
///
-/// @return AST: top-level dictionary holds keys
+/// @return AST: top-level dictionary with these keys:
///
/// "error": Dictionary with error, present only if parser saw some
/// error. Contains the following keys:
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 4f54d4c88b..c5825963c0 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -4619,7 +4619,8 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la
"/\\(\\)", "/\\%(\\)",
"?", ":?", "?<CR>", "g?", "g?g?", "g??", "z?",
"/\\?", "/\\z(\\)", "\\=", ":s\\=",
- "[count]", "[quotex]", "[range]",
+ "[count]", "[quotex]",
+ "[range]", ":[range]",
"[pattern]", "\\|", "\\%$",
"s/\\~", "s/\\U", "s/\\L",
"s/\\1", "s/\\2", "s/\\3", "s/\\9"};
@@ -4628,7 +4629,8 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la
"/\\\\(\\\\)", "/\\\\%(\\\\)",
"?", ":?", "?<CR>", "g?", "g?g?", "g??", "z?",
"/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=",
- "\\[count]", "\\[quotex]", "\\[range]",
+ "\\[count]", "\\[quotex]",
+ "\\[range]", ":\\[range]",
"\\[pattern]", "\\\\bar", "/\\\\%\\$",
"s/\\\\\\~", "s/\\\\U", "s/\\\\L",
"s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"};
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index f6a5f59676..a0ede4f3c5 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -6230,7 +6230,6 @@ void tabpage_close_other(tabpage_T *tp, int forceit)
if (!valid_tabpage(tp) || tp->tp_firstwin == wp)
break;
}
- apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, FALSE, curbuf);
redraw_tabline = TRUE;
if (h != tabline_height())
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index f85009dca8..120a449690 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1121,6 +1121,7 @@ qf_init_ext(
}
if (qf_add_entry(qi,
+ qi->qf_curlist,
qi->qf_directory,
(*fields.namebuf || qi->qf_directory)
? fields.namebuf : ((qi->qf_currfile && fields.valid)
@@ -1182,13 +1183,14 @@ qf_init_end:
return retval;
}
-static void qf_store_title(qf_info_T *qi, char_u *title)
+static void qf_store_title(qf_info_T *qi, int qf_idx, char_u *title)
{
if (title != NULL) {
- char_u *p = xmalloc(STRLEN(title) + 2);
+ size_t len = STRLEN(title) + 1;
+ char_u *p = xmallocz(len);
- qi->qf_lists[qi->qf_curlist].qf_title = p;
- sprintf((char *)p, ":%s", (char *)title);
+ qi->qf_lists[qf_idx].qf_title = p;
+ snprintf((char *)p, len + 1, ":%s", (char *)title);
}
}
@@ -1217,7 +1219,7 @@ static void qf_new_list(qf_info_T *qi, char_u *qf_title)
} else
qi->qf_curlist = qi->qf_listcount++;
memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T)));
- qf_store_title(qi, qf_title);
+ qf_store_title(qi, qi->qf_curlist, qf_title);
}
/*
@@ -1260,6 +1262,7 @@ void qf_free_all(win_T *wp)
/// Add an entry to the end of the list of errors.
///
/// @param qi quickfix list
+/// @param qf_idx list index
/// @param dir optional directory name
/// @param fname file name or NULL
/// @param bufnum buffer number or zero
@@ -1273,9 +1276,10 @@ void qf_free_all(win_T *wp)
/// @param valid valid entry
///
/// @returns OK or FAIL.
-static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum,
- char_u *mesg, long lnum, int col, char_u vis_col,
- char_u *pattern, int nr, char_u type, char_u valid)
+static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname,
+ int bufnum, char_u *mesg, long lnum, int col,
+ char_u vis_col, char_u *pattern, int nr, char_u type,
+ char_u valid)
{
qfline_T *qfp = xmalloc(sizeof(qfline_T));
qfline_T **lastp; // pointer to qf_last or NULL
@@ -1306,12 +1310,12 @@ static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum,
qfp->qf_type = (char_u)type;
qfp->qf_valid = valid;
- lastp = &qi->qf_lists[qi->qf_curlist].qf_last;
- if (qi->qf_lists[qi->qf_curlist].qf_count == 0) {
- /* first element in the list */
- qi->qf_lists[qi->qf_curlist].qf_start = qfp;
- qi->qf_lists[qi->qf_curlist].qf_ptr = qfp;
- qi->qf_lists[qi->qf_curlist].qf_index = 0;
+ lastp = &qi->qf_lists[qf_idx].qf_last;
+ if (qi->qf_lists[qf_idx].qf_count == 0) {
+ // first element in the list
+ qi->qf_lists[qf_idx].qf_start = qfp;
+ qi->qf_lists[qf_idx].qf_ptr = qfp;
+ qi->qf_lists[qf_idx].qf_index = 0;
qfp->qf_prev = NULL;
} else {
assert(*lastp);
@@ -1321,12 +1325,11 @@ static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum,
qfp->qf_next = NULL;
qfp->qf_cleared = false;
*lastp = qfp;
- qi->qf_lists[qi->qf_curlist].qf_count++;
- if (qi->qf_lists[qi->qf_curlist].qf_index == 0 && qfp->qf_valid) {
- /* first valid entry */
- qi->qf_lists[qi->qf_curlist].qf_index =
- qi->qf_lists[qi->qf_curlist].qf_count;
- qi->qf_lists[qi->qf_curlist].qf_ptr = qfp;
+ qi->qf_lists[qf_idx].qf_count++;
+ if (qi->qf_lists[qf_idx].qf_index == 0 && qfp->qf_valid) {
+ // first valid entry
+ qi->qf_lists[qf_idx].qf_index = qi->qf_lists[qf_idx].qf_count;
+ qi->qf_lists[qf_idx].qf_ptr = qfp;
}
return OK;
@@ -1429,6 +1432,7 @@ void copy_loclist(win_T *from, win_T *to)
i < from_qfl->qf_count && from_qfp != NULL;
i++, from_qfp = from_qfp->qf_next) {
if (qf_add_entry(to->w_llist,
+ to->w_llist->qf_curlist,
NULL,
NULL,
0,
@@ -3704,6 +3708,7 @@ void ex_vimgrep(exarg_T *eap)
// dummy buffer, unless duplicate_name is set, then the
// buffer will be wiped out below.
if (qf_add_entry(qi,
+ qi->qf_curlist,
NULL, // dir
fname,
duplicate_name ? 0 : buf->b_fnum,
@@ -4164,23 +4169,24 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict)
/// Add list of entries to quickfix/location list. Each list entry is
/// a dictionary with item information.
-static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title,
- int action)
+static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list,
+ char_u *title, int action)
{
dict_T *d;
qfline_T *old_last = NULL;
int retval = OK;
bool did_bufnr_emsg = false;
- if (action == ' ' || qi->qf_curlist == qi->qf_listcount) {
+ if (action == ' ' || qf_idx == qi->qf_listcount) {
// make place for a new list
qf_new_list(qi, title);
- } else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0) {
+ qf_idx = qi->qf_curlist;
+ } else if (action == 'a' && qi->qf_lists[qf_idx].qf_count > 0) {
// Adding to existing list, use last entry.
- old_last = qi->qf_lists[qi->qf_curlist].qf_last;
+ old_last = qi->qf_lists[qf_idx].qf_last;
} else if (action == 'r') {
- qf_free(qi, qi->qf_curlist);
- qf_store_title(qi, title);
+ qf_free(qi, qf_idx);
+ qf_store_title(qi, qf_idx, title);
}
TV_LIST_ITER_CONST(list, li, {
@@ -4228,6 +4234,7 @@ static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title,
}
int status = qf_add_entry(qi,
+ qf_idx,
NULL, // dir
(char_u *)filename,
bufnum,
@@ -4250,16 +4257,16 @@ static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title,
}
});
- if (qi->qf_lists[qi->qf_curlist].qf_index == 0) {
+ if (qi->qf_lists[qf_idx].qf_index == 0) {
// no valid entry
- qi->qf_lists[qi->qf_curlist].qf_nonevalid = true;
+ qi->qf_lists[qf_idx].qf_nonevalid = true;
} else {
- qi->qf_lists[qi->qf_curlist].qf_nonevalid = false;
+ qi->qf_lists[qf_idx].qf_nonevalid = false;
}
if (action != 'a') {
- qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start;
- if (qi->qf_lists[qi->qf_curlist].qf_count > 0) {
- qi->qf_lists[qi->qf_curlist].qf_index = 1;
+ qi->qf_lists[qf_idx].qf_ptr = qi->qf_lists[qf_idx].qf_start;
+ if (qi->qf_lists[qf_idx].qf_count > 0) {
+ qi->qf_lists[qf_idx].qf_index = 1;
}
}
@@ -4400,7 +4407,7 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title,
} else if (what != NULL) {
retval = qf_set_properties(qi, what, action);
} else {
- retval = qf_add_entries(qi, list, title, action);
+ retval = qf_add_entries(qi, qi->qf_curlist, list, title, action);
}
return retval;
@@ -4718,6 +4725,7 @@ void ex_helpgrep(exarg_T *eap)
line[--l] = NUL;
if (qf_add_entry(qi,
+ qi->qf_curlist,
NULL, // dir
fnames[fi],
0,
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index ac44e09a5a..dc9790a39c 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -330,4 +330,36 @@ func Test_cmdline_search_range()
bwipe!
endfunc
+" Tests for getcmdline(), getcmdpos() and getcmdtype()
+func Check_cmdline(cmdtype)
+ call assert_equal('MyCmd a', getcmdline())
+ call assert_equal(8, getcmdpos())
+ call assert_equal(a:cmdtype, getcmdtype())
+ return ''
+endfunc
+
+func Test_getcmdtype()
+ call feedkeys(":MyCmd a\<C-R>=Check_cmdline(':')\<CR>\<Esc>", "xt")
+
+ let cmdtype = ''
+ debuggreedy
+ call feedkeys(":debug echo 'test'\<CR>", "t")
+ call feedkeys("let cmdtype = \<C-R>=string(getcmdtype())\<CR>\<CR>", "t")
+ call feedkeys("cont\<CR>", "xt")
+ 0debuggreedy
+ call assert_equal('>', cmdtype)
+
+ call feedkeys("/MyCmd a\<C-R>=Check_cmdline('/')\<CR>\<Esc>", "xt")
+ call feedkeys("?MyCmd a\<C-R>=Check_cmdline('?')\<CR>\<Esc>", "xt")
+
+ call feedkeys(":call input('Answer?')\<CR>", "t")
+ call feedkeys("MyCmd a\<C-R>=Check_cmdline('@')\<CR>\<Esc>", "xt")
+
+ call feedkeys(":insert\<CR>MyCmd a\<C-R>=Check_cmdline('-')\<CR>\<Esc>", "xt")
+
+ cnoremap <expr> <F6> Check_cmdline('=')
+ call feedkeys("a\<C-R>=MyCmd a\<F6>\<Esc>\<Esc>", "xt")
+ cunmap <F6>
+endfunc
+
set cpo&
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 8ab9fc1a4b..e35b803b4e 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -146,7 +146,7 @@ static const int included_patches[] = {
// 1292,
// 1291,
// 1290,
- // 1289,
+ 1289,
// 1288,
// 1287,
// 1286,
@@ -228,8 +228,187 @@ static const int included_patches[] = {
// 1210,
// 1209,
// 1208,
- // 1207,
+ 1207,
1206,
+ // 1205,
+ // 1204,
+ // 1203,
+ // 1202,
+ // 1201,
+ // 1200,
+ // 1199,
+ // 1198,
+ // 1197,
+ // 1196,
+ // 1195,
+ // 1194,
+ // 1193,
+ // 1192,
+ // 1191,
+ // 1190,
+ 1189,
+ // 1188,
+ // 1187,
+ // 1186,
+ // 1185,
+ // 1184,
+ // 1183,
+ // 1182,
+ // 1181,
+ // 1180,
+ // 1179,
+ // 1178,
+ // 1177,
+ // 1176,
+ // 1175,
+ // 1174,
+ // 1173,
+ // 1172,
+ // 1171,
+ // 1170,
+ // 1169,
+ // 1168,
+ // 1167,
+ // 1166,
+ // 1165,
+ // 1164,
+ // 1163,
+ // 1162,
+ // 1161,
+ // 1160,
+ // 1159,
+ // 1158,
+ // 1157,
+ // 1156,
+ // 1155,
+ // 1154,
+ // 1153,
+ // 1152,
+ // 1151,
+ // 1150,
+ // 1149,
+ // 1148,
+ // 1147,
+ // 1146,
+ // 1145,
+ // 1144,
+ // 1143,
+ // 1142,
+ // 1141,
+ // 1140,
+ // 1139,
+ // 1138,
+ // 1137,
+ // 1136,
+ // 1135,
+ // 1134,
+ // 1133,
+ // 1132,
+ // 1131,
+ // 1130,
+ // 1129,
+ // 1128,
+ // 1127,
+ // 1126,
+ // 1125,
+ // 1124,
+ // 1123,
+ // 1122,
+ // 1121,
+ // 1120,
+ // 1119,
+ // 1118,
+ // 1117,
+ // 1116,
+ // 1115,
+ // 1114,
+ // 1113,
+ // 1112,
+ // 1111,
+ // 1110,
+ // 1109,
+ 1108,
+ // 1107,
+ // 1106,
+ // 1105,
+ // 1104,
+ // 1103,
+ // 1102,
+ // 1101,
+ // 1100,
+ // 1099,
+ // 1098,
+ // 1097,
+ // 1096,
+ // 1095,
+ // 1094,
+ // 1093,
+ // 1092,
+ // 1091,
+ // 1090,
+ // 1089,
+ // 1088,
+ // 1087,
+ // 1086,
+ // 1085,
+ // 1084,
+ // 1083,
+ // 1082,
+ // 1081,
+ // 1080,
+ // 1079,
+ // 1078,
+ // 1077,
+ // 1076,
+ // 1075,
+ // 1074,
+ // 1073,
+ // 1072,
+ // 1071,
+ // 1070,
+ // 1069,
+ // 1068,
+ // 1067,
+ // 1066,
+ // 1065,
+ // 1064,
+ // 1063,
+ // 1062,
+ // 1061,
+ // 1060,
+ // 1059,
+ // 1058,
+ // 1057,
+ // 1056,
+ // 1055,
+ // 1054,
+ // 1053,
+ // 1052,
+ // 1051,
+ // 1050,
+ // 1049,
+ // 1048,
+ // 1047,
+ // 1046,
+ // 1045,
+ // 1044,
+ // 1043,
+ // 1042,
+ // 1041,
+ // 1040,
+ // 1039,
+ // 1038,
+ // 1037,
+ // 1036,
+ // 1035,
+ // 1034,
+ // 1033,
+ // 1032,
+ // 1031,
+ // 1030,
+ // 1029,
+ // 1028,
+ // 1027,
// 1026,
1025,
1024,
@@ -237,7 +416,7 @@ static const int included_patches[] = {
// 1022,
// 1021,
// 1020,
- // 1019,
+ 1019,
// 1018,
// 1017,
// 1016,
@@ -294,7 +473,7 @@ static const int included_patches[] = {
// 965,
// 964,
// 963,
- // 962,
+ 962,
// 961,
// 960,
// 959,
@@ -650,7 +829,7 @@ static const int included_patches[] = {
// 609,
// 608,
607,
- // 606,
+ 606,
605,
// 604,
// 603,
@@ -659,30 +838,30 @@ static const int included_patches[] = {
// 600,
// 599,
// 598,
- // 597,
+ 597,
// 596,
- // 595,
+ 595,
// 594,
// 593,
// 592,
// 591,
- // 590,
+ 590,
// 589,
// 588,
// 587,
// 586,
// 585,
- // 584,
+ 584,
// 583,
// 582,
// 581,
- // 580,
- // 579,
+ 580,
+ 579,
// 578,
// 577,
// 576,
// 575,
- // 574,
+ 574,
// 573,
// 572,
571,
@@ -691,7 +870,7 @@ static const int included_patches[] = {
// 568,
// 567,
// 566,
- // 565,
+ 565,
// 564,
// 563,
// 562,
@@ -720,7 +899,7 @@ static const int included_patches[] = {
// 539,
// 538,
// 537,
- // 536,
+ 536,
// 535,
// 534,
// 533,
@@ -739,7 +918,7 @@ static const int included_patches[] = {
// 520,
// 519,
518,
- // 517,
+ 517,
// 516,
// 515,
// 514,
@@ -772,7 +951,7 @@ static const int included_patches[] = {
487,
486,
485,
- // 484,
+ 484,
483,
482,
// 481,
@@ -836,7 +1015,7 @@ static const int included_patches[] = {
// 423,
// 422,
// 421,
- // 420,
+ 420,
// 419,
// 418,
// 417,
@@ -851,12 +1030,12 @@ static const int included_patches[] = {
408,
407,
// 406,
- // 405 NA
- // 404,
+ 405,
+ 404,
// 403,
// 402,
// 401,
- // 400 NA
+ 400,
// 399,
// 398,
// 397,
@@ -877,7 +1056,7 @@ static const int included_patches[] = {
// 382,
// 381,
// 380,
- // 379,
+ 379,
378,
377,
376,
@@ -936,7 +1115,7 @@ static const int included_patches[] = {
// 323,
322,
// 321,
- // 320,
+ 320,
319,
// 318,
// 317,
@@ -946,18 +1125,18 @@ static const int included_patches[] = {
// 313,
// 312,
311,
- // 310,
- // 309,
+ 310,
+ 309,
308,
307,
306,
305,
// 304,
// 303,
- // 302 NA
+ 302,
// 301,
300,
- // 299,
+ 299,
298,
297,
// 296,
@@ -968,38 +1147,38 @@ static const int included_patches[] = {
291,
290,
289,
- // 288 NA
+ 288,
287,
// 286,
- // 285 NA
- // 284 NA
+ 285,
+ 284,
283,
282,
- // 281 NA
+ 281,
280,
- // 279 NA
- // 278 NA
- // 277 NA
- // 276 NA
+ 279,
+ 278,
+ 277,
+ 276,
275,
274,
- // 273 NA
- // 272 NA
- // 271 NA
- // 270 NA
- // 269 NA
- // 268 NA
- // 267 NA
+ 273,
+ 272,
+ 271,
+ 270,
+ 269,
+ 268,
+ 267,
266,
// 265,
// 264,
// 263,
// 262,
// 261,
- // 260 NA
+ 260,
259,
258,
- // 257 NA
+ 257,
// 256,
// 255,
// 254,
@@ -1007,45 +1186,45 @@ static const int included_patches[] = {
// 252,
// 251,
250,
- // 249 NA
- // 248 NA
+ 249,
+ 248,
247,
- // 246 NA
+ 246,
245,
- // 244 NA
+ 244,
243,
242,
- // 241 NA
- // 240 NA
- // 239 NA
+ 241,
+ 240,
+ 239,
// 238,
237,
// 236,
235,
// 234,
// 233,
- // 232 NA
+ 232,
// 231,
// 230,
229,
// 228,
- // 227,
+ 227,
226,
// 225,
224,
223,
// 222,
- // 221 NA
+ 221,
// 220,
219,
218,
- // 217 NA
+ 217,
// 216,
- // 215 NA
+ 215,
// 214,
- // 213 NA
+ 213,
// 212,
- // 211 NA
+ 211,
// 210,
209,
208,
@@ -1053,49 +1232,49 @@ static const int included_patches[] = {
206,
205,
// 204,
- // 203 NA
+ 203,
// 202,
// 201,
// 200,
- // 199 NA
+ 199,
// 198,
// 197,
196,
195,
194,
- // 193 NA
- // 192 NA
- // 191 NA
+ 193,
+ 192,
+ 191,
190,
189,
188,
- // 187 NA
+ 187,
186,
// 185,
// 184,
- // 183 NA
+ 183,
182,
181,
- // 180 NA
+ 180,
179,
178,
177,
176,
// 175,
174,
- // 173 NA
+ 173,
172,
- // 171 NA
- // 170 NA
- // 169 NA
+ 171,
+ 170,
+ 169,
168,
167,
- // 166 NA
+ 166,
165,
164,
- // 163 NA
- // 162 NA
- // 161 NA
+ 163,
+ 162,
+ 161,
// 160,
159,
158,
@@ -1104,21 +1283,21 @@ static const int included_patches[] = {
155,
// 154,
// 153,
- // 152 NA
+ 152,
// 151,
150,
149,
148,
147,
146,
- // 145 NA
- // 144 NA
+ 145,
+ 144,
143,
142,
- // 141 NA
+ 141,
140,
- // 139 NA
- // 138 NA
+ 139,
+ 138,
137,
136,
135,
@@ -1126,137 +1305,137 @@ static const int included_patches[] = {
133,
132,
131,
- // 130 NA
- // 129 NA
+ 130,
+ 129,
128,
127,
126,
125,
124,
- // 123 NA
- // 122 NA
+ 123,
+ 122,
121,
- // 120 NA
+ 120,
119,
118,
- // 117 NA
+ 117,
116,
- // 115 NA
- // 114 NA
- // 113 NA
+ 115,
+ 114,
+ 113,
112,
111,
110,
- // 109 NA
- // 108 NA
- // 107 NA
+ 109,
+ 108,
+ 107,
106,
- // 105 NA
+ 105,
104,
- // 103 NA
+ 103,
102,
101,
100,
99,
- // 98 NA
- // 97 NA
+ 98,
+ 97,
96,
- // 95 NA
- // 94 NA
- // 93 NA
+ 95,
+ 94,
+ 93,
92,
91,
90,
- // 89 NA
+ 89,
88,
- // 87 NA
+ 87,
86,
85,
84,
83,
- // 82 NA
+ 82,
81,
- // 80 NA
+ 80,
79,
78,
- // 77 NA
- // 76 NA
+ 77,
+ 76,
75,
74,
73,
- // 72 NA
- // 71 NA
- // 70 NA
+ 72,
+ 71,
+ 70,
69,
68,
- // 67 NA
+ 67,
66,
- // 65 NA
+ 65,
64,
- // 63 NA
+ 63,
62,
- // 61 NA
+ 61,
60,
- // 59 NA
+ 59,
58,
57,
56,
- // 55 NA
- // 54 NA
+ 55,
+ 54,
53,
52,
- // 51 NA
- // 50 NA
+ 51,
+ 50,
49,
- // 48 NA
+ 48,
47,
46,
- // 45 NA
+ 45,
44,
43,
42,
41,
40,
- // 39 NA
+ 39,
38,
37,
- // 36 NA
+ 36,
35,
34,
33,
32,
31,
- // 30 NA
- // 29 NA
- // 28 NA
- // 27 NA
+ 30,
+ 29,
+ 28,
+ 27,
26,
25,
- // 24 NA
+ 24,
23,
- // 22 NA
- // 21 NA
+ 22,
+ 21,
20,
19,
- // 18 NA
+ 18,
17,
- // 16 NA
- // 15 NA
- // 14 NA
- // 13 NA
+ 16,
+ 15,
+ 14,
+ 13,
12,
- // 11 NA
- // 10 NA
- // 9 NA
+ 11,
+ 10,
+ 9,
8,
- // 7 NA
+ 7,
6,
- // 5 NA
+ 5,
4,
3,
2,
1,
- 0
+ 0,
};
// clang-format on
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 5e85a9bede..b687781dfb 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1724,7 +1724,6 @@ void close_windows(buf_T *buf, int keep_curwin)
{
tabpage_T *tp, *nexttp;
int h = tabline_height();
- int count = tabpage_index(NULL);
++RedrawingDisabled;
@@ -1762,10 +1761,6 @@ void close_windows(buf_T *buf, int keep_curwin)
--RedrawingDisabled;
- if (count != tabpage_index(NULL)) {
- apply_autocmds(EVENT_TABCLOSED, NULL, NULL, false, curbuf);
- }
-
redraw_tabline = true;
if (h != tabline_height()) {
shell_new_rows();
@@ -1848,7 +1843,6 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf,
// Since goto_tabpage_tp above did not trigger *Enter autocommands, do
// that now.
- apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf);
apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf);
apply_autocmds(EVENT_TABENTER, NULL, NULL, false, curbuf);
if (old_curbuf != curbuf) {
@@ -2108,19 +2102,29 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
/* When closing the last window in a tab page remove the tab page. */
if (tp->tp_firstwin == tp->tp_lastwin) {
- if (tp == first_tabpage)
+ char_u prev_idx[NUMBUFLEN];
+ if (has_event(EVENT_TABCLOSED)) {
+ vim_snprintf((char *)prev_idx, NUMBUFLEN, "%i", tabpage_index(tp));
+ }
+
+ if (tp == first_tabpage) {
first_tabpage = tp->tp_next;
- else {
+ } else {
for (ptp = first_tabpage; ptp != NULL && ptp->tp_next != tp;
- ptp = ptp->tp_next)
- ;
+ ptp = ptp->tp_next) {
+ // loop
+ }
if (ptp == NULL) {
internal_error("win_close_othertab()");
return;
}
ptp->tp_next = tp->tp_next;
}
- free_tp = TRUE;
+ free_tp = true;
+
+ if (has_event(EVENT_TABCLOSED)) {
+ apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, win->w_buffer);
+ }
}
/* Free the memory used for the window. */