mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-04 17:23:36 +02:00
Fix file links in VS Code
This commit is contained in:
+6
-6
@@ -60,8 +60,7 @@ pub struct AppState {
|
||||
file_buf: Vec<u8>,
|
||||
official_exercises: bool,
|
||||
cmd_runner: CmdRunner,
|
||||
// Running in VS Code.
|
||||
vs_code: bool,
|
||||
emit_file_links: bool,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
@@ -181,7 +180,8 @@ impl AppState {
|
||||
file_buf,
|
||||
official_exercises: !Path::new("info.toml").exists(),
|
||||
cmd_runner,
|
||||
vs_code: env::var_os("TERM_PROGRAM").is_some_and(|v| v == "vscode"),
|
||||
// VS Code has its own file link handling
|
||||
emit_file_links: env::var_os("TERM_PROGRAM").is_none_or(|v| v != "vscode"),
|
||||
};
|
||||
|
||||
Ok((slf, state_file_status))
|
||||
@@ -218,8 +218,8 @@ impl AppState {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn vs_code(&self) -> bool {
|
||||
self.vs_code
|
||||
pub fn emit_file_links(&self) -> bool {
|
||||
self.emit_file_links
|
||||
}
|
||||
|
||||
// Write the state file.
|
||||
@@ -621,7 +621,7 @@ mod tests {
|
||||
file_buf: Vec::new(),
|
||||
official_exercises: true,
|
||||
cmd_runner: CmdRunner::build().unwrap(),
|
||||
vs_code: false,
|
||||
emit_file_links: true,
|
||||
};
|
||||
|
||||
let mut assert = |done: [bool; 3], expected: [Option<usize>; 3]| {
|
||||
|
||||
Reference in New Issue
Block a user