mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 01:51:30 +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.
|
||||
if !matches!(
|
||||
prev_token,
|
||||
Some(Tok::Newline | Tok::NonLogicalNewline) | None
|
||||
) {
|
||||
if !matches!(prev_token, Some(Tok::Newline | Tok::NonLogicalNewline)) {
|
||||
continuation_lines.push(line_start);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue