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

Allow piping from stdin into a buffer on startup #996

Merged
merged 6 commits into from
Nov 10, 2021

Conversation

jasonrhansen
Copy link
Contributor

Closes #927

@@ -311,7 +313,13 @@ impl Editor {
pub fn new_file(&mut self, action: Action) -> DocumentId {
let id = DocumentId(self.next_document_id);
self.next_document_id += 1;
let mut doc = Document::default();
let mut doc = if stdin().is_tty() {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want it to be in this function, I think it would make more sense for it to be in helix-term/src/application.rs::Application::new()

It did make me think of potentially opening new files that were piped from an application via :n "<shell stuff>" as a shortcut to creating a new file and directly piping it like that. @archseer

@jasonrhansen
Copy link
Contributor Author

I tested this on Linux, Windows, and macOS. It works on Linux and Windows, but unfortunately not on macOS. It might be a bug in crossterm, but I'll have to do some more digging.

Here's the panic message:

thread 'main' panicked at 'reader source not set', ***/crossterm-0.22.1/src/event/read.rs:38:30

@jasonrhansen
Copy link
Contributor Author

Looks like there's an open issue for the macOS problem I'm seeing.

crossterm-rs/crossterm#500

@kirawi
Copy link
Member

kirawi commented Nov 6, 2021

Conditionally disabling on MacOS might make sense right now.

helix-term/src/application.rs Outdated Show resolved Hide resolved
helix-term/src/application.rs Outdated Show resolved Hide resolved
jasonrhansen and others added 3 commits November 6, 2021 20:05
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
@archseer archseer merged commit cf831b1 into helix-editor:master Nov 10, 2021
EbbDrop pushed a commit to EbbDrop/helix that referenced this pull request Nov 11, 2021
* Allow piping from stdin into a buffer on startup

* Refactor

* Don't allow piping into new buffer on macOS

* Update helix-term/src/application.rs

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

* Update helix-term/src/application.rs

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

* Fix

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
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.

Support reading from standard input
3 participants