Skip to content

Commit ee25a7d

Browse files
committed
Disable terminal links in VS-Code
1 parent 594e212 commit ee25a7d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/term.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{
2-
fmt, fs,
2+
cell::Cell,
3+
env, fmt, fs,
34
io::{self, BufRead, StdoutLock, Write},
45
};
56

@@ -10,6 +11,10 @@ use crossterm::{
1011
Command, QueueableCommand,
1112
};
1213

14+
thread_local! {
15+
static VS_CODE: Cell<bool> = Cell::new(env::var_os("TERM").is_some_and(|v| v == "vscode"));
16+
}
17+
1318
/// Terminal progress bar to be used when not using Ratataui.
1419
pub fn progress_bar(
1520
stdout: &mut StdoutLock,
@@ -73,6 +78,11 @@ pub fn press_enter_prompt(stdout: &mut StdoutLock) -> io::Result<()> {
7378
}
7479

7580
pub fn terminal_file_link(stdout: &mut StdoutLock, path: &str, color: Color) -> io::Result<()> {
81+
// VS Code shows its own links. This also avoids some issues, especially on Windows.
82+
if VS_CODE.get() {
83+
return stdout.write_all(path.as_bytes());
84+
}
85+
7686
let canonical_path = fs::canonicalize(path).ok();
7787

7888
let Some(canonical_path) = canonical_path.as_deref().and_then(|p| p.to_str()) else {

0 commit comments

Comments
 (0)