Windows: start git without a console window, and run one reload at a time #3
+11
-6
@@ -32,12 +32,17 @@ pub struct RepoData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn git(dir: &Path, args: &[&str]) -> Result<String, String> {
|
pub fn git(dir: &Path, args: &[&str]) -> Result<String, String> {
|
||||||
let out = Command::new("git")
|
let mut cmd = Command::new("git");
|
||||||
.arg("-C")
|
cmd.arg("-C").arg(dir).args(args);
|
||||||
.arg(dir)
|
// gites has no console, so Windows would open a console window for every git it
|
||||||
.args(args)
|
// starts. Each one flashes on screen and takes the focus, and gites reloads on focus.
|
||||||
.output()
|
#[cfg(windows)]
|
||||||
.map_err(|e| format!("could not run git: {e}"))?;
|
{
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||||
|
cmd.creation_flags(CREATE_NO_WINDOW);
|
||||||
|
}
|
||||||
|
let out = cmd.output().map_err(|e| format!("could not run git: {e}"))?;
|
||||||
if !out.status.success() {
|
if !out.status.success() {
|
||||||
return Err(String::from_utf8_lossy(&out.stderr).trim().to_string());
|
return Err(String::from_utf8_lossy(&out.stderr).trim().to_string());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,11 +105,18 @@ function startDrag(e: PointerEvent, axis: "x" | "y") {
|
|||||||
|
|
||||||
let filtersLoadedFor: string | null = null;
|
let filtersLoadedFor: string | null = null;
|
||||||
|
|
||||||
|
let loading = false;
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
|
// The window gets focus often; one reload at a time is enough.
|
||||||
|
if (loading) return;
|
||||||
|
loading = true;
|
||||||
try {
|
try {
|
||||||
await applyRepo(await invoke<RepoData>("load_repo"));
|
await applyRepo(await invoke<RepoData>("load_repo"));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error.value = String(e);
|
error.value = String(e);
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user