documents: lists go on, block lines shift, tables change, matches show, fences color by language
CI / platforms (windows-latest) (push) Failing after 9s
CI / site (push) Successful in 21s
CI / crate (push) Failing after 11m41s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

The document carries Markdown's editing tools for ElyMark (MARK-06):
Enter continues a list item or ends an empty one, Tab and Shift-Tab
shift an open block's lines, table rows and columns come and go as
one undo step, a match shows in any mode, replacements are one step,
and a fenced block colors by its language.

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 06:14:34 -04:00
1 parent 2e196a10a7
commit ce4a1e9cb5
12 files changed
+680 -8

No files matched your search

+1
View File
@@ -368,6 +368,7 @@ fn a_press_after_a_write_back_waits_for_the_long_read(cx: &mut TestAppContext) {
mod history;
mod links;
mod place;
mod tools;
#[gpui::test]
fn typed_source_reads_after_a_pause(cx: &mut TestAppContext) {
+95
View File
@@ -0,0 +1,95 @@
use gpui::{Modifiers, TestAppContext};
use super::{MarkdownMode, open, opened, press, text};
#[gpui::test]
fn enter_in_source_goes_on_with_the_list(cx: &mut TestAppContext) {
let (document, cx) = open("- a", MarkdownMode::Source, cx);
document.update(cx, |document, cx| document.set_caret(0, 3, cx));
let editor = document.read_with(cx, |document, _| document.editor().clone());
let focus = editor.read_with(cx, gpui::Focusable::focus_handle);
cx.update(|window, cx| window.focus(&focus, cx));
cx.simulate_keystrokes("enter");
cx.simulate_input("b");
assert_eq!(text(&document, cx), "- a\n- b");
cx.simulate_keystrokes("enter enter");
assert_eq!(
text(&document, cx),
"- a\n- b\n",
"an empty item ends the list"
);
}
#[gpui::test]
fn enter_in_a_block_goes_on_with_the_list(cx: &mut TestAppContext) {
let (document, cx) = open("1. a\n", MarkdownMode::Visual, cx);
press(0, Modifiers::none(), cx);
cx.simulate_keystrokes("enter");
cx.simulate_input("b");
assert_eq!(opened(&document, cx), "1. a\n2. b");
}
#[gpui::test]
fn tab_shifts_a_block_line_in_and_out(cx: &mut TestAppContext) {
let (document, cx) = open("- a\n- b\n", MarkdownMode::Visual, cx);
press(0, Modifiers::none(), cx);
cx.simulate_keystrokes("tab");
assert_eq!(opened(&document, cx), "- a\n - b");
cx.simulate_keystrokes("shift-tab");
assert_eq!(opened(&document, cx), "- a\n- b");
}
#[gpui::test]
fn a_table_edit_is_one_undo_step_at_the_caret(cx: &mut TestAppContext) {
let (document, cx) = open("| A |\n| - |\n| 1 |\n", MarkdownMode::Source, cx);
document.update(cx, |document, cx| document.set_caret(2, 2, cx));
let edited = document.update(cx, |document, cx| {
document.edit_table(crate::documents::TableEdit::RowBelow, cx)
});
assert!(edited);
assert_eq!(text(&document, cx), "| A |\n| --- |\n| 1 |\n| |\n");
let editor = document.read_with(cx, |document, _| document.editor().clone());
editor.update(cx, |editor, cx| editor.undo(cx));
assert_eq!(text(&document, cx), "| A |\n| - |\n| 1 |\n");
}
#[gpui::test]
fn a_new_table_goes_after_the_caret_line(cx: &mut TestAppContext) {
let (document, cx) = open("Intro\nNext\n", MarkdownMode::Visual, cx);
document.update(cx, |document, cx| document.insert_table(cx));
assert_eq!(
text(&document, cx),
"Intro\n\n| | | |\n| --- | --- | --- |\n| | | |\n| | | |\n\nNext\n"
);
}
#[gpui::test]
fn a_match_in_visual_opens_its_block_selected(cx: &mut TestAppContext) {
let (document, cx) = open("# A\n\nfind me here\n", MarkdownMode::Visual, cx);
let at = "# A\n\nfind me here\n".find("me").expect("the word");
document.update_in(cx, |document, window, cx| {
document.show_match(at..at + 2, window, cx)
});
let selected = document.read_with(cx, |document, cx| {
let input = document
.open
.as_ref()
.expect("a block opens")
.input
.read(cx);
input.text()[input.selection()].to_string()
});
assert_eq!(selected, "me");
}
#[gpui::test]
fn every_replacement_is_one_undo_step(cx: &mut TestAppContext) {
let (document, cx) = open("a b a", MarkdownMode::Visual, cx);
document.update(cx, |document, cx| {
document.replace(vec![(0..1, "x".into()), (4..5, "x".into())], cx)
});
assert_eq!(text(&document, cx), "x b x");
let editor = document.read_with(cx, |document, _| document.editor().clone());
editor.update(cx, |editor, cx| editor.undo(cx));
assert_eq!(text(&document, cx), "a b a");
}