aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 7e1eae9632..f937450107 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -94,11 +94,19 @@ static char *e_buflocked = N_("E937: Attempt to delete a buffer that is in use")
// Number of times free_buffer() was called.
static int buf_free_count = 0;
+static int top_file_num = 1; ///< highest file number
+
typedef enum {
kBffClearWinInfo = 1,
kBffInitChangedtick = 2,
} BufFreeFlags;
+/// @return the highest possible buffer number
+int get_highest_fnum(void)
+{
+ return top_file_num - 1;
+}
+
/// Read data from buffer for retrying.
///
/// @param read_stdin read file from stdin, otherwise fifo
@@ -443,6 +451,7 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last, bool i
return false;
}
+ // check no autocommands closed the window
if (win != NULL // Avoid bogus clang warning.
&& win_valid_any_tab(win)) {
// Set b_last_cursor when closing the last window for the buffer.
@@ -1643,8 +1652,6 @@ void no_write_message_nobang(const buf_T *const buf)
// functions for dealing with the buffer list
//
-static int top_file_num = 1; ///< highest file number
-
/// Initialize b:changedtick and changedtick_val attribute
///
/// @param[out] buf Buffer to initialize for.
@@ -3136,18 +3143,16 @@ void maketitle(void)
if (*p_titlestring != NUL) {
if (stl_syntax & STL_IN_TITLE) {
int use_sandbox = false;
- int save_called_emsg = called_emsg;
+ const int called_emsg_before = called_emsg;
use_sandbox = was_set_insecurely(curwin, "titlestring", 0);
- called_emsg = false;
build_stl_str_hl(curwin, buf, sizeof(buf),
(char *)p_titlestring, use_sandbox,
0, maxlen, NULL, NULL);
title_str = buf;
- if (called_emsg) {
+ if (called_emsg > called_emsg_before) {
set_string_option_direct("titlestring", -1, "", OPT_FREE, SID_ERROR);
}
- called_emsg |= save_called_emsg;
} else {
title_str = (char *)p_titlestring;
}
@@ -3252,17 +3257,15 @@ void maketitle(void)
if (*p_iconstring != NUL) {
if (stl_syntax & STL_IN_ICON) {
int use_sandbox = false;
- int save_called_emsg = called_emsg;
+ const int called_emsg_before = called_emsg;
use_sandbox = was_set_insecurely(curwin, "iconstring", 0);
- called_emsg = false;
build_stl_str_hl(curwin, icon_str, sizeof(buf),
(char *)p_iconstring, use_sandbox,
0, 0, NULL, NULL);
- if (called_emsg) {
+ if (called_emsg > called_emsg_before) {
set_string_option_direct("iconstring", -1, "", OPT_FREE, SID_ERROR);
}
- called_emsg |= save_called_emsg;
} else {
icon_str = (char *)p_iconstring;
}
@@ -5268,9 +5271,9 @@ bool bt_terminal(const buf_T *const buf)
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.
-bool bt_nofile(const buf_T *const buf)
+bool bt_nofilename(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')
@@ -5279,6 +5282,13 @@ bool bt_nofile(const buf_T *const buf)
|| 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"
/// buffer.
bool bt_dontwrite(const buf_T *const buf)
@@ -5330,7 +5340,7 @@ char *buf_spname(buf_T *buf)
}
// There is no _file_ when 'buftype' is "nofile", b_sfname
// contains the name as specified by the user.
- if (bt_nofile(buf)) {
+ if (bt_nofilename(buf)) {
if (buf->b_fname != NULL) {
return buf->b_fname;
}