documents: a text past the read limit drops the old read
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
69b11d7852
commit
f59c9f7f50
2 files changed
+12
-5
No files matched your search
@@ -234,7 +234,13 @@ impl MarkdownDocument {
|
||||
let (text, edits) = (self.editor.read(cx).text().to_string(), self.edits);
|
||||
if text.len() > LARGEST_READ {
|
||||
self._parsing = None;
|
||||
return log::info!("markdown document: {} bytes, too long to read", text.len());
|
||||
log::info!("markdown document: {} bytes, too long to read", text.len());
|
||||
// Nothing read: no blocks, no headings.
|
||||
let unread = Parsed {
|
||||
text,
|
||||
..Parsed::default()
|
||||
};
|
||||
return self.adopt(unread, edits, cx);
|
||||
}
|
||||
if now && text.len() <= AT_ONCE {
|
||||
self._parsing = None;
|
||||
|
||||
@@ -387,12 +387,13 @@ fn typed_source_reads_after_a_pause(cx: &mut TestAppContext) {
|
||||
|
||||
#[gpui::test]
|
||||
fn a_text_past_the_largest_read_is_never_read(cx: &mut TestAppContext) {
|
||||
let (document, cx) = open("# Old\n", MarkdownMode::Source, cx);
|
||||
let long = "a\n".repeat(super::LARGEST_READ / 2 + 1);
|
||||
let (document, cx) = open(&long, MarkdownMode::Source, cx);
|
||||
document.update(cx, |document, cx| document.set_text(long, cx));
|
||||
cx.executor().advance_clock(super::PAUSE);
|
||||
cx.run_until_parked();
|
||||
let (read, outline) = document.read_with(cx, |document, cx| {
|
||||
(document.read_now(cx), document.outline(cx).len())
|
||||
let (blocks, outline) = document.read_with(cx, |document, cx| {
|
||||
(document.parsed.blocks.len(), document.outline(cx).len())
|
||||
});
|
||||
assert!(!read && outline == 0);
|
||||
assert_eq!((blocks, outline), (0, 0), "the old read is gone");
|
||||
}
|
||||
Reference in new issue
Block a user