Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit e57fa84

Browse files
committed
Use home_dir from home crate
The `$HOME` -> `$USERPROFILE` fallback logic does not work for Windows when running builds under `sh`. We don't canonicalize the path here so just rely on checking `$USERPROFILE` first and that it has `C:\Windows\Style` path instead of `/unix/one` (shape is important when stripping prefix).
1 parent 7ee3bb8 commit e57fa84

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ cargo_metadata = "0.6"
1616
clippy_lints = { git = "https://github.com/rust-lang/rust-clippy", rev = "a3c77f6ad1c1c185e561e9cd7fdec7db569169d1", optional = true }
1717
env_logger = "0.5"
1818
failure = "0.1.1"
19+
home = "0.3"
1920
itertools = "0.7.3"
2021
jsonrpc-core = "8.0.1"
2122
languageserver-types = "0.51"

src/actions/hover.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::config::FmtConfig;
1515
use crate::lsp_data::*;
1616
use crate::server::ResponseError;
1717

18+
use home;
1819
use racer;
1920
use rls_analysis::{Def, DefKind};
2021
use rls_span::{Column, Row, Span, ZeroIndexed};
@@ -646,10 +647,7 @@ fn racer_match_to_def(ctx: &InitActionContext, m: &racer::Match) -> Option<Def>
646647
let contextstr = if kind == DefKind::Mod {
647648
use std::env;
648649

649-
let home = env::var("HOME")
650-
.or_else(|_| env::var("USERPROFILE"))
651-
.map(PathBuf::from)
652-
.unwrap_or_default();
650+
let home = home::home_dir().unwrap_or_default();
653651
let rustup_home = env::var("RUSTUP_HOME")
654652
.map(PathBuf::from)
655653
.unwrap_or_else(|_| home.join(".rustup"));

0 commit comments

Comments
 (0)