-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert conditional setting of stdin handle #3379
Conversation
Switched to conditional compilation and tested on Windows and Ubuntu (WSL). Everything seemed to work as intended. |
helix-term/src/commands.rs
Outdated
#[cfg(not(target_family = "windows"))] | ||
if input.is_some() { | ||
process.stdin(Stdio::piped()); | ||
} | ||
#[cfg(target_family = "windows")] | ||
{ | ||
process.stdin(Stdio::piped()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need conditional compiling since it compiles ok on and off windows. The runtime behavior should be influenced by it though and that can be checked with the cfg!
macro
if input.is_some() || cfg!(windows) {
precss.stdin(Stdio::piped());
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this usually preferable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understand, it's best to only use what conditional compilation you really need. That way you don't mistakenly end up with wildly different code-paths on different operating systems. At the very least it makes rust-analyzer a little quieter to keep conditional compiles to a minimum :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, gotcha. Thanks!
I did have an issue with my first attempt, even though I was pretty sure it wasn't going to work. It did compile, but the binary would just hang there. The most surprising thing is that this was legal, and it compiled.
#[cfg(target_family = "windows")]
let a = "hello";
* Revert 3121353 * Switch to conditional compilation * Run formatter * Switch from conditional compilation to compile-time bool
* Revert 3121353 * Switch to conditional compilation * Run formatter * Switch from conditional compilation to compile-time bool
fixes #3374
I still like the change to avoid setting stdio if necessary, but it looks like this causes an issue on Windows.
After attempting other fixes, reverting the changes was the only thing that worked.
P.S. Conditional compilation could be added for non-Windows targets, but I think this would not add value to the codebase or Helix.