@@ -860,6 +860,7 @@ fn align_selections(cx: &mut Context) {
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);
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) {
1292 doc.apply(&transaction, view.id);
1293 doc.apply(&transaction, view.id);
1294+ view.apply(&transaction, doc);
@@ -1307,6 +1309,7 @@ where
1309 doc.apply(&transaction, view.id);
1311 doc.apply(&transaction, view.id);
1312+ view.apply(&transaction, doc);
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)
2115 doc.apply(&transaction, view.id);
2118 doc.apply(&transaction, view.id);
2119+ view.apply(&transaction, doc);
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) {
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;
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)
2136 doc.apply(&transaction, view_id);
2140 doc.apply(&transaction, view_id);
2141+ view.apply(&transaction, doc);
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(),
2232 doc.apply(&transaction, view.id);
2237 doc.apply(&transaction, view.id);
2238+ view.apply(&transaction, doc);
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()));
2619 doc.apply(&transaction, view.id);
2626 doc.apply(&transaction, view.id);
2627+ view.apply(&transaction, doc);
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);
2640− try_restore_indent(doc, view.id);
2648+ try_restore_indent(doc, view);
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) {
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;
@@ -2673,18 +2681,19 @@ fn try_restore_indent(doc: &mut Document, view_id: ViewId) {
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));
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)
2687− doc.apply(&transaction, view_id);
2695+ doc.apply(&transaction, view.id);
2696+ view.apply(&transaction, doc);
@@ -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);
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 {
3023 doc.apply(&transaction, view.id);
3033 doc.apply(&transaction, view.id);
3034+ view.apply(&transaction, doc);
3026 pub fn insert_newline(cx: &mut Context) {
3037 pub fn insert_newline(cx: &mut Context) {
@@ -3108,6 +3119,7 @@ pub mod insert {
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);
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 {
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);
3206 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
3219 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
@@ -3220,6 +3233,7 @@ pub mod insert {
3222 doc.apply(&transaction, view.id);
3235 doc.apply(&transaction, view.id);
3236+ view.apply(&transaction, doc);
3224 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
3238 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
@@ -3413,7 +3427,7 @@ enum Paste {
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(
@@ -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())
3459 doc.apply(&transaction, view.id);
3473 doc.apply(&transaction, view.id);
3474+ view.apply(&transaction, doc);
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) {
3551 doc.apply(&transaction, view.id);
3566 doc.apply(&transaction, view.id);
3567+ view.apply(&transaction, doc);
@@ -3572,6 +3588,7 @@ fn replace_selections_with_clipboard_impl(
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);
@@ -3642,6 +3659,7 @@ fn indent(cx: &mut Context) {
3644 doc.apply(&transaction, view.id);
3661 doc.apply(&transaction, view.id);
3662+ view.apply(&transaction, doc);
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());
3683 doc.apply(&transaction, view.id);
3701 doc.apply(&transaction, view.id);
3702+ view.apply(&transaction, doc);
3686fn format_selections(cx: &mut Context) {
3705fn format_selections(cx: &mut Context) {
@@ -3728,6 +3747,7 @@ fn format_selections(cx: &mut Context) {
3730 // doc.apply(&transaction, view.id);
3749 // doc.apply(&transaction, view.id);
3750+ // view.apply(&transaction, doc);
@@ -3783,6 +3803,7 @@ fn join_selections_inner(cx: &mut Context, select_space: bool) {
3785 doc.apply(&transaction, view.id);
3805 doc.apply(&transaction, view.id);
3806+ view.apply(&transaction, doc);
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);
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);
@@ -3992,6 +4014,7 @@ fn rotate_selection_contents(cx: &mut Context, direction: Direction) {
3994 doc.apply(&transaction, view.id);
4016 doc.apply(&transaction, view.id);
4017+ view.apply(&transaction, doc);
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) {
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);
@@ -4527,6 +4551,7 @@ fn surround_replace(cx: &mut Context) {
4529 doc.apply(&transaction, view.id);
4553 doc.apply(&transaction, view.id);
4554+ view.apply(&transaction, doc);
@@ -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);
@@ -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);
@@ -4792,6 +4819,7 @@ fn add_newline_impl(cx: &mut Context, open: Open) {
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);
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());
4887 doc.apply(&transaction, view.id);
4915 doc.apply(&transaction, view.id);
4916+ view.apply(&transaction, doc);