mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Shrink unlinked-file
diagnostic to 3 characters
This commit is contained in:
parent
99ed68a109
commit
ac980e96e5
1 changed files with 9 additions and 7 deletions
|
@ -20,7 +20,7 @@ use itertools::Itertools;
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode},
|
ast::{self, AstNode},
|
||||||
SyntaxNode, SyntaxNodePtr, TextRange,
|
SyntaxNode, SyntaxNodePtr, TextRange, TextSize,
|
||||||
};
|
};
|
||||||
use text_edit::TextEdit;
|
use text_edit::TextEdit;
|
||||||
use unlinked_file::UnlinkedFile;
|
use unlinked_file::UnlinkedFile;
|
||||||
|
@ -159,14 +159,16 @@ pub(crate) fn diagnostics(
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.on::<UnlinkedFile, _>(|d| {
|
.on::<UnlinkedFile, _>(|d| {
|
||||||
|
// Limit diagnostic to the first few characters in the file. This matches how VS Code
|
||||||
|
// renders it with the full span, but on other editors, and is less invasive.
|
||||||
|
let range = sema.diagnostics_display_range(d.display_source()).range;
|
||||||
|
let range = range.intersect(TextRange::up_to(TextSize::of("..."))).unwrap_or(range);
|
||||||
|
|
||||||
// Override severity and mark as unused.
|
// Override severity and mark as unused.
|
||||||
res.borrow_mut().push(
|
res.borrow_mut().push(
|
||||||
Diagnostic::hint(
|
Diagnostic::hint(range, d.message())
|
||||||
sema.diagnostics_display_range(d.display_source()).range,
|
.with_fix(d.fix(&sema))
|
||||||
d.message(),
|
.with_code(Some(d.code())),
|
||||||
)
|
|
||||||
.with_fix(d.fix(&sema))
|
|
||||||
.with_code(Some(d.code())),
|
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.on::<hir::diagnostics::UnresolvedProcMacro, _>(|d| {
|
.on::<hir::diagnostics::UnresolvedProcMacro, _>(|d| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue