aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/undo.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-10-31 03:50:19 +0100
committerJustin M. Keyes <justinkz@gmail.com>2016-11-08 21:20:08 +0100
commitc04ffe866d276d6a6bd9e9c6a8b0dbb71504db7c (patch)
tree0fca258fbfb83cb871a493916d9dd6e0ef1195c3 /src/nvim/undo.c
parente8c0f909626094350be7ee7b524697804da38dc1 (diff)
downloadrneovim-c04ffe866d276d6a6bd9e9c6a8b0dbb71504db7c.tar.gz
rneovim-c04ffe866d276d6a6bd9e9c6a8b0dbb71504db7c.tar.bz2
rneovim-c04ffe866d276d6a6bd9e9c6a8b0dbb71504db7c.zip
'inccommand': rework
- Eliminate/isolate static/global variables - Remove special-case parameter from buflist_new() - Remove special-case ECMD_RESERVED_BUFNR - To determine when u_undo_and_forget() should be done, check b_changedtick instead of a heuristic. - use mb_string2cells() instead of strlen() to measure the :sub patterns - call ml_close() before buf_clear_file(). Avoids leaks caught by ASan. Original patch by: Robin Elrharbi-Fleury (Robinhola) Audrey Rayé (Adrey06) Philémon Hullot (DesbyP) Aymeric Collange (aym7) Clément Guyomard (Clement0)
Diffstat (limited to 'src/nvim/undo.c')
-rw-r--r--src/nvim/undo.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index a4af45d441..20adf40012 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -1685,7 +1685,7 @@ void u_redo(int count)
u_doit(count, false);
}
-/// undo and forget.
+/// undo, and remove the undo branch from the undo tree.
bool u_undo_and_forget(int count)
{
if (curbuf->b_u_synced == false) {
@@ -1726,9 +1726,7 @@ bool u_undo_and_forget(int count)
return true;
}
-/*
- * Undo or redo, depending on 'undo_undoes', 'count' times.
- */
+/// Undo or redo, depending on `undo_undoes`, `count` times.
static void u_doit(int startcount, bool quiet)
{
int count = startcount;
@@ -2342,17 +2340,13 @@ static void u_undoredo(int undo)
#endif
}
-/*
- * If we deleted or added lines, report the number of less/more lines.
- * Otherwise, report the number of changes (this may be incorrect
- * in some cases, but it's better than nothing).
- */
-static void
-u_undo_end(
- int did_undo, // just did an undo
- int absolute, // used ":undo N"
- bool quiet
-)
+/// If we deleted or added lines, report the number of less/more lines.
+/// Otherwise, report the number of changes (this may be incorrect
+/// in some cases, but it's better than nothing).
+static void u_undo_end(
+ int did_undo, //< just did an undo
+ int absolute, //< used ":undo N"
+ bool quiet)
{
char *msgstr;
u_header_T *uhp;
@@ -2361,9 +2355,9 @@ u_undo_end(
if ((fdo_flags & FDO_UNDO) && KeyTyped)
foldOpenCursor();
- if (global_busy // no messages now, wait until global is finished
- || !messaging() // 'lazyredraw' set, don't do messages now
- || quiet) { // livemode doesn't show messages
+ if (quiet
+ || global_busy // no messages until global is finished
+ || !messaging()) { // 'lazyredraw' set, don't do messages now
return;
}