on master help sign in
Apply transactions to Views
0aedef0Michael Davis
helix-term/src/commands.rs+36−7
@@ -860,6 +860,7 @@ fn align_selections(cx: &mut Context) {
860
860
861 let transaction = Transaction::change(doc.text(), changes.into_iter());
861 let transaction = Transaction::change(doc.text(), changes.into_iter());
862 doc.apply(&transaction, view.id);
862 doc.apply(&transaction, view.id);
863+ view.apply(&transaction, doc);
863}
864}
864
865
865fn goto_window(cx: &mut Context, align: Align) {
866fn goto_window(cx: &mut Context, align: Align) {
@@ -1290,6 +1291,7 @@ fn replace(cx: &mut Context) {
1290 });
1291 });
1291
1292
1292 doc.apply(&transaction, view.id);
1293 doc.apply(&transaction, view.id);
1294+ view.apply(&transaction, doc);
1293 }
1295 }
1294 })
1296 })
1295}
1297}
@@ -1307,6 +1309,7 @@ where
1307 });
1309 });
1308
1310
1309 doc.apply(&transaction, view.id);
1311 doc.apply(&transaction, view.id);
1312+ view.apply(&transaction, doc);
1310}
1313}
1311
1314
1312fn switch_case(cx: &mut Context) {
1315fn switch_case(cx: &mut Context) {
@@ -2113,6 +2116,7 @@ fn delete_selection_impl(cx: &mut Context, op: Operation) {
2113 (range.from(), range.to(), None)
2116 (range.from(), range.to(), None)
2114 });
2117 });
2115 doc.apply(&transaction, view.id);
2118 doc.apply(&transaction, view.id);
2119+ view.apply(&transaction, doc);
2116
2120
2117 match op {
2121 match op {
2118 Operation::Delete => {
2122 Operation::Delete => {
@@ -2126,7 +2130,7 @@ fn delete_selection_impl(cx: &mut Context, op: Operation) {
2126}
2130}
2127
2131
2128#[inline]
2132#[inline]
2129−fn delete_selection_insert_mode(doc: &mut Document, view: &View, selection: &Selection) {
2133+fn delete_selection_insert_mode(doc: &mut Document, view: &mut View, selection: &Selection) {
2130 let view_id = view.id;
2134 let view_id = view.id;
2131
2135
2132 // then delete
2136 // then delete
@@ -2134,6 +2138,7 @@ fn delete_selection_insert_mode(doc: &mut Document, view: &View, selection: &Sel
2134 (range.from(), range.to(), None)
2138 (range.from(), range.to(), None)
2135 });
2139 });
2136 doc.apply(&transaction, view_id);
2140 doc.apply(&transaction, view_id);
2141+ view.apply(&transaction, doc);
2137}
2142}
2138
2143
2139fn delete_selection(cx: &mut Context) {
2144fn delete_selection(cx: &mut Context) {
@@ -2230,6 +2235,7 @@ fn append_mode(cx: &mut Context) {
2230 [(end, end, Some(doc.line_ending.as_str().into()))].into_iter(),
2235 [(end, end, Some(doc.line_ending.as_str().into()))].into_iter(),
2231 );
2236 );
2232 doc.apply(&transaction, view.id);
2237 doc.apply(&transaction, view.id);
2238+ view.apply(&transaction, doc);
2233 }
2239 }
2234
2240
2235 let selection = doc.selection(view.id).clone().transform(|range| {
2241 let selection = doc.selection(view.id).clone().transform(|range| {
@@ -2530,6 +2536,7 @@ async fn make_format_callback(
2530 let view = view_mut!(editor);
2536 let view = view_mut!(editor);
2531 if doc.version() == doc_version {
2537 if doc.version() == doc_version {
2532 doc.apply(&format, view.id);
2538 doc.apply(&format, view.id);
2539+ view.apply(&format, doc);
2533 doc.append_changes_to_history(view.id);
2540 doc.append_changes_to_history(view.id);
2534 doc.detect_indent_and_line_ending();
2541 doc.detect_indent_and_line_ending();
2535 view.ensure_cursor_in_view(doc, scrolloff);
2542 view.ensure_cursor_in_view(doc, scrolloff);
@@ -2617,6 +2624,7 @@ fn open(cx: &mut Context, open: Open) {
2617 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
2624 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
2618
2625
2619 doc.apply(&transaction, view.id);
2626 doc.apply(&transaction, view.id);
2627+ view.apply(&transaction, doc);
2620}
2628}
2621
2629
2622// o inserts a new line after each line with a selection
2630// o inserts a new line after each line with a selection
@@ -2637,7 +2645,7 @@ fn normal_mode(cx: &mut Context) {
2637 cx.editor.mode = Mode::Normal;
2645 cx.editor.mode = Mode::Normal;
2638 let (view, doc) = current!(cx.editor);
2646 let (view, doc) = current!(cx.editor);
2639
2647
2640− try_restore_indent(doc, view.id);
2648+ try_restore_indent(doc, view);
2641
2649
2642 // if leaving append mode, move cursor back by 1
2650 // if leaving append mode, move cursor back by 1
2643 if doc.restore_cursor {
2651 if doc.restore_cursor {
@@ -2654,7 +2662,7 @@ fn normal_mode(cx: &mut Context) {
2654 }
2662 }
2655}
2663}
2656
2664
2657−fn try_restore_indent(doc: &mut Document, view_id: ViewId) {
2665+fn try_restore_indent(doc: &mut Document, view: &mut View) {
2658 use helix_core::chars::char_is_whitespace;
2666 use helix_core::chars::char_is_whitespace;
2659 use helix_core::Operation;
2667 use helix_core::Operation;
2660
2668
@@ -2673,18 +2681,19 @@ fn try_restore_indent(doc: &mut Document, view_id: ViewId) {
2673
2681
2674 let doc_changes = doc.changes().changes();
2682 let doc_changes = doc.changes().changes();
2675 let text = doc.text().slice(..);
2683 let text = doc.text().slice(..);
2676− let range = doc.selection(view_id).primary();
2684+ let range = doc.selection(view.id).primary();
2677 let pos = range.cursor(text);
2685 let pos = range.cursor(text);
2678 let line_end_pos = line_end_char_index(&text, range.cursor_line(text));
2686 let line_end_pos = line_end_char_index(&text, range.cursor_line(text));
2679
2687
2680 if inserted_a_new_blank_line(doc_changes, pos, line_end_pos) {
2688 if inserted_a_new_blank_line(doc_changes, pos, line_end_pos) {
2681 // Removes tailing whitespaces.
2689 // Removes tailing whitespaces.
2682 let transaction =
2690 let transaction =
2683− Transaction::change_by_selection(doc.text(), doc.selection(view_id), |range| {
2691+ Transaction::change_by_selection(doc.text(), doc.selection(view.id), |range| {
2684 let line_start_pos = text.line_to_char(range.cursor_line(text));
2692 let line_start_pos = text.line_to_char(range.cursor_line(text));
2685 (line_start_pos, pos, None)
2693 (line_start_pos, pos, None)
2686 });
2694 });
2687− doc.apply(&transaction, view_id);
2695+ doc.apply(&transaction, view.id);
2696+ view.apply(&transaction, doc);
2688 }
2697 }
2689}
2698}
2690
2699
@@ -2999,6 +3008,7 @@ pub mod insert {
2999 let (view, doc) = current!(cx.editor);
3008 let (view, doc) = current!(cx.editor);
3000 if let Some(t) = transaction {
3009 if let Some(t) = transaction {
3001 doc.apply(&t, view.id);
3010 doc.apply(&t, view.id);
3011+ view.apply(&t, doc);
3002 }
3012 }
3003
3013
3004 // TODO: need a post insert hook too for certain triggers (autocomplete, signature help, etc)
3014 // TODO: need a post insert hook too for certain triggers (autocomplete, signature help, etc)
@@ -3021,6 +3031,7 @@ pub mod insert {
3021 indent,
3031 indent,
3022 );
3032 );
3023 doc.apply(&transaction, view.id);
3033 doc.apply(&transaction, view.id);
3034+ view.apply(&transaction, doc);
3024 }
3035 }
3025
3036
3026 pub fn insert_newline(cx: &mut Context) {
3037 pub fn insert_newline(cx: &mut Context) {
@@ -3108,6 +3119,7 @@ pub mod insert {
3108
3119
3109 let (view, doc) = current!(cx.editor);
3120 let (view, doc) = current!(cx.editor);
3110 doc.apply(&transaction, view.id);
3121 doc.apply(&transaction, view.id);
3122+ view.apply(&transaction, doc);
3111 }
3123 }
3112
3124
3113 pub fn delete_char_backward(cx: &mut Context) {
3125 pub fn delete_char_backward(cx: &mut Context) {
@@ -3202,6 +3214,7 @@ pub mod insert {
3202 });
3214 });
3203 let (view, doc) = current!(cx.editor);
3215 let (view, doc) = current!(cx.editor);
3204 doc.apply(&transaction, view.id);
3216 doc.apply(&transaction, view.id);
3217+ view.apply(&transaction, doc);
3205
3218
3206 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
3219 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
3207 }
3220 }
@@ -3220,6 +3233,7 @@ pub mod insert {
3220 )
3233 )
3221 });
3234 });
3222 doc.apply(&transaction, view.id);
3235 doc.apply(&transaction, view.id);
3236+ view.apply(&transaction, doc);
3223
3237
3224 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
3238 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
3225 }
3239 }
@@ -3413,7 +3427,7 @@ enum Paste {
3413 Cursor,
3427 Cursor,
3414}
3428}
3415
3429
3416−fn paste_impl(values: &[String], doc: &mut Document, view: &View, action: Paste, count: usize) {
3430+fn paste_impl(values: &[String], doc: &mut Document, view: &mut View, action: Paste, count: usize) {
3417 let repeat = std::iter::repeat(
3431 let repeat = std::iter::repeat(
3418 values
3432 values
3419 .last()
3433 .last()
@@ -3457,6 +3471,7 @@ fn paste_impl(values: &[String], doc: &mut Document, view: &View, action: Paste,
3457 (pos, pos, values.next())
3471 (pos, pos, values.next())
3458 });
3472 });
3459 doc.apply(&transaction, view.id);
3473 doc.apply(&transaction, view.id);
3474+ view.apply(&transaction, doc);
3460}
3475}
3461
3476
3462pub(crate) fn paste_bracketed_value(cx: &mut Context, contents: String) {
3477pub(crate) fn paste_bracketed_value(cx: &mut Context, contents: String) {
@@ -3549,6 +3564,7 @@ fn replace_with_yanked(cx: &mut Context) {
3549 });
3564 });
3550
3565
3551 doc.apply(&transaction, view.id);
3566 doc.apply(&transaction, view.id);
3567+ view.apply(&transaction, doc);
3552 }
3568 }
3553 }
3569 }
3554}
3570}
@@ -3572,6 +3588,7 @@ fn replace_selections_with_clipboard_impl(
3572 });
3588 });
3573
3589
3574 doc.apply(&transaction, view.id);
3590 doc.apply(&transaction, view.id);
3591+ view.apply(&transaction, doc);
3575 doc.append_changes_to_history(view.id);
3592 doc.append_changes_to_history(view.id);
3576 Ok(())
3593 Ok(())
3577 }
3594 }
@@ -3642,6 +3659,7 @@ fn indent(cx: &mut Context) {
3642 }),
3659 }),
3643 );
3660 );
3644 doc.apply(&transaction, view.id);
3661 doc.apply(&transaction, view.id);
3662+ view.apply(&transaction, doc);
3645}
3663}
3646
3664
3647fn unindent(cx: &mut Context) {
3665fn unindent(cx: &mut Context) {
@@ -3681,6 +3699,7 @@ fn unindent(cx: &mut Context) {
3681 let transaction = Transaction::change(doc.text(), changes.into_iter());
3699 let transaction = Transaction::change(doc.text(), changes.into_iter());
3682
3700
3683 doc.apply(&transaction, view.id);
3701 doc.apply(&transaction, view.id);
3702+ view.apply(&transaction, doc);
3684}
3703}
3685
3704
3686fn format_selections(cx: &mut Context) {
3705fn format_selections(cx: &mut Context) {
@@ -3728,6 +3747,7 @@ fn format_selections(cx: &mut Context) {
3728 // );
3747 // );
3729
3748
3730 // doc.apply(&transaction, view.id);
3749 // doc.apply(&transaction, view.id);
3750+ // view.apply(&transaction, doc);
3731 }
3751 }
3732}
3752}
3733
3753
@@ -3783,6 +3803,7 @@ fn join_selections_inner(cx: &mut Context, select_space: bool) {
3783 };
3803 };
3784
3804
3785 doc.apply(&transaction, view.id);
3805 doc.apply(&transaction, view.id);
3806+ view.apply(&transaction, doc);
3786}
3807}
3787
3808
3788fn keep_or_remove_selections_impl(cx: &mut Context, remove: bool) {
3809fn keep_or_remove_selections_impl(cx: &mut Context, remove: bool) {
@@ -3936,6 +3957,7 @@ fn toggle_comments(cx: &mut Context) {
3936 let transaction = comment::toggle_line_comments(doc.text(), doc.selection(view.id), token);
3957 let transaction = comment::toggle_line_comments(doc.text(), doc.selection(view.id), token);
3937
3958
3938 doc.apply(&transaction, view.id);
3959 doc.apply(&transaction, view.id);
3960+ view.apply(&transaction, doc);
3939 exit_select_mode(cx);
3961 exit_select_mode(cx);
3940}
3962}
3941
3963
@@ -3992,6 +4014,7 @@ fn rotate_selection_contents(cx: &mut Context, direction: Direction) {
3992 );
4014 );
3993
4015
3994 doc.apply(&transaction, view.id);
4016 doc.apply(&transaction, view.id);
4017+ view.apply(&transaction, doc);
3995}
4018}
3996
4019
3997fn rotate_selection_contents_forward(cx: &mut Context) {
4020fn rotate_selection_contents_forward(cx: &mut Context) {
@@ -4488,6 +4511,7 @@ fn surround_add(cx: &mut Context) {
4488
4511
4489 let transaction = Transaction::change(doc.text(), changes.into_iter());
4512 let transaction = Transaction::change(doc.text(), changes.into_iter());
4490 doc.apply(&transaction, view.id);
4513 doc.apply(&transaction, view.id);
4514+ view.apply(&transaction, doc);
4491 })
4515 })
4492}
4516}
4493
4517
@@ -4527,6 +4551,7 @@ fn surround_replace(cx: &mut Context) {
4527 }),
4551 }),
4528 );
4552 );
4529 doc.apply(&transaction, view.id);
4553 doc.apply(&transaction, view.id);
4554+ view.apply(&transaction, doc);
4530 });
4555 });
4531 })
4556 })
4532}
4557}
@@ -4554,6 +4579,7 @@ fn surround_delete(cx: &mut Context) {
4554 let transaction =
4579 let transaction =
4555 Transaction::change(doc.text(), change_pos.into_iter().map(|p| (p, p + 1, None)));
4580 Transaction::change(doc.text(), change_pos.into_iter().map(|p| (p, p + 1, None)));
4556 doc.apply(&transaction, view.id);
4581 doc.apply(&transaction, view.id);
4582+ view.apply(&transaction, doc);
4557 })
4583 })
4558}
4584}
4559
4585
@@ -4729,6 +4755,7 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
4729 if behavior != &ShellBehavior::Ignore {
4755 if behavior != &ShellBehavior::Ignore {
4730 let transaction = Transaction::change(doc.text(), changes.into_iter());
4756 let transaction = Transaction::change(doc.text(), changes.into_iter());
4731 doc.apply(&transaction, view.id);
4757 doc.apply(&transaction, view.id);
4758+ view.apply(&transaction, doc);
4732 doc.append_changes_to_history(view.id);
4759 doc.append_changes_to_history(view.id);
4733 }
4760 }
4734
4761
@@ -4792,6 +4819,7 @@ fn add_newline_impl(cx: &mut Context, open: Open) {
4792
4819
4793 let transaction = Transaction::change(text, changes);
4820 let transaction = Transaction::change(text, changes);
4794 doc.apply(&transaction, view.id);
4821 doc.apply(&transaction, view.id);
4822+ view.apply(&transaction, doc);
4795}
4823}
4796
4824
4797/// Increment object under cursor by count.
4825/// Increment object under cursor by count.
@@ -4885,6 +4913,7 @@ fn increment_impl(cx: &mut Context, amount: i64) {
4885 let transaction = transaction.with_selection(selection.clone());
4913 let transaction = transaction.with_selection(selection.clone());
4886
4914
4887 doc.apply(&transaction, view.id);
4915 doc.apply(&transaction, view.id);
4916+ view.apply(&transaction, doc);
4888 }
4917 }
4889}
4918}
4890
4919
helix-term/src/commands/lsp.rs+2−3
@@ -596,9 +596,7 @@ pub fn apply_workspace_edit(
596 }
596 }
597 };
597 };
598
598
599− let doc = editor
599+ let doc = doc_mut!(editor, &doc_id);
600− .document_mut(doc_id)
601− .expect("Document for document_changes not found");
602
600
603 // Need to determine a view for apply/append_changes_to_history
601 // Need to determine a view for apply/append_changes_to_history
604 let selections = doc.selections();
602 let selections = doc.selections();
@@ -620,6 +618,7 @@ pub fn apply_workspace_edit(
620 offset_encoding,
618 offset_encoding,
621 );
619 );
622 doc.apply(&transaction, view_id);
620 doc.apply(&transaction, view_id);
621+ view_mut!(editor, view_id).apply(&transaction, doc);
623 doc.append_changes_to_history(view_id);
622 doc.append_changes_to_history(view_id);
624 };
623 };
625
624
helix-term/src/commands/typed.rs+5−1
@@ -463,6 +463,7 @@ fn set_line_ending(
463 }),
463 }),
464 );
464 );
465 doc.apply(&transaction, view.id);
465 doc.apply(&transaction, view.id);
466+ view.apply(&transaction, doc);
466 doc.append_changes_to_history(view.id);
467 doc.append_changes_to_history(view.id);
467
468
468 Ok(())
469 Ok(())
@@ -884,6 +885,7 @@ fn replace_selections_with_clipboard_impl(
884 });
885 });
885
886
886 doc.apply(&transaction, view.id);
887 doc.apply(&transaction, view.id);
888+ view.apply(&transaction, doc);
887 doc.append_changes_to_history(view.id);
889 doc.append_changes_to_history(view.id);
888 Ok(())
890 Ok(())
889 }
891 }
@@ -1004,7 +1006,7 @@ fn reload(
1004
1006
1005 let scrolloff = cx.editor.config().scrolloff;
1007 let scrolloff = cx.editor.config().scrolloff;
1006 let (view, doc) = current!(cx.editor);
1008 let (view, doc) = current!(cx.editor);
1007− doc.reload(view.id).map(|_| {
1009+ doc.reload(view).map(|_| {
1008 view.ensure_cursor_in_view(doc, scrolloff);
1010 view.ensure_cursor_in_view(doc, scrolloff);
1009 })
1011 })
1010}
1012}
@@ -1399,6 +1401,7 @@ fn sort_impl(
1399 );
1401 );
1400
1402
1401 doc.apply(&transaction, view.id);
1403 doc.apply(&transaction, view.id);
1404+ view.apply(&transaction, doc);
1402 doc.append_changes_to_history(view.id);
1405 doc.append_changes_to_history(view.id);
1403
1406
1404 Ok(())
1407 Ok(())
@@ -1443,6 +1446,7 @@ fn reflow(
1443 });
1446 });
1444
1447
1445 doc.apply(&transaction, view.id);
1448 doc.apply(&transaction, view.id);
1449+ view.apply(&transaction, doc);
1446 doc.append_changes_to_history(view.id);
1450 doc.append_changes_to_history(view.id);
1447 view.ensure_cursor_in_view(doc, scrolloff);
1451 view.ensure_cursor_in_view(doc, scrolloff);
1448
1452
helix-term/src/ui/completion.rs+5−2
@@ -143,11 +143,11 @@ impl Completion {
143 let (view, doc) = current!(editor);
143 let (view, doc) = current!(editor);
144
144
145 // if more text was entered, remove it
145 // if more text was entered, remove it
146− doc.restore(view.id);
146+ doc.restore(view);
147
147
148 match event {
148 match event {
149 PromptEvent::Abort => {
149 PromptEvent::Abort => {
150− doc.restore(view.id);
150+ doc.restore(view);
151 editor.last_completion = None;
151 editor.last_completion = None;
152 }
152 }
153 PromptEvent::Update => {
153 PromptEvent::Update => {
@@ -165,6 +165,7 @@ impl Completion {
165 // initialize a savepoint
165 // initialize a savepoint
166 doc.savepoint();
166 doc.savepoint();
167 doc.apply(&transaction, view.id);
167 doc.apply(&transaction, view.id);
168+ view.apply(&transaction, doc);
168
169
169 editor.last_completion = Some(CompleteAction {
170 editor.last_completion = Some(CompleteAction {
170 trigger_offset,
171 trigger_offset,
@@ -184,6 +185,7 @@ impl Completion {
184 );
185 );
185
186
186 doc.apply(&transaction, view.id);
187 doc.apply(&transaction, view.id);
188+ view.apply(&transaction, doc);
187
189
188 editor.last_completion = Some(CompleteAction {
190 editor.last_completion = Some(CompleteAction {
189 trigger_offset,
191 trigger_offset,
@@ -214,6 +216,7 @@ impl Completion {
214 offset_encoding, // TODO: should probably transcode in Client
216 offset_encoding, // TODO: should probably transcode in Client
215 );
217 );
216 doc.apply(&transaction, view.id);
218 doc.apply(&transaction, view.id);
219+ view.apply(&transaction, doc);
217 }
220 }
218 }
221 }
219 }
222 }
helix-term/src/ui/editor.rs+2−1
@@ -988,7 +988,7 @@ impl EditorView {
988 InsertEvent::CompletionApply(compl) => {
988 InsertEvent::CompletionApply(compl) => {
989 let (view, doc) = current!(cxt.editor);
989 let (view, doc) = current!(cxt.editor);
990
990
991− doc.restore(view.id);
991+ doc.restore(view);
992
992
993 let text = doc.text().slice(..);
993 let text = doc.text().slice(..);
994 let cursor = doc.selection(view.id).primary().cursor(text);
994 let cursor = doc.selection(view.id).primary().cursor(text);
@@ -1003,6 +1003,7 @@ impl EditorView {
1003 }),
1003 }),
1004 );
1004 );
1005 doc.apply(&tx, view.id);
1005 doc.apply(&tx, view.id);
1006+ view.apply(&tx, doc);
1006 }
1007 }
1007 InsertEvent::TriggerCompletion => {
1008 InsertEvent::TriggerCompletion => {
1008 let (_, doc) = current!(cxt.editor);
1009 let (_, doc) = current!(cxt.editor);
helix-view/src/document.rs+8−6
@@ -24,7 +24,7 @@ use helix_core::{
24 DEFAULT_LINE_ENDING,
24 DEFAULT_LINE_ENDING,
25};
25};
26
26
27−use crate::{DocumentId, Editor, ViewId};
27+use crate::{DocumentId, Editor, View, ViewId};
28
28
29/// 8kB of buffer space for encoding and decoding `Rope`s.
29/// 8kB of buffer space for encoding and decoding `Rope`s.
30const BUF_SIZE: usize = 8192;
30const BUF_SIZE: usize = 8192;
@@ -601,7 +601,7 @@ impl Document {
601 }
601 }
602
602
603 /// Reload the document from its path.
603 /// Reload the document from its path.
604− pub fn reload(&mut self, view_id: ViewId) -> Result<(), Error> {
604+ pub fn reload(&mut self, view: &mut View) -> Result<(), Error> {
605 let encoding = &self.encoding;
605 let encoding = &self.encoding;
606 let path = self.path().filter(|path| path.exists());
606 let path = self.path().filter(|path| path.exists());
607
607
@@ -617,8 +617,9 @@ impl Document {
617 // This is not considered a modification of the contents of the file regardless
617 // This is not considered a modification of the contents of the file regardless
618 // of the encoding.
618 // of the encoding.
619 let transaction = helix_core::diff::compare_ropes(self.text(), &rope);
619 let transaction = helix_core::diff::compare_ropes(self.text(), &rope);
620− self.apply(&transaction, view_id);
620+ self.apply(&transaction, view.id);
621+ view.apply(&transaction, self);
621− self.append_changes_to_history(view_id);
622+ self.append_changes_to_history(view.id);
622 self.reset_modified();
623 self.reset_modified();
623
624
624 self.detect_indent_and_line_ending();
625 self.detect_indent_and_line_ending();
@@ -862,9 +863,10 @@ impl Document {
862 self.savepoint = Some(Transaction::new(self.text()));
863 self.savepoint = Some(Transaction::new(self.text()));
863 }
864 }
864
865
865− pub fn restore(&mut self, view_id: ViewId) {
866+ pub fn restore(&mut self, view: &mut View) {
866 if let Some(revert) = self.savepoint.take() {
867 if let Some(revert) = self.savepoint.take() {
867− self.apply(&revert, view_id);
868+ self.apply(&revert, view.id);
869+ view.apply(&revert, self);
868 }
870 }
869 }
871 }
870
872