documents: an empty visual document opens its end on focus
CI / platforms (windows-latest) (push) Failing after 9s
CI / site (push) Successful in 22s
CI / crate (push) Failing after 11m48s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

Typing in a new file lands with no press.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-12 03:52:55 -04:00
1 parent f59c9f7f50
commit 6f0401e967
3 files changed
+47 -6

No files matched your search

+28
View File
@@ -397,3 +397,31 @@ fn a_text_past_the_largest_read_is_never_read(cx: &mut TestAppContext) {
});
assert_eq!((blocks, outline), (0, 0), "the old read is gone");
}
/// Focus on `document`'s own handle, as an owner gives it.
fn focus(document: &Entity<MarkdownDocument>, cx: &mut VisualTestContext) {
let handle = document.read_with(cx, |document, cx| {
gpui::Focusable::focus_handle(document, cx)
});
cx.update(|window, cx| window.focus(&handle, cx));
cx.run_until_parked();
}
#[gpui::test]
fn an_empty_visual_document_takes_typing_on_focus(cx: &mut TestAppContext) {
let (document, cx) = open("", MarkdownMode::Visual, cx);
focus(&document, cx);
cx.simulate_input("Hi");
assert_eq!(text(&document, cx), "Hi", "typing lands with no press");
cx.simulate_keystrokes("escape");
cx.run_until_parked();
assert_eq!(text(&document, cx), "Hi", "escape keeps it");
}
#[gpui::test]
fn focus_opens_no_block_in_a_written_document(cx: &mut TestAppContext) {
let (document, cx) = open(TEXT, MarkdownMode::Visual, cx);
focus(&document, cx);
cx.simulate_input("x");
assert_eq!(text(&document, cx), TEXT);
}