Skip to content

Commit

Permalink
fix up misplaced comments
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 committed Aug 8, 2024
1 parent f555ae2 commit f9db08e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions crates/ruff_linter/src/fix/edits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ pub(crate) fn adjust_indentation(
) -> Result<String> {
// If the range includes a multi-line string, use LibCST to ensure that we don't adjust the
// whitespace _within_ the string.
let contents = locator.slice(range);
let contains_multiline_string =
indexer.multiline_ranges().intersects(range) || indexer.fstring_ranges().intersects(range);

let contents = locator.slice(range);
// If the range has mixed indentation, we will use LibCST as well.
let mixed_indentation = contents.universal_newlines().any(|line| {
let trimmed = line.trim_whitespace_start();
Expand All @@ -315,10 +317,7 @@ pub(crate) fn adjust_indentation(
line_indentation.contains('\t') && line_indentation.contains(' ')
});

if mixed_indentation
|| indexer.multiline_ranges().intersects(range)
|| indexer.fstring_ranges().intersects(range)
{
if contains_multiline_string || mixed_indentation {
let module_text = format!("def f():{}{contents}", stylist.line_ending().as_str());

let mut tree = match_statement(&module_text)?;
Expand Down

0 comments on commit f9db08e

Please sign in to comment.