Omit code frames for fixes with empty ranges (#12304)

## Summary

Closes https://github.com/astral-sh/ruff/issues/12291.

## Test Plan

```shell
❯ cargo run check ../uv/foo --select INP
/Users/crmarsh/workspace/uv/foo/bar/baz.py:1:1: INP001 File `/Users/crmarsh/workspace/uv/foo/bar/baz.py` is part of an implicit namespace package. Add an `__init__.py`.
Found 1 error.
```
This commit is contained in:
Charlie Marsh 2024-07-12 11:21:28 -04:00 committed by GitHub
parent e58713e2ac
commit 940df67823
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 11 additions and 457 deletions

View file

@ -116,14 +116,17 @@ impl Emitter for TextEmitter {
)?;
if self.flags.intersects(EmitterFlags::SHOW_SOURCE) {
writeln!(
writer,
"{}",
MessageCodeFrame {
message,
notebook_index
}
)?;
// The `0..0` range is used to highlight file-level diagnostics.
if message.range() != TextRange::default() {
writeln!(
writer,
"{}",
MessageCodeFrame {
message,
notebook_index
}
)?;
}
}
if self.flags.intersects(EmitterFlags::SHOW_FIX_DIFF) {