fix: keep large-file editing responsive
Bound synchronous full-source syntax parsing, cache dirty comparisons, edit ordinary inline changes in place, retain changed-row undo history, and buffer atomic saves. Skip repository snapshots beyond existing worker limits before copying their text.
This commit is contained in:
@@ -4,6 +4,47 @@ use std::{
|
||||
sync::atomic::{AtomicU64, Ordering},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn oversized_repository_text_skips_snapshots_and_recovers_after_shrinking() {
|
||||
let fixture = Fixture::new();
|
||||
let path = fixture.file("buffer.txt", "small\n");
|
||||
let mut session = EditorSession::open(Some(path.clone()), vec![], None).unwrap();
|
||||
let buffer = session.editor.buffer_id();
|
||||
session.editor.set_gutter_changes(
|
||||
buffer,
|
||||
session.editor.text_revision(),
|
||||
&path,
|
||||
vec![Some(crate::gutter::Change::Added)],
|
||||
);
|
||||
assert_eq!(
|
||||
session.editor.gutter_change(0),
|
||||
Some(crate::gutter::Change::Added)
|
||||
);
|
||||
fs::write(&path, "x".repeat(crate::gutter::FILE_LIMIT + 1)).unwrap();
|
||||
assert!(session.editor.refresh_files());
|
||||
session.poll_gutter_at(Instant::now());
|
||||
session.synchronize_documents();
|
||||
let source = session
|
||||
.gutter_sources
|
||||
.iter()
|
||||
.find(|source| source.buffer == buffer)
|
||||
.unwrap();
|
||||
assert!(source.contents.is_none());
|
||||
assert!(session.blame_worker.is_none());
|
||||
assert_eq!(session.editor.gutter_change(0), None);
|
||||
fs::write(&path, "small again\n").unwrap();
|
||||
assert!(session.editor.refresh_files());
|
||||
session.poll_gutter_at(Instant::now());
|
||||
session.synchronize_documents();
|
||||
let source = session
|
||||
.gutter_sources
|
||||
.iter()
|
||||
.find(|source| source.buffer == buffer)
|
||||
.unwrap();
|
||||
assert_eq!(source.contents.as_deref(), Some("small again\n"));
|
||||
assert!(session.blame_worker.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolver_load_errors_return_through_real_session_without_touching_the_draft() {
|
||||
let fixture = Fixture::new();
|
||||
|
||||
Reference in New Issue
Block a user