Skip to content

Commit 72d8d48

Browse files
committed
fix?
1 parent 4d9df58 commit 72d8d48

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

crates/pglt_statement_splitter/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ mod tests {
114114
]);
115115
}
116116

117+
#[test]
118+
fn single_newlines() {
119+
Tester::from("select 1\nfrom contact\n\nselect 3")
120+
.expect_statements(vec!["select 1\nfrom contact", "select 3"]);
121+
}
122+
117123
#[test]
118124
fn alter_column() {
119125
Tester::from("alter table users alter column email drop not null;")

crates/pglt_statement_splitter/src/parser.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ impl Parser {
183183
}
184184
}
185185

186+
#[cfg(windows)]
187+
/// Returns true if the token is relevant for the paring process
188+
///
189+
/// On windows, a newline is represented by `\r\n` which is two characters.
190+
fn is_irrelevant_token(t: &Token) -> bool {
191+
WHITESPACE_TOKENS.contains(&t.kind)
192+
&& (t.kind != SyntaxKind::Newline || t.text == "\r\n" || t.text.chars.count() == 1)
193+
}
194+
195+
#[cfg(not(windows))]
196+
/// Returns true if the token is relevant for the paring process
186197
fn is_irrelevant_token(t: &Token) -> bool {
187198
WHITESPACE_TOKENS.contains(&t.kind)
188199
&& (t.kind != SyntaxKind::Newline || t.text.chars().count() == 1)

0 commit comments

Comments
 (0)