Skip to content

Commit

Permalink
fix windows console and relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
gulbanana committed Mar 19, 2024
1 parent 418dafa commit f22da42
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Desirable things
These changes may or may not be implemented in the future.
* bug: proper fix for https://github.com/tauri-apps/tauri/issues/9127 (currently worked-around via fork; fix may be in beta12, or it might not work)
* bug: open menu command sometimes opens multiple dialogues
* bug: no CLI output on windows
* edge case: mutations can fail due to ambiguity due to other writers; this should update the UI. maybe use a special From on resolve_change
* perf: optimise revdetail loads - we already have the header
* perf: better solution to slow immutability check - jj-lib will have a revset contains cache soon
Expand Down
38 changes: 34 additions & 4 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ clap = { version = "4.5.3", features = ["derive"] }

[patch.crates-io]
muda = { git = "https://github.com/gulbanana/muda.git", branch = "tauri-9127" }

[target."cfg(windows)".dependencies]
windows = { version = "0.54.0", features = ["Win32_System_Console", "Win32_Foundation"] }
7 changes: 7 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ impl AppState {
}

fn main() -> Result<()> {
// before parsing args, attach a console on windows - will fail if not started from a shell, but that's fine
#[cfg(windows)]
{
use windows::Win32::System::Console::{AttachConsole, ATTACH_PARENT_PROCESS};
let _ = unsafe { AttachConsole(ATTACH_PARENT_PROCESS) };
}

let args = Args::parse();

tauri::Builder::default()
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod tests;
use std::{
env::{self, VarError},
fmt::Debug,
fs,
path::PathBuf,
};

Expand Down Expand Up @@ -79,7 +80,7 @@ impl WorkerSession {
pub fn get_cwd(&self) -> Result<PathBuf> {
self.working_directory
.as_ref()
.map(|cwd| Ok(cwd.clone()))
.map(|cwd| Ok(fs::canonicalize(cwd.clone())?))
.or_else(|| match env::var("OWD") {
Ok(var) => Some(Ok(PathBuf::from(var))),
Err(VarError::NotPresent) => None,
Expand Down

0 comments on commit f22da42

Please sign in to comment.