mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-24 13:10:07 +00:00
feat: remove extra linebreak in diagnostic message (#1599)
This commit is contained in:
parent
d49695b884
commit
7b74506dcc
2 changed files with 9 additions and 10 deletions
|
|
@ -85,10 +85,7 @@ fn convert_diagnostic(
|
||||||
let lsp_range = diagnostic_range(&source, span, ctx.position_encoding);
|
let lsp_range = diagnostic_range(&source, span, ctx.position_encoding);
|
||||||
|
|
||||||
let lsp_severity = diagnostic_severity(typst_diagnostic.severity);
|
let lsp_severity = diagnostic_severity(typst_diagnostic.severity);
|
||||||
|
let lsp_message = diagnostic_message(&typst_diagnostic);
|
||||||
let typst_message = &typst_diagnostic.message;
|
|
||||||
let typst_hints = &typst_diagnostic.hints;
|
|
||||||
let lsp_message = format!("{typst_message}{}", diagnostic_hints(typst_hints));
|
|
||||||
|
|
||||||
let tracepoints =
|
let tracepoints =
|
||||||
diagnostic_related_information(ctx, &typst_diagnostic, ctx.position_encoding)?;
|
diagnostic_related_information(ctx, &typst_diagnostic, ctx.position_encoding)?;
|
||||||
|
|
@ -185,11 +182,13 @@ fn diagnostic_severity(typst_severity: TypstSeverity) -> DiagnosticSeverity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diagnostic_hints(typst_hints: &[EcoString]) -> Format<impl Iterator<Item = EcoString> + '_> {
|
fn diagnostic_message(typst_diagnostic: &TypstDiagnostic) -> String {
|
||||||
iter::repeat(EcoString::from("\n\nHint: "))
|
let mut message = typst_diagnostic.message.to_string();
|
||||||
.take(typst_hints.len())
|
for hint in &typst_diagnostic.hints {
|
||||||
.interleave(typst_hints.iter().cloned())
|
message.push_str("\nHint: ");
|
||||||
.format("")
|
message.push_str(hint);
|
||||||
|
}
|
||||||
|
message
|
||||||
}
|
}
|
||||||
|
|
||||||
trait DiagnosticRefiner {
|
trait DiagnosticRefiner {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ pub use std::path::{Path, PathBuf};
|
||||||
pub use std::sync::{Arc, LazyLock, OnceLock};
|
pub use std::sync::{Arc, LazyLock, OnceLock};
|
||||||
|
|
||||||
pub use ecow::{eco_vec, EcoVec};
|
pub use ecow::{eco_vec, EcoVec};
|
||||||
pub use itertools::{Format, Itertools};
|
pub use itertools::Itertools;
|
||||||
pub use lsp_types::{
|
pub use lsp_types::{
|
||||||
request::GotoDeclarationResponse, CodeAction, CodeActionKind, CodeActionOrCommand, CodeLens,
|
request::GotoDeclarationResponse, CodeAction, CodeActionKind, CodeActionOrCommand, CodeLens,
|
||||||
ColorInformation, ColorPresentation, Diagnostic, DiagnosticRelatedInformation,
|
ColorInformation, ColorPresentation, Diagnostic, DiagnosticRelatedInformation,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue