Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(biome_diagnostics): fix JetBrains relative file URLs should be clickable when given line and column numbers #4876

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading