Skip to content

Commit ab503d9

Browse files
committed
maybe fix?
1 parent 49cde17 commit ab503d9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

crates/pglt_lexer/src/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,18 @@ pub static WHITESPACE_TOKENS: &[SyntaxKind] = &[
6161
SyntaxKind::SqlComment,
6262
];
6363

64-
static PATTERN_LEXER: LazyLock<Regex> =
65-
LazyLock::new(|| Regex::new(r"(?P<whitespace> +)|(?P<newline>\r?\n+)|(?P<tab>\t+)").unwrap());
64+
static PATTERN_LEXER: LazyLock<Regex> = LazyLock::new(|| {
65+
#[cfg(windows)]
66+
{
67+
// On Windows, treat \r\n as a single newline token
68+
Regex::new(r"(?P<whitespace> +)|(?P<newline>\r\n|\n+)|(?P<tab>\t+)").unwrap()
69+
}
70+
#[cfg(not(windows))]
71+
{
72+
// On other platforms, just check for \n
73+
Regex::new(r"(?P<whitespace> +)|(?P<newline>\n+)|(?P<tab>\t+)").unwrap()
74+
}
75+
});
6676

6777
fn whitespace_tokens(input: &str) -> VecDeque<Token> {
6878
let mut tokens = VecDeque::new();

0 commit comments

Comments
 (0)