documents: table edits keep extra cells and quote marks and say why they refuse; preview takes no edits; lists go on only in list items; a match waits for its text
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ce4a1e9cb5
commit
edc328aadf
7 files changed
+273
-59
No files matched your search
@@ -22,11 +22,13 @@ impl MarkdownDocument {
|
||||
}
|
||||
MarkdownMode::Preview => self.reveal(line(self, cx), window, cx),
|
||||
MarkdownMode::Visual => {
|
||||
if self.commit(cx).is_some() {
|
||||
if self.commit(cx).is_some() || !self.read_now(cx) {
|
||||
self.reparse(true, cx);
|
||||
}
|
||||
if !self.read_now(cx) {
|
||||
return log::warn!("markdown document: a match shown while the text is read");
|
||||
// A long text: shown once read.
|
||||
self.showing = Some(range);
|
||||
return cx.notify();
|
||||
}
|
||||
let ix = self.block_at(range.start);
|
||||
let held = self.parsed.blocks.get(ix).map(|block| block.range.clone());
|
||||
@@ -48,10 +50,39 @@ impl MarkdownDocument {
|
||||
}
|
||||
}
|
||||
|
||||
/// `edits` to the text as one undo step.
|
||||
pub fn replace(&mut self, edits: Vec<(Range<usize>, String)>, cx: &mut Context<Self>) {
|
||||
/// A match asked before its text was read, now shown.
|
||||
pub(super) fn show_waiting(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.showing.is_none() || !self.read_now(cx) {
|
||||
return;
|
||||
}
|
||||
let range = self.showing.take().expect("checked above");
|
||||
let text = self.editor.read(cx).text();
|
||||
let fits = range.end <= text.len()
|
||||
&& text.is_char_boundary(range.start)
|
||||
&& text.is_char_boundary(range.end);
|
||||
if !fits {
|
||||
return log::warn!("markdown document: a waiting match outlived its text");
|
||||
}
|
||||
self.show_match(range, window, cx);
|
||||
}
|
||||
|
||||
/// `edits` as one undo step; false in preview.
|
||||
pub fn replace(&mut self, edits: Vec<(Range<usize>, String)>, cx: &mut Context<Self>) -> bool {
|
||||
if self.mode == MarkdownMode::Preview {
|
||||
return false;
|
||||
}
|
||||
self.commit(cx);
|
||||
let text = self.editor.read(cx).text();
|
||||
if edits
|
||||
.iter()
|
||||
.all(|(range, with)| text[range.clone()] == *with)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
log::info!("markdown document: {} replaced", edits.len());
|
||||
// Its own change: an open block outlives it.
|
||||
self.writes += 1;
|
||||
self.editor.update(cx, |editor, cx| editor.edit(edits, cx));
|
||||
true
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user