Skip to content

Commit

Permalink
fix(biome_diagnostics): fix JetBrains relative file URLs should be cl…
Browse files Browse the repository at this point in the history
…ickable when given line and column numbers (#4876)

Co-authored-by: Emanuele Stoppa <[email protected]>
  • Loading branch information
Andrew-Chen-Wang and ematipico authored Jan 13, 2025
1 parent 7f0e969 commit 46b41fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cli: patch
---

# - Fix [#4875](https://github.com/biomejs/biome/issues/4875), where the Jetbrains IDE terminal would output not clickable, relative file path link to the diagnostic file. This does not fix paths without line and column numbers.
7 changes: 7 additions & 0 deletions crates/biome_diagnostics/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ impl<D: Diagnostic + ?Sized> fmt::Display for PrintHeader<'_, D> {
};

let is_vscode = env::var("TERM_PROGRAM").unwrap_or_default() == "vscode";
// https://github.com/JetBrains/jediterm/issues/253#issuecomment-1280492436
// https://github.com/JetBrains/intellij-community/blob/5ca79d879617e9cc82f61590b8d157d6a4ad8746/plugins/terminal/src/org/jetbrains/plugins/terminal/runner/LocalOptionsConfigurer.java#L94
let is_jetbrains = env::var("TERMINAL_EMULATOR")
.unwrap_or_default()
.contains("JetBrains");

if let Some(name) = file_name {
if is_vscode {
Expand All @@ -121,6 +126,8 @@ impl<D: Diagnostic + ?Sized> fmt::Display for PrintHeader<'_, D> {
fmt.write_markup(markup! {
<Hyperlink href={link}>{name}</Hyperlink>
})?;
} else if is_jetbrains {
fmt.write_str(&format!(" at {name}"))?;
} else {
fmt.write_str(name)?;
}
Expand Down

0 comments on commit 46b41fa

Please sign in to comment.