documents: an empty task ends a list; Shift-Tab takes a tab out; a table on a blank indented line is a table
CI / platforms (windows-latest) (push) Failing after 8s
CI / site (push) Successful in 22s
CI / crate (push) Failing after 11m41s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

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 07:17:24 -04:00
1 parent e162082f6f
commit 4fb59bb8e1
3 files changed
+61 -9

No files matched your search

+9 -3
View File
@@ -50,10 +50,14 @@ pub(super) fn enter(source: &str, at: usize) -> Option<(Range<usize>, String)> {
"" => " ",
written => written,
};
let task = matches!(item, mdast::Node::ListItem(item) if item.checked.is_some());
let body = source[start + after..span(item).end].trim_start();
let body = match task {
true => body.get(3..).unwrap_or_default(),
// A bare box has no `checked`: it is still a task.
let boxed = ["[ ]", "[x]", "[X]"]
.iter()
.any(|task| body.starts_with(task));
let task = boxed || matches!(item, mdast::Node::ListItem(item) if item.checked.is_some());
let body = match boxed {
true => &body[3..],
false => body,
};
let end = source[at..]
@@ -101,6 +105,8 @@ pub(super) fn shift(text: &str, range: Range<usize>, deeper: bool) -> (String, R
let spaces = line.len() - line.trim_start_matches(' ').len();
match deeper {
true => changes.push((at, STEP as isize)),
// A leading tab is one step out.
false if line.starts_with('\t') => changes.push((at, -1)),
false if spaces > 0 => changes.push((at, -(spaces.min(STEP) as isize))),
false => {}
}