mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-30 02:07:10 +01:00
Scripts: leave getIsFileOpen's path comparison as main has it
The change to how getIsFileOpen compares paths on and off Windows goes in its own change, with its test.
This commit is contained in:
1 parent
8c668944d1
commit
38dfb800e1
2 files changed
+6
-15
No files matched your search
@@ -881,14 +881,13 @@ fn app_set_coords(h: &Host, a: &[Data]) -> Answer {
|
||||
Ok(Data::Undefined)
|
||||
}
|
||||
|
||||
/// A path as `getIsFileOpen` compares it. A Windows path (any path on Windows, or one with a drive
|
||||
/// letter) has `\` and `/` alike and letters in one case; elsewhere a `\` is a character of a name.
|
||||
/// A path as `getIsFileOpen` compares it: `\` and `/` alike, and on Windows paths (a drive letter
|
||||
/// or a `\`) letters in one case.
|
||||
fn path_key(p: &str) -> String {
|
||||
if cfg!(windows) || p.as_bytes().get(1) == Some(&b':') {
|
||||
p.replace('\\', "/").trim_end_matches('/').to_lowercase()
|
||||
} else {
|
||||
p.trim_end_matches('/').to_string()
|
||||
}
|
||||
let windows = p.contains('\\') || p.as_bytes().get(1) == Some(&b':');
|
||||
let p = p.replace('\\', "/");
|
||||
let p = p.trim_end_matches('/').to_string();
|
||||
if windows { p.to_lowercase() } else { p }
|
||||
}
|
||||
|
||||
/// `app.redraw()`: returns without changing anything. The app draws a frame between the run's
|
||||
|
||||
@@ -1942,14 +1942,6 @@ fn get_is_file_open_cannot_probe_outside_script_scope() {
|
||||
let query = format!("vc.log(app.getIsFileOpen({p})); vc.log(app.getIsFileOpen({other}));");
|
||||
let out = log(&mut s, &query);
|
||||
assert_eq!(out, vec![json!(true), json!(false)]);
|
||||
// Outside Windows a `\` is a character of a name: the folder and the name joined by one name
|
||||
// another file.
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
let (dir, name) = (path.parent().unwrap().to_string_lossy(), path.file_name().unwrap().to_string_lossy());
|
||||
let joined = serde_json::to_string(&format!("{dir}\\{name}")).unwrap();
|
||||
assert_eq!(log(&mut s, &format!("vc.log(app.getIsFileOpen({joined}));")), vec![json!(false)], "{joined}");
|
||||
}
|
||||
// Read roots that leave out the document's file: the same path does not count.
|
||||
let elsewhere = fixture.join("elsewhere");
|
||||
std::fs::create_dir_all(&elsewhere).unwrap();
|
||||
|
||||
Reference in new issue
Block a user