documents: undo in an untouched block steps the document; visual after preview opens an empty end
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6f0401e967
commit
362a0fc9fa
4 files changed
+86
-8
No files matched your search
@@ -425,3 +425,50 @@ fn focus_opens_no_block_in_a_written_document(cx: &mut TestAppContext) {
|
||||
cx.simulate_input("x");
|
||||
assert_eq!(text(&document, cx), TEXT);
|
||||
}
|
||||
|
||||
fn mode(document: &Entity<MarkdownDocument>, mode: MarkdownMode, cx: &mut VisualTestContext) {
|
||||
document.update_in(cx, |document, window, cx| {
|
||||
document.set_mode(mode, window, cx)
|
||||
});
|
||||
cx.run_until_parked();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn preview_and_back_still_take_typing_in_an_empty_document(cx: &mut TestAppContext) {
|
||||
let (document, cx) = open("", MarkdownMode::Visual, cx);
|
||||
focus(&document, cx);
|
||||
cx.simulate_keystrokes("escape");
|
||||
mode(&document, MarkdownMode::Preview, cx);
|
||||
mode(&document, MarkdownMode::Visual, cx);
|
||||
cx.simulate_input("Hi");
|
||||
assert_eq!(text(&document, cx), "Hi");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn undo_in_an_untouched_block_steps_the_document(cx: &mut TestAppContext) {
|
||||
let (document, cx) = open("Seed", MarkdownMode::Source, cx);
|
||||
document.update(cx, |document, cx| document.set_text("", cx));
|
||||
mode(&document, MarkdownMode::Visual, cx);
|
||||
cx.simulate_keystrokes("secondary-z");
|
||||
cx.run_until_parked();
|
||||
assert_eq!(text(&document, cx), "Seed", "the source edit is undone");
|
||||
cx.simulate_keystrokes("secondary-shift-z");
|
||||
cx.run_until_parked();
|
||||
assert_eq!(text(&document, cx), "", "and redone");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn undo_in_a_typed_block_stays_in_the_block(cx: &mut TestAppContext) {
|
||||
let (document, cx) = open("Seed", MarkdownMode::Source, cx);
|
||||
document.update(cx, |document, cx| document.set_text(TEXT, cx));
|
||||
mode(&document, MarkdownMode::Visual, cx);
|
||||
press(1, Modifiers::none(), cx);
|
||||
cx.simulate_input(" x");
|
||||
cx.simulate_keystrokes("secondary-z");
|
||||
cx.run_until_parked();
|
||||
assert_eq!(
|
||||
text(&document, cx),
|
||||
TEXT,
|
||||
"the typing went, not the edit before"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user