diff --git a/src/buffer.c b/src/buffer.c index 5d88d01c04..a36e3b12aa 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -595,6 +595,7 @@ close_buffer( if (buf->b_nwindows == 1) { ++buf->b_locked; + ++buf->b_locked_split; if (apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname, FALSE, buf) && !bufref_valid(&bufref)) @@ -605,6 +606,7 @@ aucmd_abort: return FALSE; } --buf->b_locked; + --buf->b_locked_split; if (abort_if_last && one_window()) // Autocommands made this the only window. goto aucmd_abort; @@ -614,12 +616,14 @@ aucmd_abort: if (!unload_buf) { ++buf->b_locked; + ++buf->b_locked_split; if (apply_autocmds(EVENT_BUFHIDDEN, buf->b_fname, buf->b_fname, FALSE, buf) && !bufref_valid(&bufref)) // Autocommands deleted the buffer. goto aucmd_abort; --buf->b_locked; + --buf->b_locked_split; if (abort_if_last && one_window()) // Autocommands made this the only window. goto aucmd_abort; @@ -804,6 +808,7 @@ buf_freeall(buf_T *buf, int flags) // Make sure the buffer isn't closed by autocommands. ++buf->b_locked; + ++buf->b_locked_split; set_bufref(&bufref, buf); if (buf->b_ml.ml_mfp != NULL) { @@ -830,6 +835,7 @@ buf_freeall(buf_T *buf, int flags) return; } --buf->b_locked; + --buf->b_locked_split; // If the buffer was in curwin and the window has changed, go back to that // window, if it still exists. This avoids that ":edit x" triggering a @@ -1722,8 +1728,8 @@ set_curbuf(buf_T *buf, int action) set_bufref(&prevbufref, prevbuf); set_bufref(&newbufref, buf); - // Autocommands may delete the current buffer and/or the buffer we want to go - // to. In those cases don't close the buffer. + // Autocommands may delete the current buffer and/or the buffer we want to + // go to. In those cases don't close the buffer. if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf) || (bufref_valid(&prevbufref) && bufref_valid(&newbufref) diff --git a/src/dict.c b/src/dict.c index 260f229850..b36b2bf6dd 100644 --- a/src/dict.c +++ b/src/dict.c @@ -945,7 +945,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) if (**arg != ':') { if (*skipwhite(*arg) == ':') - semsg(_(e_no_white_space_allowed_before_str), ":"); + semsg(_(e_no_white_space_allowed_before_str_str), ":", *arg); else semsg(_(e_missing_dict_colon), *arg); clear_tv(&tvkey); @@ -970,7 +970,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) } if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1])) { - semsg(_(e_white_space_required_after_str), ":"); + semsg(_(e_white_space_required_after_str_str), ":", *arg); clear_tv(&tvkey); goto failret; } @@ -1012,7 +1012,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) { if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1])) { - semsg(_(e_white_space_required_after_str), ","); + semsg(_(e_white_space_required_after_str_str), ",", *arg); goto failret; } *arg = skipwhite(*arg + 1); @@ -1025,7 +1025,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) if (!had_comma) { if (**arg == ',') - semsg(_(e_no_white_space_allowed_before_str), ","); + semsg(_(e_no_white_space_allowed_before_str_str), ",", *arg); else semsg(_(e_missing_dict_comma), *arg); goto failret; diff --git a/src/errors.h b/src/errors.h index e6d7ab26c8..9b9a782753 100644 --- a/src/errors.h +++ b/src/errors.h @@ -173,10 +173,10 @@ EXTERN char e_cannot_declare_a_register_str[] INIT(= N_("E1066: Cannot declare a register: %s")); EXTERN char e_separator_mismatch_str[] INIT(= N_("E1067: Separator mismatch: %s")); -EXTERN char e_no_white_space_allowed_before_str[] - INIT(= N_("E1068: No white space allowed before '%s'")); -EXTERN char e_white_space_required_after_str[] - INIT(= N_("E1069: White space required after '%s'")); +EXTERN char e_no_white_space_allowed_before_str_str[] + INIT(= N_("E1068: No white space allowed before '%s': %s")); +EXTERN char e_white_space_required_after_str_str[] + INIT(= N_("E1069: White space required after '%s': %s")); EXTERN char e_missing_from[] INIT(= N_("E1070: Missing \"from\"")); EXTERN char e_invalid_string_after_from[] @@ -353,3 +353,7 @@ EXTERN char e_missing_return_type[] INIT(= N_("E1157: Missing return type")); EXTERN char e_cannot_use_flatten_in_vim9_script[] INIT(= N_("E1158: Cannot use flatten() in Vim9 script")); +EXTERN char e_cannot_split_window_when_closing_buffer[] + INIT(= N_("E1159: Cannot split a window when closing the buffer")); +EXTERN char e_cannot_use_default_for_variable_arguments[] + INIT(= N_("E1160: Cannot use a default for variable arguments")); diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 40e5eed9d7..b5bdcd3cde 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -5218,8 +5218,7 @@ ends_excmd2(char_u *cmd_start UNUSED, char_u *cmd) return TRUE; #ifdef FEAT_EVAL if (in_vim9script()) - return c == '#' && cmd[1] != '{' - && (cmd == cmd_start || VIM_ISWHITE(cmd[-1])); + return c == '#' && (cmd == cmd_start || VIM_ISWHITE(cmd[-1])); #endif return c == '"'; } diff --git a/src/filepath.c b/src/filepath.c index b8bfc78096..99193383fe 100644 --- a/src/filepath.c +++ b/src/filepath.c @@ -3360,7 +3360,10 @@ dos_expandpath( if (p == NULL) break; // out of memory - if (*wfb.cAlternateFileName == NUL) + // Do not use the alternate filename when the file name ends in '~', + // because it picks up backup files: short name for "foo.vim~" is + // "foo~1.vim", which matches "*.vim". + if (*wfb.cAlternateFileName == NUL || p[STRLEN(p) - 1] == '~') p_alt = NULL; else p_alt = utf16_to_enc(wfb.cAlternateFileName, NULL); diff --git a/src/list.c b/src/list.c index c51c99bc90..4d33aa6e08 100644 --- a/src/list.c +++ b/src/list.c @@ -1311,7 +1311,7 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error) { if (vim9script && !IS_WHITE_OR_NUL((*arg)[1]) && (*arg)[1] != ']') { - semsg(_(e_white_space_required_after_str), ","); + semsg(_(e_white_space_required_after_str_str), ",", *arg); goto failret; } *arg = skipwhite(*arg + 1); @@ -1328,7 +1328,8 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error) if (do_error) { if (**arg == ',') - semsg(_(e_no_white_space_allowed_before_str), ","); + semsg(_(e_no_white_space_allowed_before_str_str), + ",", *arg); else semsg(_("E696: Missing comma in List: %s"), *arg); } diff --git a/src/popupwin.c b/src/popupwin.c index 436238f9ba..47e7338b74 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -1941,7 +1941,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type) buf->b_p_ul = -1; // no undo buf->b_p_swf = FALSE; // no swap file buf->b_p_bl = FALSE; // unlisted buffer - buf->b_locked = TRUE; + buf->b_locked = TRUE; // prevent deleting the buffer // Avoid that 'buftype' is reset when this buffer is entered. buf->b_p_initialized = TRUE; diff --git a/src/scriptfile.c b/src/scriptfile.c index c8a23d55a3..82ae42a1a6 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -1319,6 +1319,9 @@ do_source( } // imports can be redefined once mark_imports_for_reload(sid); + + // reset version, "vim9script" may have been added or removed. + si->sn_version = 1; } else { @@ -1457,7 +1460,7 @@ almosttheend: if (si->sn_save_cpo != NULL) { set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, 0); - CLEAR_POINTER(si->sn_save_cpo); + VIM_CLEAR(si->sn_save_cpo); } restore_funccal(); diff --git a/src/structs.h b/src/structs.h index d6c0b15340..9ab14fd381 100644 --- a/src/structs.h +++ b/src/structs.h @@ -2636,6 +2636,8 @@ struct file_buffer int b_flags; // various BF_ flags int b_locked; // Buffer is being closed or referenced, don't // let autocommands wipe it out. + int b_locked_split; // Buffer is being closed, don't allow opening + // a new window with it. /* * b_ffname has the full path of the file (NULL for no name). diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index df2b9c89cf..5839691aa9 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -2761,15 +2761,15 @@ endfunc " Fuzzer found some strange combination that caused a crash. func Test_autocmd_normal_mess() - " TODO: why does this hang on Windows? + " For unknown reason this hangs on MS-Windows CheckNotMSWindows augroup aucmd_normal_test au BufLeave,BufWinLeave,BufHidden,BufUnload,BufDelete,BufWipeout * norm 7q/qc augroup END - o4 + call assert_fails('o4', 'E1159') silent! H - e xx + call assert_fails('e xx', 'E1159') normal G augroup aucmd_normal_test @@ -2778,6 +2778,9 @@ func Test_autocmd_normal_mess() endfunc func Test_autocmd_closing_cmdwin() + " For unknown reason this hangs on MS-Windows + CheckNotMSWindows + au BufWinLeave * nested q call assert_fails("norm 7q?\n", 'E855:') @@ -2791,8 +2794,8 @@ func Test_autocmd_vimgrep() au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9 augroup END - " TODO: if this is executed directly valgrind reports errors - call assert_fails('lv?a?', 'E926:') + %bwipe! + call assert_fails('lv ?a? foo', 'E926:') augroup aucmd_vimgrep au! diff --git a/src/testdir/test_bufline.vim b/src/testdir/test_bufline.vim index b2de198ef0..5df5288184 100644 --- a/src/testdir/test_bufline.vim +++ b/src/testdir/test_bufline.vim @@ -40,11 +40,13 @@ func Test_setbufline_getbufline() call assert_equal([], getbufline(b, 6)) call assert_equal([], getbufline(b, 2, 1)) - call setbufline(b, 2, [function('eval'), #{key: 123}, test_null_job()]) - call assert_equal(["function('eval')", - \ "{'key': 123}", - \ "no process"], - \ getbufline(b, 2, 4)) + if has('job') + call setbufline(b, 2, [function('eval'), #{key: 123}, test_null_job()]) + call assert_equal(["function('eval')", + \ "{'key': 123}", + \ "no process"], + \ getbufline(b, 2, 4)) + endif exe "bwipe! " . b endfunc diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim index 06839c0c51..eb36bd77a1 100644 --- a/src/testdir/test_vim9_builtin.vim +++ b/src/testdir/test_vim9_builtin.vim @@ -824,11 +824,13 @@ def Test_set_get_bufline() assert_equal([], getbufline(b, 6)) assert_equal([], getbufline(b, 2, 1)) - setbufline(b, 2, [function('eval'), {key: 123}, test_null_job()]) - assert_equal(["function('eval')", - "{'key': 123}", - "no process"], - getbufline(b, 2, 4)) + if has('job') + setbufline(b, 2, [function('eval'), {key: 123}, test_null_job()]) + assert_equal(["function('eval')", + "{'key': 123}", + "no process"], + getbufline(b, 2, 4)) + endif exe 'bwipe! ' .. b END diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 73ff693fa9..cdaba5af74 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -781,6 +781,16 @@ def Test_call_def_varargs() Func(1, 'a') END CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch') + + lines =<< trim END + vim9script + def Func( # some comment + ...l = [] + ) + echo l + enddef + END + CheckScriptFailure(lines, 'E1160:') enddef let s:value = '' diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index d25bb47aaa..42a0d61dd0 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -1743,6 +1743,21 @@ def Test_if_elseif_else_fails() CheckDefFailure(['endif'], 'E580:') CheckDefFailure(['if g:abool', 'elseif xxx'], 'E1001:') CheckDefFailure(['if true', 'echo 1'], 'E171:') + + var lines =<< trim END + var s = '' + if s = '' + endif + END + CheckDefFailure(lines, 'E488:') + + lines =<< trim END + var s = '' + if s == '' + elseif s = '' + endif + END + CheckDefFailure(lines, 'E488:') enddef let g:bool_true = v:true @@ -2190,6 +2205,10 @@ def Test_while_loop() result ..= cnt .. '_' endwhile assert_equal('1_3_', result) + + var s = '' + while s == 'x' #{comment} + endwhile enddef def Test_while_loop_fails() @@ -2200,6 +2219,13 @@ def Test_while_loop_fails() CheckDefFailure(['break'], 'E587:') CheckDefFailure(['if true', 'break'], 'E587:') CheckDefFailure(['while 1', 'echo 3'], 'E170:') + + var lines =<< trim END + var s = '' + while s = '' + endwhile + END + CheckDefFailure(lines, 'E488:') enddef def Test_interrupt_loop() @@ -3129,6 +3155,19 @@ def Test_restoring_cpo() delete('Xsourced') delete('Xclose') delete('Xdone') + + writefile(['vim9script'], 'XanotherScript') + set cpo=aABceFsMny> + edit XanotherScript + so % + assert_equal('aABceFsMny>', &cpo) + :1del + w + so % + assert_equal('aABceFsMny>', &cpo) + + delete('XanotherScript') + set cpo&vim enddef diff --git a/src/userfunc.c b/src/userfunc.c index bdf4064263..c9b15fd638 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -126,7 +126,7 @@ one_function_arg( ++p; if (!skip && !VIM_ISWHITE(*p)) { - semsg(_(e_white_space_required_after_str), ":"); + semsg(_(e_white_space_required_after_str_str), ":", p - 1); return arg; } type = skipwhite(p); @@ -241,6 +241,11 @@ get_function_args( skip); if (p == arg) break; + if (*skipwhite(p) == '=') + { + emsg(_(e_cannot_use_default_for_variable_arguments)); + break; + } } } else @@ -297,7 +302,7 @@ get_function_args( if (!skip && in_vim9script() && !IS_WHITE_OR_NUL(*p) && *p != endchar) { - semsg(_(e_white_space_required_after_str), ","); + semsg(_(e_white_space_required_after_str_str), ",", p - 1); goto err_ret; } } @@ -487,7 +492,7 @@ skip_arrow( if (white_error != NULL && !VIM_ISWHITE(s[1])) { *white_error = TRUE; - semsg(_(e_white_space_required_after_str), ":"); + semsg(_(e_white_space_required_after_str_str), ":", s); return NULL; } s = skipwhite(s + 1); @@ -873,7 +878,7 @@ get_func_tv( { if (*argp != ',' && *skipwhite(argp) == ',') { - semsg(_(e_no_white_space_allowed_before_str), ","); + semsg(_(e_no_white_space_allowed_before_str_str), ",", argp); ret = FAIL; break; } @@ -884,7 +889,7 @@ get_func_tv( break; if (vim9script && !IS_WHITE_OR_NUL(argp[1])) { - semsg(_(e_white_space_required_after_str), ","); + semsg(_(e_white_space_required_after_str_str), ",", argp); ret = FAIL; break; } @@ -3209,7 +3214,7 @@ define_function(exarg_T *eap, char_u *name_arg) if ((vim9script || eap->cmdidx == CMD_def) && VIM_ISWHITE(p[-1])) { - semsg(_(e_no_white_space_allowed_before_str), "("); + semsg(_(e_no_white_space_allowed_before_str_str), "(", p - 1); goto ret_free; } diff --git a/src/version.c b/src/version.c index b6889cf6ff..1951e15d45 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,28 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2486, +/**/ + 2485, +/**/ + 2484, +/**/ + 2483, +/**/ + 2482, +/**/ + 2481, +/**/ + 2480, +/**/ + 2479, +/**/ + 2478, +/**/ + 2477, +/**/ + 2476, /**/ 2475, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index 6a1d8d9e78..512f7246c2 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2800,14 +2800,14 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount) if (*p != ',' && *skipwhite(p) == ',') { - semsg(_(e_no_white_space_allowed_before_str), ","); + semsg(_(e_no_white_space_allowed_before_str_str), ",", p); p = skipwhite(p); } if (*p == ',') { ++p; if (*p != NUL && !VIM_ISWHITE(*p)) - semsg(_(e_white_space_required_after_str), ","); + semsg(_(e_white_space_required_after_str_str), ",", p - 1); } else must_end = TRUE; @@ -3055,7 +3055,7 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) } if (*p == ',') { - semsg(_(e_no_white_space_allowed_before_str), ","); + semsg(_(e_no_white_space_allowed_before_str_str), ",", p); return FAIL; } if (*p == ']') @@ -3073,7 +3073,7 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) ++p; if (*p != ']' && !IS_WHITE_OR_NUL(*p)) { - semsg(_(e_white_space_required_after_str), ","); + semsg(_(e_white_space_required_after_str_str), ",", p - 1); return FAIL; } } @@ -3234,7 +3234,7 @@ compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) if (**arg != ':') { if (*skipwhite(*arg) == ':') - semsg(_(e_no_white_space_allowed_before_str), ":"); + semsg(_(e_no_white_space_allowed_before_str_str), ":", *arg); else semsg(_(e_missing_dict_colon), *arg); return FAIL; @@ -3242,7 +3242,7 @@ compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) whitep = *arg + 1; if (!IS_WHITE_OR_NUL(*whitep)) { - semsg(_(e_white_space_required_after_str), ":"); + semsg(_(e_white_space_required_after_str_str), ":", *arg); return FAIL; } @@ -3273,16 +3273,16 @@ compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) } if (IS_WHITE_OR_NUL(*whitep)) { - semsg(_(e_no_white_space_allowed_before_str), ","); + semsg(_(e_no_white_space_allowed_before_str_str), ",", whitep); return FAIL; } whitep = *arg + 1; if (!IS_WHITE_OR_NUL(*whitep)) { - semsg(_(e_white_space_required_after_str), ","); + semsg(_(e_white_space_required_after_str_str), ",", *arg); return FAIL; } - *arg = skipwhite(*arg + 1); + *arg = skipwhite(whitep); } *arg = *arg + 1; @@ -4270,7 +4270,7 @@ compile_expr7t(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) if (**arg != '>') { if (*skipwhite(*arg) == '>') - semsg(_(e_no_white_space_allowed_before_str), ">"); + semsg(_(e_no_white_space_allowed_before_str_str), ">", *arg); else emsg(_(e_missing_gt)); return FAIL; @@ -5711,7 +5711,7 @@ compile_lhs( // parse optional type: "let var: type = expr" if (!VIM_ISWHITE(var_end[1])) { - semsg(_(e_white_space_required_after_str), ":"); + semsg(_(e_white_space_required_after_str_str), ":", var_end); return FAIL; } p = skipwhite(var_end + 1); @@ -6701,6 +6701,11 @@ compile_if(char_u *arg, cctx_T *cctx) clear_ppconst(&ppconst); return NULL; } + if (!ends_excmd2(arg, skipwhite(p))) + { + semsg(_(e_trailing_arg), p); + return NULL; + } if (cctx->ctx_skip == SKIP_YES) clear_ppconst(&ppconst); else if (instr->ga_len == instr_count && ppconst.pp_used == 1) @@ -6825,6 +6830,11 @@ compile_elseif(char_u *arg, cctx_T *cctx) return NULL; } cctx->ctx_skip = save_skip; + if (!ends_excmd2(arg, skipwhite(p))) + { + semsg(_(e_trailing_arg), p); + return NULL; + } if (scope->se_skip_save == SKIP_YES) clear_ppconst(&ppconst); else if (instr->ga_len == instr_count && ppconst.pp_used == 1) @@ -7237,6 +7247,11 @@ compile_while(char_u *arg, cctx_T *cctx) // compile "expr" if (compile_expr0(&p, cctx) == FAIL) return NULL; + if (!ends_excmd2(arg, skipwhite(p))) + { + semsg(_(e_trailing_arg), p); + return NULL; + } if (bool_on_stack(cctx) == FAIL) return FAIL; diff --git a/src/vim9script.c b/src/vim9script.c index 010b4bfdb3..387c9bedc4 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -629,7 +629,7 @@ vim9_declare_scriptvar(exarg_T *eap, char_u *arg) } if (!VIM_ISWHITE(p[1])) { - semsg(_(e_white_space_required_after_str), ":"); + semsg(_(e_white_space_required_after_str_str), ":", p); return arg + STRLEN(arg); } name = vim_strnsave(arg, p - arg); diff --git a/src/vim9type.c b/src/vim9type.c index 1374cee1b1..1a20ef5796 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -638,7 +638,7 @@ parse_type_member( if (give_error) { if (*skipwhite(*arg) == '<') - semsg(_(e_no_white_space_allowed_before_str), "<"); + semsg(_(e_no_white_space_allowed_before_str_str), "<", *arg); else emsg(_(e_missing_type)); } @@ -779,7 +779,8 @@ parse_type(char_u **arg, garray_T *type_gap, int give_error) if (*p != ',' && *skipwhite(p) == ',') { if (give_error) - semsg(_(e_no_white_space_allowed_before_str), ","); + semsg(_(e_no_white_space_allowed_before_str_str), + ",", p); return NULL; } if (*p == ',') @@ -788,7 +789,8 @@ parse_type(char_u **arg, garray_T *type_gap, int give_error) if (!VIM_ISWHITE(*p)) { if (give_error) - semsg(_(e_white_space_required_after_str), ","); + semsg(_(e_white_space_required_after_str_str), + ",", p - 1); return NULL; } } @@ -815,7 +817,8 @@ parse_type(char_u **arg, garray_T *type_gap, int give_error) // parse return type ++*arg; if (!VIM_ISWHITE(**arg) && give_error) - semsg(_(e_white_space_required_after_str), ":"); + semsg(_(e_white_space_required_after_str_str), + ":", *arg - 1); *arg = skipwhite(*arg); ret_type = parse_type(arg, type_gap, give_error); if (ret_type == NULL) diff --git a/src/window.c b/src/window.c index 2c085a6480..17f36a9932 100644 --- a/src/window.c +++ b/src/window.c @@ -769,6 +769,11 @@ check_split_disallowed() emsg(_("E242: Can't split a window while closing another")); return FAIL; } + if (curwin->w_buffer->b_locked_split) + { + emsg(_(e_cannot_split_window_when_closing_buffer)); + return FAIL; + } return OK; } @@ -793,6 +798,9 @@ win_split(int size, int flags) if (ERROR_IF_ANY_POPUP_WINDOW) return FAIL; + if (check_split_disallowed() == FAIL) + return FAIL; + // When the ":tab" modifier was used open a new tab page instead. if (may_open_tabpage() == OK) return OK; @@ -804,8 +812,6 @@ win_split(int size, int flags) emsg(_("E442: Can't split topleft and botright at the same time")); return FAIL; } - if (check_split_disallowed() == FAIL) - return FAIL; // When creating the help window make a snapshot of the window layout. // Otherwise clear the snapshot, it's now invalid.