aboutsummaryrefslogtreecommitdiff
path: root/config.def.h
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-12 10:55:01 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-12 10:55:01 +0200
commit9d97c6b78627994eb140e5943660d6166673168b (patch)
tree924a1a1e3ccc098e4989548f90fc00b64472e12f /config.def.h
parent374ceb4916820204714b79f75fdd6fe580bf750d (diff)
downloadvis-9d97c6b78627994eb140e5943660d6166673168b.tar.gz
vis-9d97c6b78627994eb140e5943660d6166673168b.tar.xz
Take snapshot when leaving insert/replace mode
Make sure we are able to restore text to whatever state was when we left insert / replace mode after an editing operation.
Diffstat (limited to 'config.def.h')
-rw-r--r--config.def.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index b8bbdd5..ad8eb4c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -453,6 +453,11 @@ static KeyBinding vis_insert_mode[] = {
{ /* empty last element, array terminator */ },
};
+static void vis_mode_insert_leave(Mode *old) {
+ /* make sure we can recover the current state after an editing operation */
+ text_snapshot(vis->win->text);
+}
+
static void vis_insert_idle(void) {
text_snapshot(vis->win->text);
}
@@ -466,6 +471,11 @@ static KeyBinding vis_replace[] = {
{ /* empty last element, array terminator */ },
};
+static void vis_mode_replace_leave(Mode *old) {
+ /* make sure we can recover the current state after an editing operation */
+ text_snapshot(vis->win->text);
+}
+
static void vis_replace_input(const char *str, size_t len) {
editor_replace_key(vis, str, len);
}
@@ -603,6 +613,7 @@ static Mode vis_modes[] = {
.name = "INSERT",
.parent = &vis_modes[VIS_MODE_INSERT_REGISTER],
.bindings = vis_insert_mode,
+ .leave = vis_mode_insert_leave,
.input = vis_insert_input,
.idle = vis_insert_idle,
},
@@ -610,6 +621,7 @@ static Mode vis_modes[] = {
.name = "REPLACE",
.parent = &vis_modes[VIS_MODE_INSERT],
.bindings = vis_replace,
+ .leave = vis_mode_replace_leave,
.input = vis_replace_input,
.idle = vis_insert_idle,
},