mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 00:00:03 +03:00
Fix Windows terminal links
This commit is contained in:
parent
7a74a72dc8
commit
f6cf6c611c
|
@ -35,7 +35,7 @@ The following command will download and compile Rustlings:
|
||||||
<!-- TODO: Remove @6.0.0-beta.x -->
|
<!-- TODO: Remove @6.0.0-beta.x -->
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo install rustlings@6.0.0-beta.7
|
cargo install rustlings@6.0.0-beta.8
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
@ -44,7 +44,7 @@ cargo install rustlings@6.0.0-beta.7
|
||||||
<!-- TODO: Remove @6.0.0-beta.x -->
|
<!-- TODO: Remove @6.0.0-beta.x -->
|
||||||
|
|
||||||
- Make sure you have the latest Rust version by running `rustup update`
|
- Make sure you have the latest Rust version by running `rustup update`
|
||||||
- Try adding the `--locked` flag: `cargo install rustlings@6.0.0-beta.7 --locked`
|
- Try adding the `--locked` flag: `cargo install rustlings@6.0.0-beta.8 --locked`
|
||||||
- Otherwise, please [report the issue](https://github.com/rust-lang/rustlings/issues/new)
|
- Otherwise, please [report the issue](https://github.com/rust-lang/rustlings/issues/new)
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
|
@ -7,15 +7,18 @@ pub struct TerminalFileLink<'a>(pub &'a str);
|
||||||
|
|
||||||
impl<'a> Display for TerminalFileLink<'a> {
|
impl<'a> Display for TerminalFileLink<'a> {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
if let Ok(Some(canonical_path)) = fs::canonicalize(self.0)
|
let path = fs::canonicalize(self.0);
|
||||||
.as_deref()
|
|
||||||
.map(|path| path.to_str())
|
if let Some(path) = path.as_deref().ok().and_then(|path| path.to_str()) {
|
||||||
{
|
// Windows itself can't handle its verbatim paths.
|
||||||
write!(
|
#[cfg(windows)]
|
||||||
f,
|
let path = if path.len() > 5 && &path[0..4] == r"\\?\" {
|
||||||
"\x1b]8;;file://{}\x1b\\{}\x1b]8;;\x1b\\",
|
&path[4..]
|
||||||
canonical_path, self.0,
|
} else {
|
||||||
)
|
path
|
||||||
|
};
|
||||||
|
|
||||||
|
write!(f, "\x1b]8;;file://{path}\x1b\\{}\x1b]8;;\x1b\\", self.0)
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}", self.0)
|
write!(f, "{}", self.0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue