mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
fix: Improve hover text in unlinked file diagnostics
Use full sentences, and mention how to disable the diagnostic if users are intentionally working on unowned files.
This commit is contained in:
parent
67f7eb505e
commit
e62bc2d1f5
2 changed files with 6 additions and 3 deletions
|
@ -30,11 +30,13 @@ pub(crate) fn unlinked_file(
|
||||||
// FIXME: This is a hack for the vscode extension to notice whether there is an autofix or not before having to resolve diagnostics.
|
// FIXME: This is a hack for the vscode extension to notice whether there is an autofix or not before having to resolve diagnostics.
|
||||||
// This is to prevent project linking popups from appearing when there is an autofix. https://github.com/rust-lang/rust-analyzer/issues/14523
|
// This is to prevent project linking popups from appearing when there is an autofix. https://github.com/rust-lang/rust-analyzer/issues/14523
|
||||||
let message = if fixes.is_none() {
|
let message = if fixes.is_none() {
|
||||||
"file not included in crate hierarchy"
|
"This file is not included in any crates, so rust-analyzer can't offer IDE services."
|
||||||
} else {
|
} else {
|
||||||
"file not included in module tree"
|
"This file is not included anywhere in the module tree, so rust-analyzer can't offer IDE services."
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let message = format!("{message}\n\nIf you're intentionally working on unowned files, you can silence this warning by adding \"unlinked-file\" to rust-analyzer.diagnostics.disabled in your settings.");
|
||||||
|
|
||||||
let mut range = ctx.sema.db.parse(file_id).syntax_node().text_range();
|
let mut range = ctx.sema.db.parse(file_id).syntax_node().text_range();
|
||||||
let mut unused = true;
|
let mut unused = true;
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,8 @@ export async function createClient(
|
||||||
// value === "unlinked-file" &&
|
// value === "unlinked-file" &&
|
||||||
value === "temporary-disabled" &&
|
value === "temporary-disabled" &&
|
||||||
!unlinkedFiles.includes(uri) &&
|
!unlinkedFiles.includes(uri) &&
|
||||||
diag.message !== "file not included in module tree"
|
(diag.message === "file not included in crate hierarchy" ||
|
||||||
|
diag.message.startsWith("This file is not included in any crates"))
|
||||||
) {
|
) {
|
||||||
const config = vscode.workspace.getConfiguration("rust-analyzer");
|
const config = vscode.workspace.getConfiguration("rust-analyzer");
|
||||||
if (config.get("showUnlinkedFileNotification")) {
|
if (config.get("showUnlinkedFileNotification")) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue