Skip to content

refactor!: graceful handle ReedlineEvent::CtrlC#1051

Merged
fdncred merged 2 commits into
nushell:mainfrom
tisonkun:handle-ctrl-c-graceful
Apr 17, 2026
Merged

refactor!: graceful handle ReedlineEvent::CtrlC#1051
fdncred merged 2 commits into
nushell:mainfrom
tisonkun:handle-ctrl-c-graceful

Conversation

@tisonkun
Copy link
Copy Markdown
Contributor

@tisonkun tisonkun commented Apr 14, 2026

This closes #1050

This aligns the manner of ReedlineEvent::CtrlD. I don't know what self.deactivate_menus(); does so do my guess to put it in the if self.editor.is_empty() branch.

Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
Copy link
Copy Markdown
Contributor Author

cc @cptpiepmatz @fdncred in case if you have time to drop a review

Comment thread src/engine.rs Outdated
@tisonkun tisonkun requested a review from fdncred April 15, 2026 14:02
Copy link
Copy Markdown
Contributor

@fdncred fdncred left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM!

@tisonkun
Copy link
Copy Markdown
Contributor Author

@fdncred I'm waiting for this PR to be released to use in my project.

Are there any other blockers, or is there some estimation I can expect?

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 15, 2026

I've been waiting for our patch release which happened just a few minutes ago. I'll probably land this PR tomorrow or the next day.

@tisonkun
Copy link
Copy Markdown
Contributor Author

Thanks for your information!

@fdncred fdncred merged commit df83329 into nushell:main Apr 17, 2026
7 checks passed
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 17, 2026

Thanks!

Comment thread src/engine.rs
self.editor.reset_undo_stack();
Ok(EventStatus::Exits(Signal::CtrlC))
if self.editor.is_empty() {
self.editor.reset_undo_stack();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is a bit late for the review. But I believe CtrlC should always clear undo stack

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tisonkun if you want to submit another PR to make that change, we can land it pretty quickly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fdncred See #1058

Sorry I miss this comment the very first time.

@Juhan280
Copy link
Copy Markdown
Contributor

So, I have been running this for a few day now. Not sure I like this change. I would prefer to have a way to get original functionality back somehow. I want to know what others think about this.

CtrlC clears the prompt instead of making a new prompt (that was the point of this PR). But I find myself wanting to copy stuff from my previous prompt which I CtrlC-ed to the current prompt. But its no longer possible since the prompt is gone. Not sure how many people might have similar experience as my but I assume that would be very small number of people.

Because of the point mentioned above, CtrlC should probably not clear undo stack (already current behavior, but still mentioning this because I stated the opposite in my previous comment.)

Previously, CtrlC-ing from vi_normal mode would take me to vi_insert mode in a new prompt. But after this PR, CtrlC-ing the first time only clears the prompt keeping me in my current mode. Only after CtrlC-ing the second time (when the prompt is empty), it takes me to vi_insert mode. Not sure if I like this change either.But I can get used to this. CtrlC sometimes maintain current mode and sometimes doesn't. I think this is a confusing behavior. It should be consistent.

I made this comment to bring attention to the matter that it changes very core behavior the users interact with the most. So we should give it more thorough consideration whether we want this change or want to compromise.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented Apr 19, 2026

I vote for consistency and making things easier for the user, which falls in line with your idea of not clearing and generally making thigs more consistent.

@NotTheDr01ds
Copy link
Copy Markdown
Contributor

NotTheDr01ds commented May 17, 2026

@fdncred If I'm reading your comment correctly, you are in support of rolling back this change? If so, I can take care of it.

@tisonkun Can you look for another solution for your use-case? For Nushell, we do want to keep the command intact on Ctrl+C.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 17, 2026

@NotTheDr01ds I'm up for whatever the right fix is. There's also #1058 although we're getting close to a release again without much time to test.

@NotTheDr01ds
Copy link
Copy Markdown
Contributor

@fdncred Since it's just reverting a 4-line change (cumulative, between the two commits), I'm not too worried. It's also well tested behavior since it's been working this way for years ;-).

I've submitted #1081 for it if you can give it a quick glance.

@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 18, 2026

@NotTheDr01ds i saw it. go for it if that's what you want to do. it's not really bothering me the way it is now.

@tisonkun tisonkun deleted the handle-ctrl-c-graceful branch May 18, 2026 11:20
@tisonkun
Copy link
Copy Markdown
Contributor Author

@tisonkun Can you look for another solution for your use-case?

If Ctrl+C is hardcoded as before this PR in reedline, I think there is no escape way :O

NotTheDr01ds added a commit that referenced this pull request May 18, 2026
rbran pushed a commit to rbran/reedline that referenced this pull request May 19, 2026
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.

Retrieve buffer when receive CtrlC

4 participants