aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/clint.py13
-rw-r--r--src/nvim/buffer.c6
-rw-r--r--src/nvim/event/process.c4
-rw-r--r--src/nvim/event/stream.c5
-rw-r--r--src/nvim/ex_cmds.c68
-rw-r--r--src/nvim/ex_docmd.c5
-rw-r--r--src/nvim/generators/gen_eval.lua2
-rw-r--r--src/nvim/macros.h6
-rw-r--r--src/nvim/move.c8
-rw-r--r--src/nvim/normal.c8
-rw-r--r--src/nvim/ops.c4
-rw-r--r--src/nvim/os/process.c19
-rw-r--r--src/nvim/testdir/runnvim.vim5
-rw-r--r--src/nvim/testdir/test_arabic.vim48
-rw-r--r--src/nvim/testdir/test_compiler.vim6
-rw-r--r--src/nvim/testdir/test_makeencoding.py4
-rw-r--r--src/nvim/testdir/test_normal.vim15
-rw-r--r--src/nvim/testdir/test_registers.vim9
-rw-r--r--src/nvim/undo.c13
19 files changed, 116 insertions, 132 deletions
diff --git a/src/clint.py b/src/clint.py
index 3994ffbb14..675b67ccef 100755
--- a/src/clint.py
+++ b/src/clint.py
@@ -2610,9 +2610,13 @@ def CheckBraces(filename, clean_lines, linenum, error):
'Brace starting function body must be placed on its own line')
else:
func_start_linenum = end_linenum + 1
- while not clean_lines.lines[func_start_linenum] == '{':
- attrline = Match(r'^((?!# *define).*?)(?:FUNC_ATTR|FUNC_API|REAL_FATTR)_\w+(?:\(\d+(, \d+)*\))?',
- clean_lines.lines[func_start_linenum])
+ while not clean_lines.lines[func_start_linenum] == "{":
+ attrline = Match(
+ r'^((?!# *define).*?)'
+ r'(?:FUNC_ATTR|FUNC_API|REAL_FATTR)_\w+'
+ r'(?:\(\d+(, \d+)*\))?',
+ clean_lines.lines[func_start_linenum],
+ )
if attrline:
if len(attrline.group(1)) != 2:
error(filename, func_start_linenum,
@@ -3182,7 +3186,8 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
r'|li_(?:next|prev|tv))\b', line)
if match:
error(filename, linenum, 'runtime/deprecated', 4,
- 'Accessing list_T internals directly is prohibited (hint: see commit d46e37cb4c71)')
+ 'Accessing list_T internals directly is prohibited '
+ '(hint: see commit d46e37cb4c71)')
# Check for suspicious usage of "if" like
# } if (a == b) {
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 34fe52c10e..89f1e33a86 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -5171,18 +5171,21 @@ chk_modeline(
// Return true if "buf" is a help buffer.
bool bt_help(const buf_T *const buf)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return buf != NULL && buf->b_help;
}
// Return true if "buf" is the quickfix buffer.
bool bt_quickfix(const buf_T *const buf)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return buf != NULL && buf->b_p_bt[0] == 'q';
}
// Return true if "buf" is a terminal buffer.
bool bt_terminal(const buf_T *const buf)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return buf != NULL && buf->b_p_bt[0] == 't';
}
@@ -5190,6 +5193,7 @@ bool bt_terminal(const buf_T *const buf)
// Return true if "buf" is a "nofile", "acwrite" or "terminal" buffer.
// This means the buffer name is not a file name.
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')
|| buf->b_p_bt[0] == 'a' || buf->terminal);
@@ -5197,11 +5201,13 @@ bool bt_nofile(const buf_T *const buf)
// Return true if "buf" is a "nowrite", "nofile" or "terminal" buffer.
bool bt_dontwrite(const buf_T *const buf)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return buf != NULL && (buf->b_p_bt[0] == 'n' || buf->terminal);
}
bool bt_dontwrite_msg(const buf_T *const buf)
+ FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
if (bt_dontwrite(buf)) {
EMSG(_("E382: Cannot write, 'buftype' option is set"));
diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c
index 990dee0c7f..4410deadef 100644
--- a/src/nvim/event/process.c
+++ b/src/nvim/event/process.c
@@ -223,10 +223,6 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL
switch (proc->type) {
case kProcessTypeUv:
- // Close the process's stdin. If the process doesn't close its own
- // stdout/stderr, they will be closed when it exits(possibly due to being
- // terminated after a timeout)
- stream_may_close(&proc->in);
os_proc_tree_kill(proc->pid, SIGTERM);
break;
case kProcessTypePty:
diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c
index 7aaac0b03b..7c8014dead 100644
--- a/src/nvim/event/stream.c
+++ b/src/nvim/event/stream.c
@@ -113,6 +113,11 @@ void stream_close_handle(Stream *stream)
FUNC_ATTR_NONNULL_ALL
{
if (stream->uvstream) {
+ if (uv_stream_get_write_queue_size(stream->uvstream) > 0) {
+ WLOG("closed Stream (%p) with %zu unwritten bytes",
+ (void *)stream,
+ uv_stream_get_write_queue_size(stream->uvstream));
+ }
uv_close((uv_handle_t *)stream->uvstream, close_cb);
} else {
uv_close((uv_handle_t *)&stream->uv.idle, close_cb);
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 9a2b683bac..2ea6937126 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -5230,10 +5230,8 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
return;
}
- /*
- * If using the "++t" argument or generating tags for "$VIMRUNTIME/doc"
- * add the "help-tags" tag.
- */
+ // If using the "++t" argument or generating tags for "$VIMRUNTIME/doc"
+ // add the "help-tags" tag.
ga_init(&ga, (int)sizeof(char_u *), 100);
if (add_help_tags
|| path_full_compare((char_u *)"$VIMRUNTIME/doc",
@@ -5243,9 +5241,7 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
GA_APPEND(char_u *, &ga, s);
}
- /*
- * Go over all the files and extract the tags.
- */
+ // Go over all the files and extract the tags.
for (int fi = 0; fi < filecount && !got_int; fi++) {
FILE *const fd = os_fopen((char *)files[fi], "r");
if (fd == NULL) {
@@ -5285,21 +5281,19 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
}
firstline = false;
}
- p1 = vim_strchr(IObuff, '*'); /* find first '*' */
+ p1 = vim_strchr(IObuff, '*'); // find first '*'
while (p1 != NULL) {
p2 = (char_u *)strchr((const char *)p1 + 1, '*'); // Find second '*'.
- if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**".
+ if (p2 != NULL && p2 > p1 + 1) { // Skip "*" and "**".
for (s = p1 + 1; s < p2; s++) {
if (*s == ' ' || *s == '\t' || *s == '|') {
break;
}
}
- /*
- * Only accept a *tag* when it consists of valid
- * characters, there is white space before it and is
- * followed by a white character or end-of-line.
- */
+ // Only accept a *tag* when it consists of valid
+ // characters, there is white space before it and is
+ // followed by a white character or end-of-line.
if (s == p2
&& (p1 == IObuff || p1[-1] == ' ' || p1[-1] == '\t')
&& (vim_strchr((char_u *)" \t\n\r", s[1]) != NULL
@@ -5310,7 +5304,7 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
GA_APPEND(char_u *, &ga, s);
sprintf((char *)s, "%s\t%s", p1, fname);
- /* find next '*' */
+ // find next '*'
p2 = vim_strchr(p2 + 1, '*');
}
}
@@ -5324,18 +5318,12 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
FreeWild(filecount, files);
- if (!got_int) {
- /*
- * Sort the tags.
- */
- if (ga.ga_data != NULL) {
- sort_strings((char_u **)ga.ga_data, ga.ga_len);
- }
+ if (!got_int && ga.ga_data != NULL) {
+ // Sort the tags.
+ sort_strings((char_u **)ga.ga_data, ga.ga_len);
- /*
- * Check for duplicates.
- */
- for (int i = 1; i < ga.ga_len; ++i) {
+ // Check for duplicates.
+ for (int i = 1; i < ga.ga_len; i++) {
p1 = ((char_u **)ga.ga_data)[i - 1];
p2 = ((char_u **)ga.ga_data)[i];
while (*p1 == *p2) {
@@ -5357,31 +5345,31 @@ static void helptags_one(char_u *const dir, const char_u *const ext,
fprintf(fd_tags, "!_TAG_FILE_ENCODING\tutf-8\t//\n");
}
- /*
- * Write the tags into the file.
- */
- for (int i = 0; i < ga.ga_len; ++i) {
+ // Write the tags into the file.
+ for (int i = 0; i < ga.ga_len; i++) {
s = ((char_u **)ga.ga_data)[i];
- if (STRNCMP(s, "help-tags\t", 10) == 0)
- /* help-tags entry was added in formatted form */
+ if (STRNCMP(s, "help-tags\t", 10) == 0) {
+ // help-tags entry was added in formatted form
fputs((char *)s, fd_tags);
- else {
- fprintf(fd_tags, "%s\t/*", s);
- for (p1 = s; *p1 != '\t'; ++p1) {
- /* insert backslash before '\\' and '/' */
- if (*p1 == '\\' || *p1 == '/')
+ } else {
+ fprintf(fd_tags, "%s\t/" "*", s);
+ for (p1 = s; *p1 != '\t'; p1++) {
+ // insert backslash before '\\' and '/'
+ if (*p1 == '\\' || *p1 == '/') {
putc('\\', fd_tags);
+ }
putc(*p1, fd_tags);
}
fprintf(fd_tags, "*\n");
}
}
}
- if (mix)
- got_int = FALSE; /* continue with other languages */
+ if (mix) {
+ got_int = false; // continue with other languages
+ }
GA_DEEP_CLEAR_PTR(&ga);
- fclose(fd_tags); /* there is no check for an error... */
+ fclose(fd_tags); // there is no check for an error...
}
/// Generate tags in one help directory, taking care of translations.
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 5365270e0b..0db148690f 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -6761,8 +6761,9 @@ void ex_splitview(exarg_T *eap)
if (*eap->arg != NUL
) {
RESET_BINDING(curwin);
- } else
- do_check_scrollbind(FALSE);
+ } else {
+ do_check_scrollbind(false);
+ }
do_exedit(eap, old_curwin);
}
diff --git a/src/nvim/generators/gen_eval.lua b/src/nvim/generators/gen_eval.lua
index fa01935fd4..2c6f8f2603 100644
--- a/src/nvim/generators/gen_eval.lua
+++ b/src/nvim/generators/gen_eval.lua
@@ -8,7 +8,7 @@ local funcs_file = arg[4]
if nvimsrcdir == '--help' then
print([[
Usage:
- lua geneval.lua src/nvim build/src/nvim/auto
+ lua gen_eval.lua src/nvim build/src/nvim/auto
Will generate build/src/nvim/auto/funcs.generated.h with definition of functions
static const array.
diff --git a/src/nvim/macros.h b/src/nvim/macros.h
index f2ba91335d..018985fad2 100644
--- a/src/nvim/macros.h
+++ b/src/nvim/macros.h
@@ -127,7 +127,11 @@
# define MB_CHAR2LEN(c) mb_char2len(c)
# define PTR2CHAR(p) utf_ptr2char(p)
-# define RESET_BINDING(wp) (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE
+# define RESET_BINDING(wp) \
+ do { \
+ (wp)->w_p_scb = false; \
+ (wp)->w_p_crb = false; \
+ } while (0)
/// Calculate the length of a C array
///
diff --git a/src/nvim/move.c b/src/nvim/move.c
index b9c4196251..4a87f82eb7 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -1245,12 +1245,12 @@ static void botline_forw(lineoff_T *lp)
} else {
++lp->lnum;
lp->fill = 0;
- if (lp->lnum > curbuf->b_ml.ml_line_count)
+ if (lp->lnum > curbuf->b_ml.ml_line_count) {
lp->height = MAXCOL;
- else if (hasFolding(lp->lnum, NULL, &lp->lnum))
- /* Add a closed fold */
+ } else if (hasFolding(lp->lnum, NULL, &lp->lnum)) {
+ // Add a closed fold
lp->height = 1;
- else {
+ } else {
lp->height = plines_nofill(lp->lnum);
}
}
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index c3b4f4e376..eeb41a5d13 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -7467,8 +7467,12 @@ static void nv_esc(cmdarg_T *cap)
&& cmdwin_type == 0
&& !VIsual_active
&& no_reason) {
- MSG(_("Type :qa! and press <Enter> to abandon all changes"
- " and exit Nvim"));
+ if (anyBufIsChanged()) {
+ MSG(_("Type :qa! and press <Enter> to abandon all changes"
+ " and exit Nvim"));
+ } else {
+ MSG(_("Type :qa and press <Enter> to exit Nvim"));
+ }
}
/* Don't reset "restart_edit" when 'insertmode' is set, it won't be
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 6709e52679..35ab9c4d84 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -2519,9 +2519,9 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
endcol = (colnr_T)STRLEN(p);
if (startcol > endcol
|| is_oneChar
- )
+ ) {
bd.textlen = 0;
- else {
+ } else {
bd.textlen = endcol - startcol + oap->inclusive;
}
bd.textstart = p + startcol;
diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c
index a1020be215..c7b473a012 100644
--- a/src/nvim/os/process.c
+++ b/src/nvim/os/process.c
@@ -89,21 +89,12 @@ bool os_proc_tree_kill(int pid, int sig)
bool os_proc_tree_kill(int pid, int sig)
{
assert(sig == SIGTERM || sig == SIGKILL);
- int pgid = getpgid(pid);
- if (pgid > 0) { // Ignore error. Never kill self (pid=0).
- if (pgid == pid) {
- ILOG("sending %s to process group: -%d",
- sig == SIGTERM ? "SIGTERM" : "SIGKILL", pgid);
- int rv = uv_kill(-pgid, sig);
- return rv == 0;
- } else {
- // Should never happen, because process_spawn() did setsid() in the child.
- ELOG("pgid %d != pid %d", pgid, pid);
- }
- } else {
- ELOG("getpgid(%d) returned %d", pid, pgid);
+ if (pid == 0) {
+ // Never kill self (pid=0).
+ return false;
}
- return false;
+ ILOG("sending %s to PID %d", sig == SIGTERM ? "SIGTERM" : "SIGKILL", -pid);
+ return uv_kill(-pid, sig) == 0;
}
#endif
diff --git a/src/nvim/testdir/runnvim.vim b/src/nvim/testdir/runnvim.vim
index 396a3a6477..52e05cfbeb 100644
--- a/src/nvim/testdir/runnvim.vim
+++ b/src/nvim/testdir/runnvim.vim
@@ -20,7 +20,7 @@ function Main()
let results = jobwait([job], 5 * 60 * 1000)
" TODO(ZyX-I): Get colors
let screen = getline(1, '$')
- bwipeout!
+ bwipeout! " kills the job always.
let stringified_events = map(s:logger.d_events,
\'v:val[0] . ": " . ' .
\'join(map(v:val[1], '.
@@ -43,9 +43,6 @@ function Main()
\])
write
if results[0] != 0
- if results[0] != -1
- call jobstop(job)
- endif
cquit
else
qall
diff --git a/src/nvim/testdir/test_arabic.vim b/src/nvim/testdir/test_arabic.vim
index 17e925ee7f..d67f875f97 100644
--- a/src/nvim/testdir/test_arabic.vim
+++ b/src/nvim/testdir/test_arabic.vim
@@ -524,54 +524,6 @@ func Test_shape_final()
bwipe!
endfunc
-func Test_shape_final_to_medial()
- new
- set arabicshape
-
- " Shaping arabic {testchar} arabic Tests chg_c_f2m().
- " This does not test much...
- " pair[0] = testchar, pair[1] = current-result
- for pair in [[s:a_f_YEH_HAMZA, s:a_f_BEH],
- \[s:a_f_WAW_HAMZA, s:a_s_BEH],
- \[s:a_f_ALEF, s:a_s_BEH],
- \[s:a_f_TEH_MARBUTA, s:a_s_BEH],
- \[s:a_f_DAL, s:a_s_BEH],
- \[s:a_f_THAL, s:a_s_BEH],
- \[s:a_f_REH, s:a_s_BEH],
- \[s:a_f_ZAIN, s:a_s_BEH],
- \[s:a_f_WAW, s:a_s_BEH],
- \[s:a_f_ALEF_MAKSURA, s:a_s_BEH],
- \[s:a_f_BEH, s:a_f_BEH],
- \[s:a_f_TEH, s:a_f_BEH],
- \[s:a_f_THEH, s:a_f_BEH],
- \[s:a_f_JEEM, s:a_f_BEH],
- \[s:a_f_HAH, s:a_f_BEH],
- \[s:a_f_KHAH, s:a_f_BEH],
- \[s:a_f_SEEN, s:a_f_BEH],
- \[s:a_f_SHEEN, s:a_f_BEH],
- \[s:a_f_SAD, s:a_f_BEH],
- \[s:a_f_DAD, s:a_f_BEH],
- \[s:a_f_TAH, s:a_f_BEH],
- \[s:a_f_ZAH, s:a_f_BEH],
- \[s:a_f_AIN, s:a_f_BEH],
- \[s:a_f_GHAIN, s:a_f_BEH],
- \[s:a_f_FEH, s:a_f_BEH],
- \[s:a_f_QAF, s:a_f_BEH],
- \[s:a_f_KAF, s:a_f_BEH],
- \[s:a_f_LAM, s:a_f_BEH],
- \[s:a_f_MEEM, s:a_f_BEH],
- \[s:a_f_NOON, s:a_f_BEH],
- \[s:a_f_HEH, s:a_f_BEH],
- \[s:a_f_YEH, s:a_f_BEH],
- \ ]
- call setline(1, ' ' . s:a_BEH . pair[0])
- call assert_equal([' ' . pair[1] . pair[0]], ScreenLines(1, 3))
- endfor
-
- set arabicshape&
- bwipe!
-endfunc
-
func Test_shape_combination_final()
new
set arabicshape
diff --git a/src/nvim/testdir/test_compiler.vim b/src/nvim/testdir/test_compiler.vim
index 4600a28da5..46c14d8bc3 100644
--- a/src/nvim/testdir/test_compiler.vim
+++ b/src/nvim/testdir/test_compiler.vim
@@ -33,9 +33,9 @@ endfunc
func Test_compiler_without_arg()
let a=split(execute('compiler'))
- call assert_match(expand('^.*runtime/compiler/ant.vim$'), a[0])
- call assert_match(expand('^.*runtime/compiler/bcc.vim$'), a[1])
- call assert_match(expand('^.*runtime/compiler/xmlwf.vim$'), a[-1])
+ call assert_match('^.*runtime/compiler/ant.vim$', a[0])
+ call assert_match('^.*runtime/compiler/bcc.vim$', a[1])
+ call assert_match('^.*runtime/compiler/xmlwf.vim$', a[-1])
endfunc
func Test_compiler_completion()
diff --git a/src/nvim/testdir/test_makeencoding.py b/src/nvim/testdir/test_makeencoding.py
index 041edadc0a..f6dc0f8d1c 100644
--- a/src/nvim/testdir/test_makeencoding.py
+++ b/src/nvim/testdir/test_makeencoding.py
@@ -8,6 +8,7 @@ import locale
import io
import sys
+
def set_output_encoding(enc=None):
"""Set the encoding of stdout and stderr
@@ -20,7 +21,7 @@ def set_output_encoding(enc=None):
def get_text_writer(fo, **kwargs):
kw = dict(kwargs)
- kw.setdefault('errors', 'backslashreplace') # use \uXXXX style
+ kw.setdefault('errors', 'backslashreplace') # use \uXXXX style
kw.setdefault('closefd', False)
if sys.version_info[0] < 3:
@@ -29,6 +30,7 @@ def set_output_encoding(enc=None):
writer = io.open(fo.fileno(), mode='w', newline='', **kw)
write = writer.write # save the original write() function
enc = locale.getpreferredencoding()
+
def convwrite(s):
if isinstance(s, bytes):
write(s.decode(enc)) # convert to unistr
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index ef17209f74..945cd5a617 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/testdir/test_normal.vim
@@ -2552,6 +2552,21 @@ func Test_delete_until_paragraph()
bwipe!
endfunc
+func Test_message_when_using_ctrl_c()
+ " Make sure no buffers are changed.
+ %bwipe!
+
+ exe "normal \<C-C>"
+ call assert_match("Type :qa and press <Enter> to exit Nvim", Screenline(&lines))
+
+ new
+ cal setline(1, 'hi!')
+ exe "normal \<C-C>"
+ call assert_match("Type :qa! and press <Enter> to abandon all changes and exit Nvim", Screenline(&lines))
+
+ bwipe!
+endfunc
+
" Test for '[m', ']m', '[M' and ']M'
" Jumping to beginning and end of methods in Java-like languages
func Test_java_motion()
diff --git a/src/nvim/testdir/test_registers.vim b/src/nvim/testdir/test_registers.vim
index 414244768a..298268a994 100644
--- a/src/nvim/testdir/test_registers.vim
+++ b/src/nvim/testdir/test_registers.vim
@@ -68,12 +68,17 @@ endfunc
" characters as an escape sequence.
func Test_recording_esc_sequence()
new
- let save_F2 = &t_F2
+ try
+ let save_F2 = &t_F2
+ catch
+ endtry
let t_F2 = "\<Esc>OQ"
call feedkeys("qqiTest\<Esc>", "xt")
call feedkeys("OQuirk\<Esc>q", "xt")
call feedkeys("Go\<Esc>@q", "xt")
call assert_equal(['Quirk', 'Test', 'Quirk', 'Test'], getline(1, 4))
bwipe!
- let t_F2 = save_F2
+ if exists('save_F2')
+ let &t_F2 = save_F2
+ endif
endfunc
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index c9b0d96866..1305e013ad 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -2961,10 +2961,23 @@ static char_u *u_save_line(linenr_T lnum)
///
/// @return true if the buffer has changed
bool bufIsChanged(buf_T *buf)
+ FUNC_ATTR_WARN_UNUSED_RESULT
{
return !bt_dontwrite(buf) && (buf->b_changed || file_ff_differs(buf, true));
}
+// Return true if any buffer has changes. Also buffers that are not written.
+bool anyBufIsChanged(void)
+ FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ FOR_ALL_BUFFERS(buf) {
+ if (bufIsChanged(buf)) {
+ return true;
+ }
+ }
+ return false;
+}
+
/// Check if the 'modified' flag is set, or 'ff' has changed (only need to
/// check the first character, because it can only be "dos", "unix" or "mac").
/// "nofile" and "scratch" type buffers are considered to always be unchanged.