mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 21:25:04 -07:00
Merge pull request #30008 from zeertzjq/vim-8.2.3476
vim-patch:8.2.{3476,3477}
This commit is contained in:
commit
2f1ea1133a
@ -2959,7 +2959,17 @@ int setfname(buf_T *buf, char *ffname_arg, char *sfname_arg, bool message)
|
|||||||
obuf = buflist_findname_file_id(ffname, &file_id, file_id_valid);
|
obuf = buflist_findname_file_id(ffname, &file_id, file_id_valid);
|
||||||
}
|
}
|
||||||
if (obuf != NULL && obuf != buf) {
|
if (obuf != NULL && obuf != buf) {
|
||||||
if (obuf->b_ml.ml_mfp != NULL) { // it's loaded, fail
|
bool in_use = false;
|
||||||
|
|
||||||
|
// during startup a window may use a buffer that is not loaded yet
|
||||||
|
FOR_ALL_TAB_WINDOWS(tab, win) {
|
||||||
|
if (win->w_buffer == obuf) {
|
||||||
|
in_use = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// it's loaded or used in a window, fail
|
||||||
|
if (obuf->b_ml.ml_mfp != NULL || in_use) {
|
||||||
if (message) {
|
if (message) {
|
||||||
emsg(_("E95: Buffer with this name already exists"));
|
emsg(_("E95: Buffer with this name already exists"));
|
||||||
}
|
}
|
||||||
|
@ -1276,4 +1276,36 @@ func Test_write_in_vimrc()
|
|||||||
call delete('Xvimrc')
|
call delete('Xvimrc')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_echo_true_in_cmd()
|
||||||
|
CheckNotGui
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
echo v:true
|
||||||
|
call writefile(['done'], 'Xresult')
|
||||||
|
quit
|
||||||
|
END
|
||||||
|
call writefile(lines, 'Xscript')
|
||||||
|
if RunVim([], [], '--cmd "source Xscript"')
|
||||||
|
call assert_equal(['done'], readfile('Xresult'))
|
||||||
|
endif
|
||||||
|
call delete('Xscript')
|
||||||
|
call delete('Xresult')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_rename_buffer_on_startup()
|
||||||
|
CheckUnix
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
call writefile(['done'], 'Xresult')
|
||||||
|
qa!
|
||||||
|
END
|
||||||
|
call writefile(lines, 'Xscript')
|
||||||
|
if RunVim([], [], "--clean -e -s --cmd 'file x|new|file x' --cmd 'so Xscript'")
|
||||||
|
call assert_equal(['done'], readfile('Xresult'))
|
||||||
|
endif
|
||||||
|
call delete('Xscript')
|
||||||
|
call delete('Xresult')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user