Skip to content
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

Merged
merged 6 commits into from
Aug 12, 2022

Conversation

AceofSpades5757
Copy link
Contributor

@AceofSpades5757 AceofSpades5757 commented Aug 10, 2022

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.

@archseer archseer added this to the 22.08 milestone Aug 10, 2022
@the-mikedavis the-mikedavis changed the title Revert 3121353c6ab2fbc5fced28f075c7fc45b53b661e Revert conditional setting of stdin handle Aug 10, 2022
@AceofSpades5757
Copy link
Contributor Author

Switched to conditional compilation and tested on Windows and Ubuntu (WSL). Everything seemed to work as intended.

Comment on lines 4562 to 4569
#[cfg(not(target_family = "windows"))]
if input.is_some() {
process.stdin(Stdio::piped());
}
#[cfg(target_family = "windows")]
{
process.stdin(Stdio::piped());
}
Copy link
Member

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());
}

Copy link
Contributor Author

@AceofSpades5757 AceofSpades5757 Aug 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this usually preferable?

Copy link
Member

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

Copy link
Contributor Author

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";

@archseer archseer merged commit 21f2aff into helix-editor:master Aug 12, 2022
AlexanderBrevig pushed a commit to AlexanderBrevig/helix that referenced this pull request Aug 29, 2022
* Revert 3121353

* Switch to conditional compilation

* Run formatter

* Switch from conditional compilation to compile-time bool
thomasskk pushed a commit to thomasskk/helix that referenced this pull request Sep 9, 2022
* Revert 3121353

* Switch to conditional compilation

* Run formatter

* Switch from conditional compilation to compile-time bool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running a shell command breaks terminal sequences
3 participants