-
Notifications
You must be signed in to change notification settings - Fork 151
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
feat: support external event queue #822
base: main
Are you sure you want to change the base?
Conversation
This helps nushell to implement `commandline edit --accept`, the same thing that `zle accept-line` does for zsh.
This looks interesting. Thanks! Generally, we'd like to not have unwrap() as much as possible. I'll have fun trying this out later. |
I updated the code to not use |
Is there another immediate use for this kind of event injection besides for nushell/nushell#11065 / nushell/nushell#13728 ? If there is a simpler solution with clear semantics that is easy to document/test I would prefer that to trying to be too general and drilling more holes into the internals. (e.g. now the ordering in the event loop could become load bearing to some behavior a library user may come up with, bikeshedding of If I understand the goal of running the output from Nushell |
Fascinating question. I also thought about this. And honestly, probably not.
I feel like, I don't fully understand what you mean. Reedline is single-threaded, right? Then the lock will be trivial to acquire. Something else, I figured after implementing: maybe I don't need the two queues. Currently, there is the local queue and a shared queue. Whenever the local queue is read, I append all the events from the shared queue beforehand. Maybe having one single queue at the first place is also a cleaner implementation?
Yes, that is the goal. And yes, I also don't see a need for synchronization, except that Rust requires a Mutex to allow the lifetime and access from different locations, basically a borrow check-proof shared memory. Feel free to propose an alternative implementation and I will give it a shot - I am a bit impatient about the feature and eager to implement it. |
I found an additional potential use case for this feature: |
This helps nushell to implement `commandline edit --accept`, the same thing that `zle accept-line` does for zsh.
How do I test this? |
Check out my PR over at nushell. Basically check out |
it seems to work for "print 'hello'" but not for "!!" or any of the other ! commands. |
Because I didn't implement it for the !-commands yet. I'd do that in a separate PR, because I'd prefer to have it as an opt-in and accordingly add a config option |
I added the two lines of code that immediately accept the bashisms. What are the maintainers' opinions on this? Obviously, a breaking change. But is it intended that we have to enter twice to accept a bash-expansion? Should this be configurable? I feel like an immediate accept is very sane default behavior. |
@@ -1639,6 +1662,12 @@ impl Reedline { | |||
.map(|token| (parsed.remainder.len(), indicator.len(), token.to_string())), | |||
}); | |||
|
|||
// if self.immediately_accept_bashisms { |
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.
would be good to remove these comments too
good move, dialing back the scope creep on both your prs. |
OK looking at the way This could be a simple Looking at the curent requirements:
I don't particularly like how Nushell Hooks are executed only by nushell and if a All of this is currently accomplished without shared state with reedline but rather happening on |
Thank you for your thorough introduction to the overall architecture. Now this is much clearer and I understand, why this is a bad implementation. As soon as I am done with my contributions over at tree-sitter-nu, I'll come back to this and incorporate my new insights into this implementation :) |
Just making this draft until we get back around to it. Thanks for working on this. |
This helps nushell to implement
commandline edit --accept
, the same thing thatzle accept-line
does for zsh.See this issue.