mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 14:28:18 +00:00
vim-patch:8.1.1547: functionality of bt_nofile() is confusing
Problem: Functionality of bt_nofile() is confusing.
Solution: Split into bt_nofile() and bt_nofilename().
26910de8b0
This commit is contained in:
@@ -5271,9 +5271,9 @@ bool bt_terminal(const buf_T *const buf)
|
|||||||
return buf != NULL && buf->b_p_bt[0] == 't';
|
return buf != NULL && buf->b_p_bt[0] == 't';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return true if "buf" is a "nofile", "acwrite", "terminal" or "prompt" /
|
/// @return true if "buf" is a "nofile", "acwrite", "terminal" or "prompt"
|
||||||
/// buffer. This means the buffer name is not a file name.
|
/// buffer. This means the buffer name is not a file name.
|
||||||
bool bt_nofile(const buf_T *const buf)
|
bool bt_nofilename(const buf_T *const buf)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
|
return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
|
||||||
@@ -5282,6 +5282,13 @@ bool bt_nofile(const buf_T *const buf)
|
|||||||
|| buf->b_p_bt[0] == 'p');
|
|| buf->b_p_bt[0] == 'p');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @return true if "buf" has 'buftype' set to "nofile".
|
||||||
|
bool bt_nofile(const buf_T *const buf)
|
||||||
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
|
{
|
||||||
|
return buf != NULL && buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f';
|
||||||
|
}
|
||||||
|
|
||||||
/// @return true if "buf" is a "nowrite", "nofile", "terminal" or "prompt"
|
/// @return true if "buf" is a "nowrite", "nofile", "terminal" or "prompt"
|
||||||
/// buffer.
|
/// buffer.
|
||||||
bool bt_dontwrite(const buf_T *const buf)
|
bool bt_dontwrite(const buf_T *const buf)
|
||||||
@@ -5333,7 +5340,7 @@ char *buf_spname(buf_T *buf)
|
|||||||
}
|
}
|
||||||
// There is no _file_ when 'buftype' is "nofile", b_sfname
|
// There is no _file_ when 'buftype' is "nofile", b_sfname
|
||||||
// contains the name as specified by the user.
|
// contains the name as specified by the user.
|
||||||
if (bt_nofile(buf)) {
|
if (bt_nofilename(buf)) {
|
||||||
if (buf->b_fname != NULL) {
|
if (buf->b_fname != NULL) {
|
||||||
return buf->b_fname;
|
return buf->b_fname;
|
||||||
}
|
}
|
||||||
|
@@ -482,7 +482,7 @@ static buf_T *find_buffer(typval_T *avar)
|
|||||||
* buffer, these don't use the full path. */
|
* buffer, these don't use the full path. */
|
||||||
FOR_ALL_BUFFERS(bp) {
|
FOR_ALL_BUFFERS(bp) {
|
||||||
if (bp->b_fname != NULL
|
if (bp->b_fname != NULL
|
||||||
&& (path_with_url(bp->b_fname) || bt_nofile(bp))
|
&& (path_with_url(bp->b_fname) || bt_nofilename(bp))
|
||||||
&& STRCMP(bp->b_fname, avar->vval.v_string) == 0) {
|
&& STRCMP(bp->b_fname, avar->vval.v_string) == 0) {
|
||||||
buf = bp;
|
buf = bp;
|
||||||
break;
|
break;
|
||||||
|
@@ -1990,7 +1990,7 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
|
|||||||
&& 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_nofile(buf)
|
&& !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
|
||||||
|
@@ -187,7 +187,7 @@ static int ses_do_win(win_T *wp)
|
|||||||
}
|
}
|
||||||
if (wp->w_buffer->b_fname == NULL
|
if (wp->w_buffer->b_fname == NULL
|
||||||
// When 'buftype' is "nofile" can't restore the window contents.
|
// When 'buftype' is "nofile" can't restore the window contents.
|
||||||
|| (!wp->w_buffer->terminal && bt_nofile(wp->w_buffer))) {
|
|| (!wp->w_buffer->terminal && bt_nofilename(wp->w_buffer))) {
|
||||||
return ssop_flags & SSOP_BLANK;
|
return ssop_flags & SSOP_BLANK;
|
||||||
}
|
}
|
||||||
if (bt_help(wp->w_buffer)) {
|
if (bt_help(wp->w_buffer)) {
|
||||||
@@ -363,7 +363,7 @@ static int put_view(FILE *fd, win_T *wp, int add_edit, unsigned *flagp, int curr
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
} else if (wp->w_buffer->b_ffname != NULL
|
} else if (wp->w_buffer->b_ffname != NULL
|
||||||
&& (!bt_nofile(wp->w_buffer) || wp->w_buffer->terminal)) {
|
&& (!bt_nofilename(wp->w_buffer) || wp->w_buffer->terminal)) {
|
||||||
// Load the file.
|
// Load the file.
|
||||||
|
|
||||||
// Editing a file in this buffer: use ":edit file".
|
// Editing a file in this buffer: use ":edit file".
|
||||||
@@ -706,7 +706,7 @@ static int makeopens(FILE *fd, char_u *dirnow)
|
|||||||
if (ses_do_win(wp)
|
if (ses_do_win(wp)
|
||||||
&& wp->w_buffer->b_ffname != NULL
|
&& wp->w_buffer->b_ffname != NULL
|
||||||
&& !bt_help(wp->w_buffer)
|
&& !bt_help(wp->w_buffer)
|
||||||
&& !bt_nofile(wp->w_buffer)) {
|
&& !bt_nofilename(wp->w_buffer)) {
|
||||||
if (need_tabnext && put_line(fd, "tabnext") == FAIL) {
|
if (need_tabnext && put_line(fd, "tabnext") == FAIL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
@@ -2286,7 +2286,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
|
|||||||
&& reset_changed
|
&& reset_changed
|
||||||
&& whole
|
&& whole
|
||||||
&& buf == curbuf
|
&& buf == curbuf
|
||||||
&& !bt_nofile(buf)
|
&& !bt_nofilename(buf)
|
||||||
&& !filtering
|
&& !filtering
|
||||||
&& (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL)
|
&& (!append || vim_strchr(p_cpo, CPO_FNAMEAPP) != NULL)
|
||||||
&& vim_strchr(p_cpo, CPO_FNAMEW) != NULL) {
|
&& vim_strchr(p_cpo, CPO_FNAMEW) != NULL) {
|
||||||
@@ -2360,22 +2360,22 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
|
|||||||
|
|
||||||
if (append) {
|
if (append) {
|
||||||
if (!(did_cmd = apply_autocmds_exarg(EVENT_FILEAPPENDCMD,
|
if (!(did_cmd = apply_autocmds_exarg(EVENT_FILEAPPENDCMD,
|
||||||
sfname, sfname, FALSE, curbuf, eap))) {
|
sfname, sfname, false, curbuf, eap))) {
|
||||||
if (overwriting && bt_nofile(curbuf)) {
|
if (overwriting && bt_nofilename(curbuf)) {
|
||||||
nofile_err = TRUE;
|
nofile_err = true;
|
||||||
} else {
|
} else {
|
||||||
apply_autocmds_exarg(EVENT_FILEAPPENDPRE,
|
apply_autocmds_exarg(EVENT_FILEAPPENDPRE,
|
||||||
sfname, sfname, FALSE, curbuf, eap);
|
sfname, sfname, false, curbuf, eap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (filtering) {
|
} else if (filtering) {
|
||||||
apply_autocmds_exarg(EVENT_FILTERWRITEPRE,
|
apply_autocmds_exarg(EVENT_FILTERWRITEPRE,
|
||||||
NULL, sfname, FALSE, curbuf, eap);
|
NULL, sfname, false, curbuf, eap);
|
||||||
} else if (reset_changed && whole) {
|
} else if (reset_changed && whole) {
|
||||||
int was_changed = curbufIsChanged();
|
int was_changed = curbufIsChanged();
|
||||||
|
|
||||||
did_cmd = apply_autocmds_exarg(EVENT_BUFWRITECMD,
|
did_cmd = apply_autocmds_exarg(EVENT_BUFWRITECMD,
|
||||||
sfname, sfname, FALSE, curbuf, eap);
|
sfname, sfname, false, curbuf, eap);
|
||||||
if (did_cmd) {
|
if (did_cmd) {
|
||||||
if (was_changed && !curbufIsChanged()) {
|
if (was_changed && !curbufIsChanged()) {
|
||||||
/* Written everything correctly and BufWriteCmd has reset
|
/* Written everything correctly and BufWriteCmd has reset
|
||||||
@@ -2385,21 +2385,21 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
|
|||||||
u_update_save_nr(curbuf);
|
u_update_save_nr(curbuf);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (overwriting && bt_nofile(curbuf)) {
|
if (overwriting && bt_nofilename(curbuf)) {
|
||||||
nofile_err = TRUE;
|
nofile_err = true;
|
||||||
} else {
|
} else {
|
||||||
apply_autocmds_exarg(EVENT_BUFWRITEPRE,
|
apply_autocmds_exarg(EVENT_BUFWRITEPRE,
|
||||||
sfname, sfname, FALSE, curbuf, eap);
|
sfname, sfname, false, curbuf, eap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!(did_cmd = apply_autocmds_exarg(EVENT_FILEWRITECMD,
|
if (!(did_cmd = apply_autocmds_exarg(EVENT_FILEWRITECMD,
|
||||||
sfname, sfname, FALSE, curbuf, eap))) {
|
sfname, sfname, false, curbuf, eap))) {
|
||||||
if (overwriting && bt_nofile(curbuf)) {
|
if (overwriting && bt_nofilename(curbuf)) {
|
||||||
nofile_err = TRUE;
|
nofile_err = true;
|
||||||
} else {
|
} else {
|
||||||
apply_autocmds_exarg(EVENT_FILEWRITEPRE,
|
apply_autocmds_exarg(EVENT_FILEWRITEPRE,
|
||||||
sfname, sfname, FALSE, curbuf, eap);
|
sfname, sfname, false, curbuf, eap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4306,7 +4306,7 @@ void shorten_buf_fname(buf_T *buf, char_u *dirname, int force)
|
|||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (buf->b_fname != NULL
|
if (buf->b_fname != NULL
|
||||||
&& !bt_nofile(buf)
|
&& !bt_nofilename(buf)
|
||||||
&& !path_with_url(buf->b_fname)
|
&& !path_with_url(buf->b_fname)
|
||||||
&& (force
|
&& (force
|
||||||
|| buf->b_sfname == NULL
|
|| buf->b_sfname == NULL
|
||||||
|
@@ -726,8 +726,7 @@ static int pum_set_selected(int n, int repeat)
|
|||||||
if (!resized
|
if (!resized
|
||||||
&& (curbuf->b_nwindows == 1)
|
&& (curbuf->b_nwindows == 1)
|
||||||
&& (curbuf->b_fname == NULL)
|
&& (curbuf->b_fname == NULL)
|
||||||
&& (curbuf->b_p_bt[0] == 'n')
|
&& bt_nofile(curbuf)
|
||||||
&& (curbuf->b_p_bt[2] == 'f')
|
|
||||||
&& (curbuf->b_p_bh[0] == 'w')) {
|
&& (curbuf->b_p_bh[0] == 'w')) {
|
||||||
// Already a "wipeout" buffer, make it empty.
|
// Already a "wipeout" buffer, make it empty.
|
||||||
while (!buf_is_empty(curbuf)) {
|
while (!buf_is_empty(curbuf)) {
|
||||||
|
Reference in New Issue
Block a user