editor: Improve rewrap of markdown lists, todos, and block quotes (#33702)
Closes #19644 #18151 Now, rewrapping markdown lists (unordered, ordered, and to-do lists) and block quotes wrap them separately, without merging them together. Additionally, it correctly indents subsequent lines. With this input: ```md 1. This is a list item that is short. 2. This list item is a bit longer because I want to see if it wraps correctly after a rewrap operation in Zed. What do you think? 3. another short item ``` Output would be: ```md 1. This is a list item that is short. 2. This list item is a bit longer because I want to see if it wraps correctly after a rewrap operation in Zed. What do you think? 3. another short item ``` Instead of: ```md 1. This is a list item that is short. 2. This list item is a bit longer because I want to see if it wraps correctly after a rewrap operation in Zed. What do you think? 3. another short item ``` Release Notes: - Improved rewrap for markdown lists, todos, and block quotes.
This commit is contained in:
parent
0d809c21ba
commit
8fb3199a84
6 changed files with 256 additions and 61 deletions
|
@ -5210,6 +5210,10 @@ async fn test_rewrap(cx: &mut TestAppContext) {
|
|||
let markdown_language = Arc::new(Language::new(
|
||||
LanguageConfig {
|
||||
name: "Markdown".into(),
|
||||
rewrap_prefixes: vec![
|
||||
regex::Regex::new("\\d+\\.\\s+").unwrap(),
|
||||
regex::Regex::new("[-*+]\\s+").unwrap(),
|
||||
],
|
||||
..LanguageConfig::default()
|
||||
},
|
||||
None,
|
||||
|
@ -5372,7 +5376,82 @@ async fn test_rewrap(cx: &mut TestAppContext) {
|
|||
A long long long line of markdown text
|
||||
to wrap.ˇ
|
||||
"},
|
||||
markdown_language,
|
||||
markdown_language.clone(),
|
||||
&mut cx,
|
||||
);
|
||||
|
||||
// Test that rewrapping boundary works and preserves relative indent for Markdown documents
|
||||
assert_rewrap(
|
||||
indoc! {"
|
||||
«1. This is a numbered list item that is very long and needs to be wrapped properly.
|
||||
2. This is a numbered list item that is very long and needs to be wrapped properly.
|
||||
- This is an unordered list item that is also very long and should not merge with the numbered item.ˇ»
|
||||
"},
|
||||
indoc! {"
|
||||
«1. This is a numbered list item that is
|
||||
very long and needs to be wrapped
|
||||
properly.
|
||||
2. This is a numbered list item that is
|
||||
very long and needs to be wrapped
|
||||
properly.
|
||||
- This is an unordered list item that is
|
||||
also very long and should not merge
|
||||
with the numbered item.ˇ»
|
||||
"},
|
||||
markdown_language.clone(),
|
||||
&mut cx,
|
||||
);
|
||||
|
||||
// Test that rewrapping add indents for rewrapping boundary if not exists already.
|
||||
assert_rewrap(
|
||||
indoc! {"
|
||||
«1. This is a numbered list item that is
|
||||
very long and needs to be wrapped
|
||||
properly.
|
||||
2. This is a numbered list item that is
|
||||
very long and needs to be wrapped
|
||||
properly.
|
||||
- This is an unordered list item that is
|
||||
also very long and should not merge with
|
||||
the numbered item.ˇ»
|
||||
"},
|
||||
indoc! {"
|
||||
«1. This is a numbered list item that is
|
||||
very long and needs to be wrapped
|
||||
properly.
|
||||
2. This is a numbered list item that is
|
||||
very long and needs to be wrapped
|
||||
properly.
|
||||
- This is an unordered list item that is
|
||||
also very long and should not merge
|
||||
with the numbered item.ˇ»
|
||||
"},
|
||||
markdown_language.clone(),
|
||||
&mut cx,
|
||||
);
|
||||
|
||||
// Test that rewrapping maintain indents even when they already exists.
|
||||
assert_rewrap(
|
||||
indoc! {"
|
||||
«1. This is a numbered list
|
||||
item that is very long and needs to be wrapped properly.
|
||||
2. This is a numbered list
|
||||
item that is very long and needs to be wrapped properly.
|
||||
- This is an unordered list item that is also very long and
|
||||
should not merge with the numbered item.ˇ»
|
||||
"},
|
||||
indoc! {"
|
||||
«1. This is a numbered list item that is
|
||||
very long and needs to be wrapped
|
||||
properly.
|
||||
2. This is a numbered list item that is
|
||||
very long and needs to be wrapped
|
||||
properly.
|
||||
- This is an unordered list item that is
|
||||
also very long and should not merge
|
||||
with the numbered item.ˇ»
|
||||
"},
|
||||
markdown_language.clone(),
|
||||
&mut cx,
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue