From 5350422d368b62a8fd40264bfe83ab847f53ffcf Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 8 Jan 2025 11:41:20 -0500 Subject: [PATCH] ruff_annotate_snippets: update snapshot for single ASCII whitespace source The change to the rendering code is elaborated on in more detail here, where I attempted to upstream it: https://github.com/rust-lang/annotate-snippets-rs/pull/169 Otherwise, the snapshot diff also shows a bug fix: a `^` is now rendered where as it previously was not. --- crates/ruff_annotate_snippets/src/renderer/display_list.rs | 4 +--- .../ruff_linter__rules__pycodestyle__tests__w292_4.snap | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/ruff_annotate_snippets/src/renderer/display_list.rs b/crates/ruff_annotate_snippets/src/renderer/display_list.rs index 95a1d69b1c110..bd723e7dd1ab0 100644 --- a/crates/ruff_annotate_snippets/src/renderer/display_list.rs +++ b/crates/ruff_annotate_snippets/src/renderer/display_list.rs @@ -1394,9 +1394,7 @@ fn format_body( } }) .sum(); - if line.chars().any(|c| !c.is_whitespace()) { - whitespace_margin = min(whitespace_margin, leading_whitespace); - } + whitespace_margin = min(whitespace_margin, leading_whitespace); max_line_len = max(max_line_len, line_length); let line_start_index = line_range.0; diff --git a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap index cadfcb66a8f56..31356cd79f95a 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap +++ b/crates/ruff_linter/src/rules/pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__w292_4.snap @@ -1,11 +1,10 @@ --- source: crates/ruff_linter/src/rules/pycodestyle/mod.rs -snapshot_kind: text --- W292_4.py:1:2: W292 [*] No newline at end of file | 1 | - | W292 + | ^ W292 | = help: Add trailing newline