on master help sign in
Call View::apply within Document::append_changes_to_history
9a9e462Michael Davis
helix-term/src/commands.rs+4−4
@@ -2564,7 +2564,7 @@ async fn make_format_callback(
2564 if let Ok(format) = format {
2564 if let Ok(format) = format {
2565 if doc.version() == doc_version {
2565 if doc.version() == doc_version {
2566 apply_transaction(&format, doc, view);
2566 apply_transaction(&format, doc, view);
2567− doc.append_changes_to_history(view.id);
2567+ doc.append_changes_to_history(view);
2568 doc.detect_indent_and_line_ending();
2568 doc.detect_indent_and_line_ending();
2569 view.ensure_cursor_in_view(doc, scrolloff);
2569 view.ensure_cursor_in_view(doc, scrolloff);
2570 } else {
2570 } else {
@@ -3365,7 +3365,7 @@ fn later(cx: &mut Context) {
3365
3365
3366fn commit_undo_checkpoint(cx: &mut Context) {
3366fn commit_undo_checkpoint(cx: &mut Context) {
3367 let (view, doc) = current!(cx.editor);
3367 let (view, doc) = current!(cx.editor);
3368− doc.append_changes_to_history(view.id);
3368+ doc.append_changes_to_history(view);
3369}
3369}
3370
3370
3371// Yank / Paste
3371// Yank / Paste
@@ -3677,7 +3677,7 @@ fn replace_selections_with_clipboard_impl(
3677 });
3677 });
3678
3678
3679 apply_transaction(&transaction, doc, view);
3679 apply_transaction(&transaction, doc, view);
3680− doc.append_changes_to_history(view.id);
3680+ doc.append_changes_to_history(view);
3681 }
3681 }
3682 Err(e) => return Err(e.context("Couldn't get system clipboard contents")),
3682 Err(e) => return Err(e.context("Couldn't get system clipboard contents")),
3683 }
3683 }
@@ -4884,7 +4884,7 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
4884 let transaction = Transaction::change(doc.text(), changes.into_iter())
4884 let transaction = Transaction::change(doc.text(), changes.into_iter())
4885 .with_selection(Selection::new(ranges, selection.primary_index()));
4885 .with_selection(Selection::new(ranges, selection.primary_index()));
4886 apply_transaction(&transaction, doc, view);
4886 apply_transaction(&transaction, doc, view);
4887− doc.append_changes_to_history(view.id);
4887+ doc.append_changes_to_history(view);
4888 }
4888 }
4889
4889
4890 // after replace cursor may be out of bounds, do this to
4890 // after replace cursor may be out of bounds, do this to
helix-term/src/commands/lsp.rs+3−2
@@ -760,8 +760,9 @@ pub fn apply_workspace_edit(
760 text_edits,
760 text_edits,
761 offset_encoding,
761 offset_encoding,
762 );
762 );
763+ let view = view_mut!(editor, view_id);
763− apply_transaction(&transaction, doc, view_mut!(editor, view_id));
764+ apply_transaction(&transaction, doc, view);
764− doc.append_changes_to_history(view_id);
765+ doc.append_changes_to_history(view);
765 };
766 };
766
767
767 if let Some(ref changes) = workspace_edit.changes {
768 if let Some(ref changes) = workspace_edit.changes {
helix-term/src/commands/typed.rs+4−4
@@ -464,7 +464,7 @@ fn set_line_ending(
464 }),
464 }),
465 );
465 );
466 apply_transaction(&transaction, doc, view);
466 apply_transaction(&transaction, doc, view);
467− doc.append_changes_to_history(view.id);
467+ doc.append_changes_to_history(view);
468
468
469 Ok(())
469 Ok(())
470}
470}
@@ -909,7 +909,7 @@ fn replace_selections_with_clipboard_impl(
909 });
909 });
910
910
911 apply_transaction(&transaction, doc, view);
911 apply_transaction(&transaction, doc, view);
912− doc.append_changes_to_history(view.id);
912+ doc.append_changes_to_history(view);
913 Ok(())
913 Ok(())
914 }
914 }
915 Err(e) => Err(e.context("Couldn't get system clipboard contents")),
915 Err(e) => Err(e.context("Couldn't get system clipboard contents")),
@@ -1573,7 +1573,7 @@ fn sort_impl(
1573 );
1573 );
1574
1574
1575 apply_transaction(&transaction, doc, view);
1575 apply_transaction(&transaction, doc, view);
1576− doc.append_changes_to_history(view.id);
1576+ doc.append_changes_to_history(view);
1577
1577
1578 Ok(())
1578 Ok(())
1579}
1579}
@@ -1617,7 +1617,7 @@ fn reflow(
1617 });
1617 });
1618
1618
1619 apply_transaction(&transaction, doc, view);
1619 apply_transaction(&transaction, doc, view);
1620− doc.append_changes_to_history(view.id);
1620+ doc.append_changes_to_history(view);
1621 view.ensure_cursor_in_view(doc, scrolloff);
1621 view.ensure_cursor_in_view(doc, scrolloff);
1622
1622
1623 Ok(())
1623 Ok(())
helix-term/src/ui/editor.rs+2−2
@@ -1319,7 +1319,7 @@ impl Component for EditorView {
1319 // Store a history state if not in insert mode. Otherwise wait till we exit insert
1319 // Store a history state if not in insert mode. Otherwise wait till we exit insert
1320 // to include any edits to the paste in the history state.
1320 // to include any edits to the paste in the history state.
1321 if mode != Mode::Insert {
1321 if mode != Mode::Insert {
1322− doc.append_changes_to_history(view.id);
1322+ doc.append_changes_to_history(view);
1323 }
1323 }
1324
1324
1325 EventResult::Consumed(None)
1325 EventResult::Consumed(None)
@@ -1418,7 +1418,7 @@ impl Component for EditorView {
1418 // Store a history state if not in insert mode. This also takes care of
1418 // Store a history state if not in insert mode. This also takes care of
1419 // committing changes when leaving insert mode.
1419 // committing changes when leaving insert mode.
1420 if mode != Mode::Insert {
1420 if mode != Mode::Insert {
1421− doc.append_changes_to_history(view.id);
1421+ doc.append_changes_to_history(view);
1422 }
1422 }
1423 }
1423 }
1424
1424
helix-view/src/document.rs+6−3
@@ -641,7 +641,7 @@ impl Document {
641 // of the encoding.
641 // of the encoding.
642 let transaction = helix_core::diff::compare_ropes(self.text(), &rope);
642 let transaction = helix_core::diff::compare_ropes(self.text(), &rope);
643 apply_transaction(&transaction, self, view);
643 apply_transaction(&transaction, self, view);
644− self.append_changes_to_history(view.id);
644+ self.append_changes_to_history(view);
645 self.reset_modified();
645 self.reset_modified();
646
646
647 self.detect_indent_and_line_ending();
647 self.detect_indent_and_line_ending();
@@ -928,7 +928,7 @@ impl Document {
928 }
928 }
929
929
930 /// Commit pending changes to history
930 /// Commit pending changes to history
931− pub fn append_changes_to_history(&mut self, view_id: ViewId) {
931+ pub fn append_changes_to_history(&mut self, view: &mut View) {
932 if self.changes.is_empty() {
932 if self.changes.is_empty() {
933 return;
933 return;
934 }
934 }
@@ -938,7 +938,7 @@ impl Document {
938 // Instead of doing this messy merge we could always commit, and based on transaction
938 // Instead of doing this messy merge we could always commit, and based on transaction
939 // annotations either add a new layer or compose into the previous one.
939 // annotations either add a new layer or compose into the previous one.
940 let transaction =
940 let transaction =
941− Transaction::from(changes).with_selection(self.selection(view_id).clone());
941+ Transaction::from(changes).with_selection(self.selection(view.id).clone());
942
942
943 // HAXX: we need to reconstruct the state as it was before the changes..
943 // HAXX: we need to reconstruct the state as it was before the changes..
944 let old_state = self.old_state.take().expect("no old_state available");
944 let old_state = self.old_state.take().expect("no old_state available");
@@ -946,6 +946,9 @@ impl Document {
946 let mut history = self.history.take();
946 let mut history = self.history.take();
947 history.commit_revision(&transaction, &old_state);
947 history.commit_revision(&transaction, &old_state);
948 self.history.set(history);
948 self.history.set(history);
949+
950+ // Update jumplist entries in the view.
951+ view.apply(&transaction, self);
949 }
952 }
950
953
951 pub fn id(&self) -> DocumentId {
954 pub fn id(&self) -> DocumentId {