Keep desktop previews visible and open project sources before compiling
This commit is contained in:
1 parent
a2c4a2b3a9
commit
68e5260d40
7 files changed
+357
-130
No files matched your search
@@ -145,6 +145,7 @@ enum ExecutionCandidate {
|
||||
}
|
||||
|
||||
const SOURCE_INTERVALS: usize = 4;
|
||||
const MIN_PREAMBLE_INTERVAL_BYTES: usize = 4096;
|
||||
const DENSE_SETTLED_PAGES: usize = 4;
|
||||
const SPARSE_SETTLED_SLOTS: usize = 4;
|
||||
|
||||
@@ -165,6 +166,7 @@ struct CaptureSchedule {
|
||||
fixed_frontier: Option<usize>,
|
||||
pending_edit_frontier: Option<usize>,
|
||||
pending_edit_fallback: Option<usize>,
|
||||
pending_preamble: Option<usize>,
|
||||
pending_line_end: Option<(usize, CaptureSlots, usize)>,
|
||||
settled_page: usize,
|
||||
}
|
||||
@@ -175,6 +177,7 @@ struct CaptureSlots {
|
||||
early: bool,
|
||||
page: bool,
|
||||
edit: bool,
|
||||
preamble: bool,
|
||||
next_page: usize,
|
||||
}
|
||||
|
||||
@@ -236,11 +239,21 @@ impl CaptureSchedule {
|
||||
fixed_frontier,
|
||||
pending_edit_frontier: edit_frontier,
|
||||
pending_edit_fallback: None,
|
||||
pending_preamble: None,
|
||||
pending_line_end: None,
|
||||
settled_page: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn with_preamble_anchor(mut self, source: &[u8]) -> Self {
|
||||
if self.fixed_frontier.is_none() && self.stride >= MIN_PREAMBLE_INTERVAL_BYTES {
|
||||
// The first grid interval can span both package loading and
|
||||
// LaTeX's generated-input reads. Keep one boundary between them.
|
||||
self.pending_preamble = preamble_frontier(source, self.stride);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
fn select_source(&mut self, source: CheckpointSource<'_>, pages: usize) -> Option<Capture> {
|
||||
let regular = self.select(source.frontier, pages);
|
||||
let mut line_end = None;
|
||||
@@ -305,6 +318,7 @@ impl CaptureSchedule {
|
||||
early: true,
|
||||
page: false,
|
||||
edit: false,
|
||||
preamble: false,
|
||||
next_page: self.next_page,
|
||||
});
|
||||
}
|
||||
@@ -321,11 +335,13 @@ impl CaptureSchedule {
|
||||
self.next_page = pages.saturating_add((pages / 8).max(1).next_power_of_two());
|
||||
}
|
||||
let edit = !entry_complete && self.take_edit_frontier(frontier, early || page);
|
||||
(early || page || edit).then_some(CaptureSlots {
|
||||
let preamble = self.pending_preamble.take_if(|pending| *pending == frontier).is_some();
|
||||
(early || page || edit || preamble).then_some(CaptureSlots {
|
||||
interval,
|
||||
early,
|
||||
page,
|
||||
edit,
|
||||
preamble,
|
||||
next_page: self.next_page,
|
||||
})
|
||||
}
|
||||
@@ -346,6 +362,8 @@ impl CaptureSchedule {
|
||||
early,
|
||||
edit: frontier < self.bytes
|
||||
&& self.take_edit_frontier(frontier, early || slots.page),
|
||||
preamble: frontier < self.bytes
|
||||
&& self.pending_preamble.take_if(|pending| *pending == frontier).is_some(),
|
||||
..slots
|
||||
})
|
||||
}
|
||||
@@ -358,6 +376,7 @@ struct CapturedEntries<'a> {
|
||||
early: [Option<Arc<CachedCheckpoint>>; SOURCE_INTERVALS],
|
||||
shipped: [Option<Arc<CachedCheckpoint>>; SOURCE_INTERVALS],
|
||||
edit: Option<Arc<CachedCheckpoint>>,
|
||||
preamble: Option<Arc<CachedCheckpoint>>,
|
||||
nested: [[Option<Arc<CachedCheckpoint>>; NESTED_INTERVALS]; NESTED_FILES],
|
||||
changed: bool,
|
||||
settled: BTreeMap<usize, SettledCheckpoint>,
|
||||
@@ -377,6 +396,7 @@ impl<'a> CapturedEntries<'a> {
|
||||
early: Default::default(),
|
||||
shipped: Default::default(),
|
||||
edit: None,
|
||||
preamble: None,
|
||||
nested: Default::default(),
|
||||
changed: false,
|
||||
settled: BTreeMap::new(),
|
||||
@@ -401,6 +421,9 @@ impl<'a> CapturedEntries<'a> {
|
||||
if slots.edit {
|
||||
self.edit = Some(checkpoint.clone());
|
||||
}
|
||||
if slots.preamble {
|
||||
self.preamble = Some(checkpoint.clone());
|
||||
}
|
||||
if slots.page {
|
||||
self.shipped[slots.interval] = Some(checkpoint);
|
||||
}
|
||||
@@ -524,6 +547,7 @@ impl<'a> CapturedEntries<'a> {
|
||||
early: false,
|
||||
page: true,
|
||||
edit: false,
|
||||
preamble: false,
|
||||
next_page: page.saturating_add(1),
|
||||
};
|
||||
self.capture(Capture::Settled { page, regular: Some(regular) }, Arc::new(entry), host);
|
||||
@@ -580,6 +604,11 @@ impl<'a> CapturedEntries<'a> {
|
||||
.expect("the full schedule has ordinary continuations");
|
||||
entries.remove(index);
|
||||
}
|
||||
if let Some(preamble) = self.preamble
|
||||
&& !entries.iter().any(|entry| Arc::ptr_eq(entry, &preamble))
|
||||
{
|
||||
entries.push(preamble);
|
||||
}
|
||||
let before_child = recording.prefix().and_then(|(_, calls)| {
|
||||
// Keep one existing parent anchor before a child's first size
|
||||
// observation. It can still replay when a new size invalidates
|
||||
@@ -753,7 +782,8 @@ impl CheckpointCache {
|
||||
Result<Arc<RevisionExecution>, RevisionFailure>,
|
||||
Option<Arc<CheckpointSet>>,
|
||||
) {
|
||||
let mut schedule = CaptureSchedule::new(source.data.len(), self.minimum_frontier, None);
|
||||
let mut schedule = CaptureSchedule::new(source.data.len(), self.minimum_frontier, None)
|
||||
.with_preamble_anchor(&source.data);
|
||||
let mut captures = CapturedEntries::new(request, files);
|
||||
let mut recording = RecordingHost::new(files);
|
||||
let mut nested = NestedSchedule::default();
|
||||
@@ -1097,7 +1127,7 @@ impl SelectedCheckpoint {
|
||||
source.data.len(),
|
||||
None,
|
||||
changed.or(self.set.edit_frontier),
|
||||
);
|
||||
).with_preamble_anchor(&source.data);
|
||||
// A comment-only line can be consumed without an observation.
|
||||
// Keep an earlier anchor for this editing boundary.
|
||||
schedule.pending_edit_fallback =
|
||||
@@ -1404,6 +1434,20 @@ fn changed_line_start(previous: &[u8], current: &[u8]) -> Option<usize> {
|
||||
)
|
||||
}
|
||||
|
||||
fn preamble_frontier(bytes: &[u8], limit: usize) -> Option<usize> {
|
||||
let mut start = 0;
|
||||
for line in bytes.split_inclusive(|&byte| matches!(byte, b'\r' | b'\n')) {
|
||||
if start >= limit {
|
||||
break;
|
||||
}
|
||||
if line.trim_ascii() == br"\begin{document}" {
|
||||
return (start > 0).then_some(start);
|
||||
}
|
||||
start += line.len();
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn preceding_command_frontier(bytes: &[u8], edit: usize) -> Option<usize> {
|
||||
let mut frontier = edit;
|
||||
while frontier > 0 {
|
||||
@@ -2541,6 +2585,30 @@ fn immutable_file_creation_and_removal_replay_real_lookup_results() {
|
||||
assert_eq!(pdfs.values().collect::<BTreeSet<_>>().len(), 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn large_automatic_schedule_keeps_a_preamble_anchor_once() {
|
||||
let prefix = b"% \\begin{document}\r\ntext \\begin{document}\r\n\\relax\r\n";
|
||||
let mut source = prefix.to_vec();
|
||||
source.extend_from_slice(b" \\begin{document}\r\n");
|
||||
source.resize(4 * MIN_PREAMBLE_INTERVAL_BYTES, b'x');
|
||||
let mut schedule = CaptureSchedule::new(source.len(), None, None).with_preamble_anchor(&source);
|
||||
assert!(schedule.select(1, 0).unwrap().early);
|
||||
let anchor = schedule.select(prefix.len(), 0).unwrap();
|
||||
assert!(anchor.preamble && !anchor.early && !anchor.edit && !anchor.page);
|
||||
assert!(schedule.select(prefix.len(), 0).is_none());
|
||||
|
||||
let mut schedule = CaptureSchedule::new(source.len(), None, Some(prefix.len()))
|
||||
.with_preamble_anchor(&source);
|
||||
let combined = schedule.select(prefix.len(), 0).unwrap();
|
||||
assert!(combined.preamble && combined.early && combined.edit);
|
||||
assert!(schedule.select(prefix.len(), 0).is_none());
|
||||
assert!(CaptureSchedule::new(source.len(), Some(1), None)
|
||||
.with_preamble_anchor(&source).pending_preamble.is_none());
|
||||
assert!(CaptureSchedule::new(prefix.len(), None, None)
|
||||
.with_preamble_anchor(prefix).pending_preamble.is_none());
|
||||
assert_eq!(preamble_frontier(prefix, prefix.len()), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn edit_only_entry_checkpoint_advances_to_its_line_end() {
|
||||
let mut schedule = CaptureSchedule::new(400, None, Some(290));
|
||||
|
||||
Reference in new issue
Block a user