mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-25 23:10:30 +00:00
Disable terminal links in VS-Code
This commit is contained in:
parent
594e212b8a
commit
ee25a7d458
1 changed files with 11 additions and 1 deletions
12
src/term.rs
12
src/term.rs
|
@ -1,5 +1,6 @@
|
|||
use std::{
|
||||
fmt, fs,
|
||||
cell::Cell,
|
||||
env, fmt, fs,
|
||||
io::{self, BufRead, StdoutLock, Write},
|
||||
};
|
||||
|
||||
|
@ -10,6 +11,10 @@ use crossterm::{
|
|||
Command, QueueableCommand,
|
||||
};
|
||||
|
||||
thread_local! {
|
||||
static VS_CODE: Cell<bool> = Cell::new(env::var_os("TERM").is_some_and(|v| v == "vscode"));
|
||||
}
|
||||
|
||||
/// Terminal progress bar to be used when not using Ratataui.
|
||||
pub fn progress_bar(
|
||||
stdout: &mut StdoutLock,
|
||||
|
@ -73,6 +78,11 @@ pub fn press_enter_prompt(stdout: &mut StdoutLock) -> io::Result<()> {
|
|||
}
|
||||
|
||||
pub fn terminal_file_link(stdout: &mut StdoutLock, path: &str, color: Color) -> io::Result<()> {
|
||||
// VS Code shows its own links. This also avoids some issues, especially on Windows.
|
||||
if VS_CODE.get() {
|
||||
return stdout.write_all(path.as_bytes());
|
||||
}
|
||||
|
||||
let canonical_path = fs::canonicalize(path).ok();
|
||||
|
||||
let Some(canonical_path) = canonical_path.as_deref().and_then(|p| p.to_str()) else {
|
||||
|
|
Loading…
Reference in a new issue