mirror of https://github.com/helix-editor/helix
statusline: Avoid showing only 'W' in workspace-diagnostics element
If you configure a subset of severities to show in the workspace diagnostics statusline element you can see the 'W' (and surrounding space) without any diagnostic indicators. This is the case by default as it's configured to show warnings and errors only - if you have only hints in your workspace like if you open `application.rs` in Helix for example then you would see the 'W' and no indicators. This change checks that any of the configured diagnostics are non-zero and bails early if there are none.pull/12326/head
parent
09bc67ad6d
commit
b0528bbac4
|
@ -305,11 +305,21 @@ where
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if hints > 0 || info > 0 || warnings > 0 || errors > 0 {
|
let sevs_to_show = &context.editor.config().statusline.workspace_diagnostics;
|
||||||
write(context, " W ".into(), None);
|
|
||||||
|
// Avoid showing the " W " if no diagnostic counts will be shown.
|
||||||
|
if !sevs_to_show.iter().any(|sev| match sev {
|
||||||
|
Severity::Hint => hints != 0,
|
||||||
|
Severity::Info => info != 0,
|
||||||
|
Severity::Warning => warnings != 0,
|
||||||
|
Severity::Error => errors != 0,
|
||||||
|
}) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for sev in &context.editor.config().statusline.workspace_diagnostics {
|
write(context, " W ".into(), None);
|
||||||
|
|
||||||
|
for sev in sevs_to_show {
|
||||||
match sev {
|
match sev {
|
||||||
Severity::Hint if hints > 0 => {
|
Severity::Hint if hints > 0 => {
|
||||||
write(
|
write(
|
||||||
|
|
Loading…
Reference in New Issue