Skip to content

Allow piping from stdin into a buffer on startup - #996

Merged
archseer merged 6 commits into
helix-editor:masterfrom
jasonrhansen:stdin
Nov 10, 2021
Merged

Allow piping from stdin into a buffer on startup#996
archseer merged 6 commits into
helix-editor:masterfrom
jasonrhansen:stdin

Conversation

@jasonrhansen

Copy link
Copy Markdown
Contributor

Closes #927

Comment thread helix-view/src/editor.rs Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

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

crossterm-rs/crossterm#500

@kirawi

kirawi commented Nov 6, 2021

Copy link
Copy Markdown
Member

Conditionally disabling on MacOS might make sense right now.

Comment thread helix-term/src/application.rs Outdated
Comment thread helix-term/src/application.rs Outdated
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