diff options
| author | Ian Wrzesinski <133046678+wrzian@users.noreply.github.com> | 2025-01-16 08:40:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-16 13:40:29 +0000 |
| commit | 63c4720ed2b9e034fda6810a9c0e521355a24c44 (patch) | |
| tree | a92370da42504608c7d06e838d5972cca165f0b2 /crates/typst-syntax | |
| parent | a4ac4e656267e718a5cf60d1e959f74b2b7346f3 (diff) | |
Fix list indent when starting at an open bracket (#5677)
Diffstat (limited to 'crates/typst-syntax')
| -rw-r--r-- | crates/typst-syntax/src/parser.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/crates/typst-syntax/src/parser.rs b/crates/typst-syntax/src/parser.rs index 335b8f1a..a65e5ff6 100644 --- a/crates/typst-syntax/src/parser.rs +++ b/crates/typst-syntax/src/parser.rs @@ -1605,10 +1605,12 @@ impl AtNewline { _ => true, }, AtNewline::StopParBreak => parbreak, - AtNewline::RequireColumn(min_col) => match column { - Some(column) => column <= min_col, - None => false, // Don't stop if we had no column. - }, + AtNewline::RequireColumn(min_col) => { + // Don't stop if this newline doesn't start a column (this may + // be checked on the boundary of lexer modes, since we only + // report a column in Markup). + column.is_some_and(|column| column <= min_col) + } } } } @@ -1703,10 +1705,13 @@ impl<'s> Parser<'s> { self.token.newline.is_some() } - /// The number of characters until the most recent newline from the current - /// token, or 0 if it did not follow a newline. + /// The number of characters until the most recent newline from the start of + /// the current token. Uses a cached value from the newline mode if present. fn current_column(&self) -> usize { - self.token.newline.and_then(|newline| newline.column).unwrap_or(0) + self.token + .newline + .and_then(|newline| newline.column) + .unwrap_or_else(|| self.lexer.column(self.token.start)) } /// The current token's text. |
