ruff/crates
Dhruv Manilawala 68a8978454
Consider line continuation character for re-lexing (#12008)
## Summary

This PR fixes a bug where the re-lexing logic didn't consider the line
continuation character being present before the newline character. This
meant that the lexer was being moved back to the newline character which
is actually ignored via `\`.

Considering the following code:
```py
f'middle {'string':\
        'format spec'}

```

The old token stream is:
```
...
Colon 18..19
FStringMiddle 19..29 (flags = F_STRING)
Newline 20..21
Indent 21..29
String 29..42
Rbrace 42..43
...
```

Notice how the ranges are overlapping between the `FStringMiddle` token
and the tokens emitted after moving the lexer backwards.

After this fix, the new token stream which is without moving the lexer
backwards in this scenario:
```
FStringStart 0..2 (flags = F_STRING)
FStringMiddle 2..9 (flags = F_STRING)
Lbrace 9..10
String 10..18
Colon 18..19
FStringMiddle 19..29 (flags = F_STRING)
FStringEnd 29..30 (flags = F_STRING)
Name 30..36
Name 37..41
Unknown 41..44
Newline 44..45
```

fixes: #12004 

## Test Plan

Add test cases and update the snapshots.
2024-06-25 02:13:54 +00:00
..
red_knot [red-knot] Move typeshed `VERSIONS` parser to the module resolver crate (#11967) 2024-06-21 16:41:08 +01:00
red_knot_module_resolver [red-knot] Simplify conversions from `std::path::Path` to `VendoredPath(Buf)` (#11988) 2024-06-23 15:52:26 +01:00
red_knot_python_semantic [red-knot] Move module-resolution logic to its own crate (#11964) 2024-06-21 13:25:44 +00:00
ruff [red-knot] Move the vendored typeshed stubs to the module resolver crate (#11966) 2024-06-21 13:47:54 +00:00
ruff_benchmark Build `CommentRanges` outside the parser (#11792) 2024-06-09 09:55:17 +00:00
ruff_cache Move sub-crates to workspace dependencies (#11407) 2024-05-13 14:37:50 +00:00
ruff_db [red-knot] Reduce allocations when normalizing `VendoredPath`s (#11992) 2024-06-24 13:08:01 +01:00
ruff_dev Fix missing related settings header (#12013) 2024-06-24 12:29:10 +02:00
ruff_diagnostics Move sub-crates to workspace dependencies (#11407) 2024-05-13 14:37:50 +00:00
ruff_formatter Fix formatter instability for lines only consisting of zero-width characters (#11748) 2024-06-05 17:55:14 +02:00
ruff_index Red-knot: Track scopes per expression (#11754) 2024-06-05 17:53:26 +02:00
ruff_linter Update Rust crate rustc-hash to v2 (#12001) 2024-06-23 20:46:42 -04:00
ruff_macros Move sub-crates to workspace dependencies (#11407) 2024-05-13 14:37:50 +00:00
ruff_notebook Add Jupyter Notebook document change snapshot test (#11944) 2024-06-21 05:29:27 +00:00
ruff_python_ast red-knot: `source_text`, `line_index`, and `parsed_module` queries (#11822) 2024-06-13 07:37:02 +00:00
ruff_python_ast_integration_tests Rename `PreorderVisitor` to `SourceOrderVisitor` (#11798) 2024-06-07 17:01:58 +00:00
ruff_python_codegen Avoid depth counting when detecting indentation (#11947) 2024-06-20 10:42:35 +05:30
ruff_python_formatter Update Rust crate rustc-hash to v2 (#12001) 2024-06-23 20:46:42 -04:00
ruff_python_index Build `CommentRanges` outside the parser (#11792) 2024-06-09 09:55:17 +00:00
ruff_python_literal Remove some unused `pub` functions (#11576) 2024-05-28 09:56:51 -04:00
ruff_python_parser Consider line continuation character for re-lexing (#12008) 2024-06-25 02:13:54 +00:00
ruff_python_resolver chore(deps): update rust crate insta to v1.38.0 (#10701) 2024-04-01 15:44:30 +00:00
ruff_python_semantic [`pyflakes`] Detect assignments that shadow definitions (`F811`) (#11961) 2024-06-23 13:29:32 -04:00
ruff_python_stdlib Regenerate sys.rs with stdlibs==2024.5.15 (#11437) 2024-05-15 22:17:32 +00:00
ruff_python_trivia Move `has_comments` to `CommentRanges` (#11495) 2024-05-22 13:35:16 +00:00
ruff_python_trivia_integration_tests Build `CommentRanges` outside the parser (#11792) 2024-06-09 09:55:17 +00:00
ruff_server Update Rust crate rustc-hash to v2 (#12001) 2024-06-23 20:46:42 -04:00
ruff_source_file red-knot: `source_text`, `line_index`, and `parsed_module` queries (#11822) 2024-06-13 07:37:02 +00:00
ruff_text_size Upgrade to Rust 1.79 (#11875) 2024-06-17 07:15:10 +01:00
ruff_wasm Manual impl of `Debug` on `Token` (#11958) 2024-06-22 04:18:24 +00:00
ruff_workspace Update Rust crate rustc-hash to v2 (#12001) 2024-06-23 20:46:42 -04:00