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
  • Loading branch information
Andrew-Chen-Wang committed Jan 11, 2025
1 parent 94bf15e commit 3014e87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b
## Unreleased

- Fix [#4323](https://github.com/biomejs/biome/issues/4258), where `lint/a11y/useSemanticElement` accidentally showed recommendations for `role="searchbox"` instead of `role="search"`
- Fix [#4875](https://github.com/biomejs/biome/issues/4875), where the Jetbrains IDE terminal would output unclickable, relative file path links to files. This does not fix paths without line and column numbers. Contributed by @Andrew-Chen-Wang

### Analyzer

Expand Down
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 3014e87

Please sign in to comment.