Revert "For # to start a comment, then it either need to be the first chara…" (#14560)

Reverts nushell/nushell#14548

I'm finding may oddities
This commit is contained in:
Darren Schroeder
2024-12-11 07:08:15 -06:00
committed by GitHub
parent 4f20c370f9
commit 1a573d17c0
3 changed files with 2 additions and 51 deletions

View File

@ -51,7 +51,7 @@ impl BlockKind {
}
// A baseline token is terminated if it's not nested inside of a paired
// delimiter and the next character is one of: `|`, `;` or any
// delimiter and the next character is one of: `|`, `;`, `#` or any
// whitespace.
fn is_item_terminator(
block_level: &[BlockKind],
@ -115,7 +115,6 @@ pub fn lex_item(
// character (whitespace, `|`, `;` or `#`) is encountered, the baseline
// token is done.
// - Otherwise, accumulate the character into the current baseline token.
let mut previous_char = None;
while let Some(c) = input.get(*curr_offset) {
let c = *c;
@ -152,8 +151,7 @@ pub fn lex_item(
if is_item_terminator(&block_level, c, additional_whitespace, special_tokens) {
break;
}
// To start a comment, It either need to be the first character of the token or prefixed with space.
in_comment = previous_char.map(|pc| pc == b' ').unwrap_or(true);
in_comment = true;
} else if c == b'\n' || c == b'\r' {
in_comment = false;
if is_item_terminator(&block_level, c, additional_whitespace, special_tokens) {
@ -256,7 +254,6 @@ pub fn lex_item(
}
*curr_offset += 1;
previous_char = Some(c);
}
let span = Span::new(span_offset + token_start, span_offset + *curr_offset);