mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-01 16:29:18 +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},
|
terminal::{Clear, ClearType},
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
fmt, fs,
|
env, fmt, fs,
|
||||||
io::{self, BufRead, StdoutLock, Write},
|
io::{self, BufRead, StdoutLock, Write},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -282,7 +282,13 @@ pub fn terminal_file_link<'a>(
|
|||||||
.stdout()
|
.stdout()
|
||||||
.queue(SetForegroundColor(color))?
|
.queue(SetForegroundColor(color))?
|
||||||
.queue(SetAttribute(Attribute::Underlined))?;
|
.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(canonical_path.as_bytes())?;
|
||||||
writer.stdout().write_all(b"\x1b\\")?;
|
writer.stdout().write_all(b"\x1b\\")?;
|
||||||
// Only this part is visible.
|
// Only this part is visible.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user