diff --git a/desktop/src-tauri/Cargo.lock b/desktop/src-tauri/Cargo.lock index 3e04ade..b2ef9ed 100644 --- a/desktop/src-tauri/Cargo.lock +++ b/desktop/src-tauri/Cargo.lock @@ -3237,7 +3237,7 @@ dependencies = [ [[package]] name = "texrra-desktop" -version = "0.1.3" +version = "0.1.4" dependencies = [ "serde_json", "tauri", diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index 1978698..dc34334 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "texrra-desktop" -version = "0.1.3" +version = "0.1.4" edition = "2024" rust-version = "1.92" license = "MIT OR Apache-2.0" diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json index 1eb5177..fe0a769 100644 --- a/desktop/src-tauri/tauri.conf.json +++ b/desktop/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "Texrra", - "version": "0.1.3", + "version": "0.1.4", "identifier": "org.texrra.desktop", "build": { "frontendDist": "../startup" diff --git a/src/native_checkpoint_guard.rs b/src/native_checkpoint_guard.rs index 5582a85..310b81a 100644 --- a/src/native_checkpoint_guard.rs +++ b/src/native_checkpoint_guard.rs @@ -1098,9 +1098,8 @@ impl SelectedCheckpoint { None, changed.or(self.set.edit_frontier), ); - // Comment-only lines may be consumed without an observation, and a - // paragraph can cross several physical lines in one command. Keep a - // nearby earlier anchor when the exact edit-line start is not visited. + // A comment-only line can be consumed without an observation. + // Keep an earlier anchor for this editing boundary. schedule.pending_edit_fallback = changed.and_then(|line| preceding_command_frontier(&source.data, line)); let mut nested_schedule = NestedSchedule::default(); @@ -1414,10 +1413,16 @@ fn preceding_command_frontier(bytes: &[u8], edit: usize) -> Option { let line = &prefix[..frontier - ending]; let start = line.iter().rposition(|byte| matches!(*byte, b'\r' | b'\n')) .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 // the ordinary scanner, host and immutable-prefix checks. - if line[start..].trim_ascii_start().first() == Some(&b'\\') { - return (frontier < edit).then_some(frontier); + if token == Some(&b'\\') { + return Some(frontier); } frontier = start; } @@ -2566,16 +2571,20 @@ fn edit_only_entry_checkpoint_advances_to_its_line_end() { #[test] 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 edit = source.windows(b"changed text".len()) .position(|bytes| bytes == b"changed text").unwrap(); 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)); schedule.pending_edit_fallback = preceding_command_frontier(source, edit); assert!(schedule.select(command, 0).unwrap().edit); assert!(schedule.select(edit, 0).unwrap().edit); 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]