Skip to content

Commit

Permalink
Use helix_view::apply_transaction in integration-tests
Browse files Browse the repository at this point in the history
`helix_view::apply_transaction` closes over `Document::apply` and
`View::apply` to ensure that jumplist entries are updated when a
document changes from a transaction. `Document::apply` shouldn't
be called directly - this helper function should be used instead.
  • Loading branch information
the-mikedavis authored and Shekhinah Memmel committed Dec 11, 2022
1 parent 9977a12 commit 5d68bc9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions helix-term/tests/test/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,12 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
let sel = doc.selection(view.id).clone();

// replace the initial text with the input text
doc.apply(
&Transaction::change_by_selection(doc.text(), &sel, |_| {
(0, doc.text().len_chars(), Some((&test_case.in_text).into()))
})
.with_selection(test_case.in_selection.clone()),
view.id,
);
let transaction = Transaction::change_by_selection(doc.text(), &sel, |_| {
(0, doc.text().len_chars(), Some((&test_case.in_text).into()))
})
.with_selection(test_case.in_selection.clone());

helix_view::apply_transaction(&transaction, doc, view);

test_key_sequence(
&mut app,
Expand Down Expand Up @@ -286,7 +285,7 @@ impl AppBuilder {
.with_selection(selection);

// replace the initial text with the input text
doc.apply(&trans, view.id);
helix_view::apply_transaction(&trans, doc, view);
}

Ok(app)
Expand Down

0 comments on commit 5d68bc9

Please sign in to comment.