Skip to content

Commit d922997

Browse files
committed
fix up misplaced comments
1 parent f555ae2 commit d922997

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/ruff_linter/src/fix/edits.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,12 @@ pub(crate) fn adjust_indentation(
300300
indexer: &Indexer,
301301
stylist: &Stylist,
302302
) -> Result<String> {
303+
let contents = locator.slice(range);
304+
303305
// If the range includes a multi-line string, use LibCST to ensure that we don't adjust the
304306
// whitespace _within_ the string.
305-
let contents = locator.slice(range);
307+
let contains_multiline_string =
308+
indexer.multiline_ranges().intersects(range) || indexer.fstring_ranges().intersects(range);
306309

307310
// If the range has mixed indentation, we will use LibCST as well.
308311
let mixed_indentation = contents.universal_newlines().any(|line| {
@@ -315,10 +318,7 @@ pub(crate) fn adjust_indentation(
315318
line_indentation.contains('\t') && line_indentation.contains(' ')
316319
});
317320

318-
if mixed_indentation
319-
|| indexer.multiline_ranges().intersects(range)
320-
|| indexer.fstring_ranges().intersects(range)
321-
{
321+
if contains_multiline_string || mixed_indentation {
322322
let module_text = format!("def f():{}{contents}", stylist.line_ending().as_str());
323323

324324
let mut tree = match_statement(&module_text)?;

0 commit comments

Comments
 (0)