mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.0403: when 'buftype' is "nofile" there is no overwrite check
Problem: When 'buftype' is "nofile" there is no overwrite check.
Solution: Also check for existing file when 'buftype' is set.
(closes vim/vim#5807)
a3a9c8ef69
Nvim doesn't have buftype=popup and doesn't allow buftype=terminal for
non-terminal buffer.
This commit is contained in:
parent
4a64cdafd6
commit
0cf5cd1ac9
@ -1980,17 +1980,14 @@ theend:
|
|||||||
/// @return OK if it's OK, FAIL if it is not.
|
/// @return OK if it's OK, FAIL if it is not.
|
||||||
int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int other)
|
int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int other)
|
||||||
{
|
{
|
||||||
/*
|
// Write to another file or b_flags set or not writing the whole file:
|
||||||
* write to other file or b_flags set or not writing the whole file:
|
// overwriting only allowed with '!'
|
||||||
* overwriting only allowed with '!'
|
|
||||||
*/
|
|
||||||
if ((other
|
if ((other
|
||||||
|| (buf->b_flags & BF_NOTEDITED)
|
|| (buf->b_flags & BF_NOTEDITED)
|
||||||
|| ((buf->b_flags & BF_NEW)
|
|| ((buf->b_flags & BF_NEW)
|
||||||
&& vim_strchr(p_cpo, CPO_OVERNEW) == NULL)
|
&& vim_strchr(p_cpo, CPO_OVERNEW) == NULL)
|
||||||
|| (buf->b_flags & BF_READERR))
|
|| (buf->b_flags & BF_READERR))
|
||||||
&& !p_wa
|
&& !p_wa
|
||||||
&& !bt_nofilename(buf)
|
|
||||||
&& os_path_exists((char_u *)ffname)) {
|
&& os_path_exists((char_u *)ffname)) {
|
||||||
if (!eap->forceit && !eap->append) {
|
if (!eap->forceit && !eap->append) {
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
|
@ -741,7 +741,16 @@ func Test_buftype()
|
|||||||
call setline(1, ['L1'])
|
call setline(1, ['L1'])
|
||||||
set buftype=nowrite
|
set buftype=nowrite
|
||||||
call assert_fails('write', 'E382:')
|
call assert_fails('write', 'E382:')
|
||||||
close!
|
|
||||||
|
" for val in ['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help', 'terminal', 'prompt', 'popup']
|
||||||
|
for val in ['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help', 'prompt']
|
||||||
|
exe 'set buftype=' .. val
|
||||||
|
call writefile(['something'], 'XBuftype')
|
||||||
|
call assert_fails('write XBuftype', 'E13:', 'with buftype=' .. val)
|
||||||
|
endfor
|
||||||
|
|
||||||
|
call delete('XBuftype')
|
||||||
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for the 'shellquote' option
|
" Test for the 'shellquote' option
|
||||||
|
Loading…
Reference in New Issue
Block a user