mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:15:33 +00:00
Detect continuations at start-of-file (#5173)
## Summary Given: ```python \ import os ``` Deleting `import os` leaves a syntax error: a file can't end in a continuation. We have code to handle this case, but it failed to pick up continuations at the _very start_ of a file. Closes #5156.
This commit is contained in:
parent
a6cf31cc89
commit
2b82caa163
1 changed files with 1 additions and 4 deletions
|
@ -49,10 +49,7 @@ impl Indexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Newlines after a newline never form a continuation.
|
// Newlines after a newline never form a continuation.
|
||||||
if !matches!(
|
if !matches!(prev_token, Some(Tok::Newline | Tok::NonLogicalNewline)) {
|
||||||
prev_token,
|
|
||||||
Some(Tok::Newline | Tok::NonLogicalNewline) | None
|
|
||||||
) {
|
|
||||||
continuation_lines.push(line_start);
|
continuation_lines.push(line_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue