From 2a7ae963e11dc2bb751e7b0933be157900f1adeb Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Tue, 25 Jan 2022 16:49:53 +0900 Subject: Automatically commit changes to history if not in insert mode Fixes #1500 --- helix-term/src/ui/editor.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'helix-term/src/ui') 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) => { -- cgit v1.2.3-70-g09d2