Skip to content

Commit

Permalink
parser: remove the node instead here.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Mar 4, 2025
1 parent 8964f32 commit 1c55e16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 8 additions & 5 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3073,16 +3073,19 @@ where
text.drain(..end);

let adjust = spx.consume(end) + 1;
// Do we need to account separately for the parent? I _think_ it always
// has the same start col to begin with as `sourcepos` itself.
assert_eq!(
sourcepos.start.column,
parent.data.borrow().sourcepos.start.column
);

// HACK: See tests::fuzz::echaw9. The paragraph doesn't exist in the source!
sourcepos.start.column = usize::min(sourcepos.end.column, adjust);
parent.data.borrow_mut().sourcepos.start.column = sourcepos.start.column;
// See tests::fuzz::echaw9. The paragraph doesn't exist in the source,
// so we remove it.
if sourcepos.end.column < adjust {
parent.detach();
} else {
sourcepos.start.column = adjust;
parent.data.borrow_mut().sourcepos.start.column = adjust;
}

grandparent.data.borrow_mut().value =
NodeValue::TaskItem(if symbol == ' ' { None } else { Some(symbol) });
Expand Down
4 changes: 1 addition & 3 deletions src/tests/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,7 @@ fn echaw9() {
"-\t[ ]&NewLine;",
(document (1:1-1:14) [
(list (1:1-1:14) [
(taskitem (1:1-1:14) [
(paragraph (1:14-1:14)) // Unsatisfying. See parser::process_tasklist.
])
(taskitem (1:1-1:14))
])
]),
);
Expand Down

0 comments on commit 1c55e16

Please sign in to comment.