summaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-01-25 07:49:53 +0000
committerBlaž Hrastnik2022-01-30 13:38:44 +0000
commit2a7ae963e11dc2bb751e7b0933be157900f1adeb (patch)
tree405ec607df256080fd028253a2a08501293829e0 /helix-term/src/ui
parente2833b58533f3991fa68061a21486b1322239fe3 (diff)
Automatically commit changes to history if not in insert mode
Fixes #1500
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 040e746d..89fa3c6e 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -1035,6 +1035,12 @@ impl Component for EditorView {
let (view, doc) = current!(cx.editor);
view.ensure_cursor_in_view(doc, cx.editor.config.scrolloff);
+ // Store a history state if not in insert mode. This also takes care of
+ // commiting changes when leaving insert mode.
+ if doc.mode() != Mode::Insert {
+ doc.append_changes_to_history(view.id);
+ }
+
// mode transitions
match (mode, doc.mode()) {
(Mode::Normal, Mode::Insert) => {