mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-18 16:08:55 +00:00
fix(welcome): a recent WSL project stored with forward slashes is not shown as missing (#3860)
Recent projects are stored as `//wsl.localhost/Ubuntu/...`; the exemption for WSL shares (a stopped distribution only hides them) recognised the backslash form only.
This commit is contained in:
@@ -156,7 +156,9 @@ pub fn with_live_branches(mut items: Vec<RecentProject>) -> Vec<RecentProject> {
|
||||
/// and WSL shares, which a stopped distribution only hides, never count as missing.
|
||||
fn is_missing(path: &Path) -> bool {
|
||||
let text = path.to_string_lossy();
|
||||
let wsl = text.starts_with(r"\\wsl$") || text.starts_with(r"\\wsl.localhost");
|
||||
// Stored paths may use `/` (`//wsl.localhost/Ubuntu/...`); host names ignore case.
|
||||
let unc = text.replace('/', r"\").to_ascii_lowercase();
|
||||
let wsl = unc.starts_with(r"\\wsl$") || unc.starts_with(r"\\wsl.localhost");
|
||||
path.is_absolute() && !text.contains("://") && !wsl && !path.exists()
|
||||
}
|
||||
|
||||
@@ -258,6 +260,15 @@ impl RecentProjects {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn wsl_shares_stored_with_forward_slashes_are_never_missing() {
|
||||
for path in
|
||||
[r"\\wsl.localhost\Ubuntu\home\me\gone", "//wsl.localhost/Ubuntu/home/me/gone", "//WSL$/Ubuntu/gone"]
|
||||
{
|
||||
assert!(!is_missing(Path::new(path)), "{path}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn newest_first_capped_and_persisted() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user