@@ -26,7 +26,6 @@ use helix_core::{
26 SmallVec, Tendril, Transaction,
26 SmallVec, Tendril, Transaction,
28use helix_view::{
28use helix_view::{
30 clipboard::ClipboardType,
29 clipboard::ClipboardType,
31 document::{FormatterError, Mode, SCRATCH_BUFFER_NAME},
30 document::{FormatterError, Mode, SCRATCH_BUFFER_NAME},
32 editor::{Action, Motion},
31 editor::{Action, Motion},
@@ -864,7 +863,7 @@ fn align_selections(cx: &mut Context) {
864 changes.sort_unstable_by_key(|(from, _, _)| *from);
863 changes.sort_unstable_by_key(|(from, _, _)| *from);
866 let transaction = Transaction::change(doc.text(), changes.into_iter());
865 let transaction = Transaction::change(doc.text(), changes.into_iter());
867− apply_transaction(&transaction, doc, view);
866+ doc.apply(&transaction, view.id);
870fn goto_window(cx: &mut Context, align: Align) {
869fn goto_window(cx: &mut Context, align: Align) {
@@ -1316,7 +1315,7 @@ fn replace(cx: &mut Context) {
1319− apply_transaction(&transaction, doc, view);
1318+ doc.apply(&transaction, view.id);
1320 exit_select_mode(cx);
1319 exit_select_mode(cx);
@@ -1334,7 +1333,7 @@ where
1334 (range.from(), range.to(), Some(text))
1333 (range.from(), range.to(), Some(text))
1337− apply_transaction(&transaction, doc, view);
1336+ doc.apply(&transaction, view.id);
1340fn switch_case(cx: &mut Context) {
1339fn switch_case(cx: &mut Context) {
@@ -2159,7 +2158,7 @@ fn delete_selection_impl(cx: &mut Context, op: Operation) {
2159 let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
2158 let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
2160 (range.from(), range.to(), None)
2159 (range.from(), range.to(), None)
2162− apply_transaction(&transaction, doc, view);
2161+ doc.apply(&transaction, view.id);
2164 match op {
2163 match op {
2165 Operation::Delete => {
2164 Operation::Delete => {
@@ -2177,7 +2176,7 @@ fn delete_selection_insert_mode(doc: &mut Document, view: &mut View, selection:
2177 let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
2176 let transaction = Transaction::change_by_selection(doc.text(), selection, |range| {
2178 (range.from(), range.to(), None)
2177 (range.from(), range.to(), None)
2180− apply_transaction(&transaction, doc, view);
2179+ doc.apply(&transaction, view.id);
2183fn delete_selection(cx: &mut Context) {
2182fn delete_selection(cx: &mut Context) {
@@ -2273,7 +2272,7 @@ fn append_mode(cx: &mut Context) {
2273 doc.text(),
2272 doc.text(),
2274 [(end, end, Some(doc.line_ending.as_str().into()))].into_iter(),
2273 [(end, end, Some(doc.line_ending.as_str().into()))].into_iter(),
2276− apply_transaction(&transaction, doc, view);
2275+ doc.apply(&transaction, view.id);
2279 let selection = doc.selection(view.id).clone().transform(|range| {
2278 let selection = doc.selection(view.id).clone().transform(|range| {
@@ -2583,7 +2582,7 @@ async fn make_format_callback(
2584 if let Ok(format) = format {
2583 if let Ok(format) = format {
2585 if doc.version() == doc_version {
2584 if doc.version() == doc_version {
2586− apply_transaction(&format, doc, view);
2585+ doc.apply(&format, view.id);
2587 doc.append_changes_to_history(view);
2586 doc.append_changes_to_history(view);
2588 doc.detect_indent_and_line_ending();
2587 doc.detect_indent_and_line_ending();
2589 view.ensure_cursor_in_view(doc, scrolloff);
2588 view.ensure_cursor_in_view(doc, scrolloff);
@@ -2676,7 +2675,7 @@ fn open(cx: &mut Context, open: Open) {
2677 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
2676 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
2679− apply_transaction(&transaction, doc, view);
2678+ doc.apply(&transaction, view.id);
2682// o inserts a new line after each line with a selection
2681// o inserts a new line after each line with a selection
@@ -3104,7 +3103,7 @@ pub mod insert {
3105 let (view, doc) = current!(cx.editor);
3104 let (view, doc) = current!(cx.editor);
3106 if let Some(t) = transaction {
3105 if let Some(t) = transaction {
3107− apply_transaction(&t, doc, view);
3106+ doc.apply(&t, view.id);
3110 // TODO: need a post insert hook too for certain triggers (autocomplete, signature help, etc)
3109 // TODO: need a post insert hook too for certain triggers (autocomplete, signature help, etc)
@@ -3126,7 +3125,7 @@ pub mod insert {
3126 &doc.selection(view.id).clone().cursors(doc.text().slice(..)),
3125 &doc.selection(view.id).clone().cursors(doc.text().slice(..)),
3129− apply_transaction(&transaction, doc, view);
3128+ doc.apply(&transaction, view.id);
3132 pub fn insert_newline(cx: &mut Context) {
3131 pub fn insert_newline(cx: &mut Context) {
@@ -3231,7 +3230,7 @@ pub mod insert {
3231 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
3230 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
3233 let (view, doc) = current!(cx.editor);
3232 let (view, doc) = current!(cx.editor);
3234− apply_transaction(&transaction, doc, view);
3233+ doc.apply(&transaction, view.id);
3237 pub fn delete_char_backward(cx: &mut Context) {
3236 pub fn delete_char_backward(cx: &mut Context) {
@@ -3326,7 +3325,7 @@ pub mod insert {
3328 let (view, doc) = current!(cx.editor);
3327 let (view, doc) = current!(cx.editor);
3329− apply_transaction(&transaction, doc, view);
3328+ doc.apply(&transaction, view.id);
3331 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
3330 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
@@ -3344,7 +3343,7 @@ pub mod insert {
3347− apply_transaction(&transaction, doc, view);
3346+ doc.apply(&transaction, view.id);
3349 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
3348 lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
@@ -3625,7 +3624,7 @@ fn paste_impl(
3625 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
3624 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
3628− apply_transaction(&transaction, doc, view);
3627+ doc.apply(&transaction, view.id);
3631pub(crate) fn paste_bracketed_value(cx: &mut Context, contents: String) {
3630pub(crate) fn paste_bracketed_value(cx: &mut Context, contents: String) {
@@ -3717,7 +3716,7 @@ fn replace_with_yanked(cx: &mut Context) {
3720− apply_transaction(&transaction, doc, view);
3719+ doc.apply(&transaction, view.id);
3721 exit_select_mode(cx);
3720 exit_select_mode(cx);
@@ -3741,7 +3740,7 @@ fn replace_selections_with_clipboard_impl(
3744− apply_transaction(&transaction, doc, view);
3743+ doc.apply(&transaction, view.id);
3745 doc.append_changes_to_history(view);
3744 doc.append_changes_to_history(view);
3747 Err(e) => return Err(e.context("Couldn't get system clipboard contents")),
3746 Err(e) => return Err(e.context("Couldn't get system clipboard contents")),
@@ -3813,7 +3812,7 @@ fn indent(cx: &mut Context) {
3813 Some((pos, pos, Some(indent.clone())))
3812 Some((pos, pos, Some(indent.clone())))
3816− apply_transaction(&transaction, doc, view);
3815+ doc.apply(&transaction, view.id);
3819fn unindent(cx: &mut Context) {
3818fn unindent(cx: &mut Context) {
@@ -3852,7 +3851,7 @@ fn unindent(cx: &mut Context) {
3853 let transaction = Transaction::change(doc.text(), changes.into_iter());
3852 let transaction = Transaction::change(doc.text(), changes.into_iter());
3855− apply_transaction(&transaction, doc, view);
3854+ doc.apply(&transaction, view.id);
3858fn format_selections(cx: &mut Context) {
3857fn format_selections(cx: &mut Context) {
@@ -3907,7 +3906,7 @@ fn format_selections(cx: &mut Context) {
3907 language_server.offset_encoding(),
3906 language_server.offset_encoding(),
3910− apply_transaction(&transaction, doc, view);
3909+ doc.apply(&transaction, view.id);
3913fn join_selections_impl(cx: &mut Context, select_space: bool) {
3912fn join_selections_impl(cx: &mut Context, select_space: bool) {
@@ -3966,7 +3965,7 @@ fn join_selections_impl(cx: &mut Context, select_space: bool) {
3966 Transaction::change(doc.text(), changes.into_iter())
3965 Transaction::change(doc.text(), changes.into_iter())
3969− apply_transaction(&transaction, doc, view);
3968+ doc.apply(&transaction, view.id);
3972fn keep_or_remove_selections_impl(cx: &mut Context, remove: bool) {
3971fn keep_or_remove_selections_impl(cx: &mut Context, remove: bool) {
@@ -4109,7 +4108,7 @@ fn toggle_comments(cx: &mut Context) {
4109 .map(|tc| tc.as_ref());
4108 .map(|tc| tc.as_ref());
4110 let transaction = comment::toggle_line_comments(doc.text(), doc.selection(view.id), token);
4109 let transaction = comment::toggle_line_comments(doc.text(), doc.selection(view.id), token);
4112− apply_transaction(&transaction, doc, view);
4111+ doc.apply(&transaction, view.id);
4113 exit_select_mode(cx);
4112 exit_select_mode(cx);
@@ -4165,7 +4164,7 @@ fn rotate_selection_contents(cx: &mut Context, direction: Direction) {
4165 .map(|(range, fragment)| (range.from(), range.to(), Some(fragment))),
4164 .map(|(range, fragment)| (range.from(), range.to(), Some(fragment))),
4168− apply_transaction(&transaction, doc, view);
4167+ doc.apply(&transaction, view.id);
4171fn rotate_selection_contents_forward(cx: &mut Context) {
4170fn rotate_selection_contents_forward(cx: &mut Context) {
@@ -4698,7 +4697,7 @@ fn surround_add(cx: &mut Context) {
4699 let transaction = Transaction::change(doc.text(), changes.into_iter())
4698 let transaction = Transaction::change(doc.text(), changes.into_iter())
4700 .with_selection(Selection::new(ranges, selection.primary_index()));
4699 .with_selection(Selection::new(ranges, selection.primary_index()));
4701− apply_transaction(&transaction, doc, view);
4700+ doc.apply(&transaction, view.id);
4702 exit_select_mode(cx);
4701 exit_select_mode(cx);
@@ -4738,7 +4737,7 @@ fn surround_replace(cx: &mut Context) {
4738 (pos, pos + 1, Some(t))
4737 (pos, pos + 1, Some(t))
4741− apply_transaction(&transaction, doc, view);
4740+ doc.apply(&transaction, view.id);
4742 exit_select_mode(cx);
4741 exit_select_mode(cx);
@@ -4766,7 +4765,7 @@ fn surround_delete(cx: &mut Context) {
4767 let transaction =
4766 let transaction =
4768 Transaction::change(doc.text(), change_pos.into_iter().map(|p| (p, p + 1, None)));
4767 Transaction::change(doc.text(), change_pos.into_iter().map(|p| (p, p + 1, None)));
4769− apply_transaction(&transaction, doc, view);
4768+ doc.apply(&transaction, view.id);
4770 exit_select_mode(cx);
4769 exit_select_mode(cx);
@@ -4981,7 +4980,7 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
4981 if behavior != &ShellBehavior::Ignore {
4980 if behavior != &ShellBehavior::Ignore {
4982 let transaction = Transaction::change(doc.text(), changes.into_iter())
4981 let transaction = Transaction::change(doc.text(), changes.into_iter())
4983 .with_selection(Selection::new(ranges, selection.primary_index()));
4982 .with_selection(Selection::new(ranges, selection.primary_index()));
4984− apply_transaction(&transaction, doc, view);
4983+ doc.apply(&transaction, view.id);
4985 doc.append_changes_to_history(view);
4984 doc.append_changes_to_history(view);
@@ -5044,7 +5043,7 @@ fn add_newline_impl(cx: &mut Context, open: Open) {
5046 let transaction = Transaction::change(text, changes);
5045 let transaction = Transaction::change(text, changes);
5047− apply_transaction(&transaction, doc, view);
5046+ doc.apply(&transaction, view.id);
5050enum IncrementDirection {
5049enum IncrementDirection {
@@ -5111,7 +5110,7 @@ fn increment_impl(cx: &mut Context, increment_direction: IncrementDirection) {
5111 let new_selection = Selection::new(new_selection_ranges, selection.primary_index());
5110 let new_selection = Selection::new(new_selection_ranges, selection.primary_index());
5112 let transaction = Transaction::change(doc.text(), changes.into_iter());
5111 let transaction = Transaction::change(doc.text(), changes.into_iter());
5113 let transaction = transaction.with_selection(new_selection);
5112 let transaction = transaction.with_selection(new_selection);
5114− apply_transaction(&transaction, doc, view);
5113+ doc.apply(&transaction, view.id);