Limit earlier edit checkpoints to skipped comments for desktop 0.1.4
This commit is contained in:
1 parent
43025e3f72
commit
8cb5ddc976
4 files changed
+18
-9
No files matched your search
Generated
+1
-1
@@ -3237,7 +3237,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "texrra-desktop"
|
name = "texrra-desktop"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tauri",
|
"tauri",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "texrra-desktop"
|
name = "texrra-desktop"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.92"
|
rust-version = "1.92"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Texrra",
|
"productName": "Texrra",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"identifier": "org.texrra.desktop",
|
"identifier": "org.texrra.desktop",
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../startup"
|
"frontendDist": "../startup"
|
||||||
|
|||||||
@@ -1098,9 +1098,8 @@ impl SelectedCheckpoint {
|
|||||||
None,
|
None,
|
||||||
changed.or(self.set.edit_frontier),
|
changed.or(self.set.edit_frontier),
|
||||||
);
|
);
|
||||||
// Comment-only lines may be consumed without an observation, and a
|
// A comment-only line can be consumed without an observation.
|
||||||
// paragraph can cross several physical lines in one command. Keep a
|
// Keep an earlier anchor for this editing boundary.
|
||||||
// nearby earlier anchor when the exact edit-line start is not visited.
|
|
||||||
schedule.pending_edit_fallback =
|
schedule.pending_edit_fallback =
|
||||||
changed.and_then(|line| preceding_command_frontier(&source.data, line));
|
changed.and_then(|line| preceding_command_frontier(&source.data, line));
|
||||||
let mut nested_schedule = NestedSchedule::default();
|
let mut nested_schedule = NestedSchedule::default();
|
||||||
@@ -1414,10 +1413,16 @@ fn preceding_command_frontier(bytes: &[u8], edit: usize) -> Option<usize> {
|
|||||||
let line = &prefix[..frontier - ending];
|
let line = &prefix[..frontier - ending];
|
||||||
let start = line.iter().rposition(|byte| matches!(*byte, b'\r' | b'\n'))
|
let start = line.iter().rposition(|byte| matches!(*byte, b'\r' | b'\n'))
|
||||||
.map_or(0, |offset| offset + 1);
|
.map_or(0, |offset| offset + 1);
|
||||||
|
let token = line[start..].trim_ascii_start().first();
|
||||||
|
// A blank line can contribute an observable paragraph end. Limit
|
||||||
|
// the extra capture to a preceding comment-only line.
|
||||||
|
if frontier == edit && token != Some(&b'%') {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
// This is a scheduling hint. The actual restart still goes through
|
// This is a scheduling hint. The actual restart still goes through
|
||||||
// the ordinary scanner, host and immutable-prefix checks.
|
// the ordinary scanner, host and immutable-prefix checks.
|
||||||
if line[start..].trim_ascii_start().first() == Some(&b'\\') {
|
if token == Some(&b'\\') {
|
||||||
return (frontier < edit).then_some(frontier);
|
return Some(frontier);
|
||||||
}
|
}
|
||||||
frontier = start;
|
frontier = start;
|
||||||
}
|
}
|
||||||
@@ -2566,16 +2571,20 @@ fn edit_only_entry_checkpoint_advances_to_its_line_end() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn edit_checkpoint_keeps_a_command_anchor_when_the_exact_line_is_skipped() {
|
fn edit_checkpoint_keeps_a_command_anchor_when_the_exact_line_is_skipped() {
|
||||||
let source = b"\\section{Title}\r\nParagraph beginning\r\nsecond line\r\nchanged text\r\n\\end";
|
let source = b"\\section{Title}\r\n % comment\r\nchanged text\r\n\\end";
|
||||||
let command = b"\\section{Title}\r\n".len();
|
let command = b"\\section{Title}\r\n".len();
|
||||||
let edit = source.windows(b"changed text".len())
|
let edit = source.windows(b"changed text".len())
|
||||||
.position(|bytes| bytes == b"changed text").unwrap();
|
.position(|bytes| bytes == b"changed text").unwrap();
|
||||||
assert_eq!(preceding_command_frontier(source, edit), Some(command));
|
assert_eq!(preceding_command_frontier(source, edit), Some(command));
|
||||||
|
let paragraph = b"\\section{Title}\nfirst line\nsecond line";
|
||||||
|
assert_eq!(preceding_command_frontier(paragraph, b"\\section{Title}\nfirst line\n".len()), None);
|
||||||
let mut schedule = CaptureSchedule::new(source.len(), None, Some(edit));
|
let mut schedule = CaptureSchedule::new(source.len(), None, Some(edit));
|
||||||
schedule.pending_edit_fallback = preceding_command_frontier(source, edit);
|
schedule.pending_edit_fallback = preceding_command_frontier(source, edit);
|
||||||
assert!(schedule.select(command, 0).unwrap().edit);
|
assert!(schedule.select(command, 0).unwrap().edit);
|
||||||
assert!(schedule.select(edit, 0).unwrap().edit);
|
assert!(schedule.select(edit, 0).unwrap().edit);
|
||||||
assert_eq!(preceding_command_frontier(source, command), None);
|
assert_eq!(preceding_command_frontier(source, command), None);
|
||||||
|
let blank = b"\\section{Title}\n\nchanged text";
|
||||||
|
assert_eq!(preceding_command_frontier(blank, b"\\section{Title}\n\n".len()), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in new issue
Block a user