mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-28 06:49:19 +00:00
feat: vscode protocol for vscode users
This commit is contained in:
parent
f24861957a
commit
437539d232
10
src/term.rs
10
src/term.rs
@ -5,7 +5,7 @@ use crossterm::{
|
||||
terminal::{Clear, ClearType},
|
||||
};
|
||||
use std::{
|
||||
fmt, fs,
|
||||
env, fmt, fs,
|
||||
io::{self, BufRead, StdoutLock, Write},
|
||||
};
|
||||
|
||||
@ -282,7 +282,13 @@ pub fn terminal_file_link<'a>(
|
||||
.stdout()
|
||||
.queue(SetForegroundColor(color))?
|
||||
.queue(SetAttribute(Attribute::Underlined))?;
|
||||
writer.stdout().write_all(b"\x1b]8;;file://")?;
|
||||
let protocol = if env::var("TERM_PROGRAM") == Ok("vscode".to_string()) {
|
||||
"vscode://file"
|
||||
} else {
|
||||
"file://"
|
||||
};
|
||||
writer.stdout().write_all(b"\x1b]8;;")?;
|
||||
writer.stdout().write_all(protocol.as_bytes())?;
|
||||
writer.stdout().write_all(canonical_path.as_bytes())?;
|
||||
writer.stdout().write_all(b"\x1b\\")?;
|
||||
// Only this part is visible.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user