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

Restore document state on completion cancel #2096

Merged

Conversation

andreytkachenko
Copy link
Contributor

Restoring document state after completion cancel.

@@ -282,13 +283,6 @@ impl Completion {

impl Component for Completion {
fn handle_event(&mut self, event: Event, cx: &mut Context) -> EventResult {
// let the Editor handle Esc instead
Copy link
Member

Choose a reason for hiding this comment

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

This override was meaningful though: we wanted esc to both cancel completion and leave insert mode.

Copy link
Contributor Author

@andreytkachenko andreytkachenko Apr 17, 2022

Choose a reason for hiding this comment

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

Yes, that's true. I am suggesting that change and I have explanations. First of all I would like to mention that it is same how vim and other modal editors works. Second it is very (by my opinion, of course) annoying and unexpected when you press escape(mostly a reflex) to unwanted completion window to continue input you got normal mode and you need to get back to insert mode again(I know about ctrl-c, but escape is so obvious). I thing we should ask about it in matrix and summarize more opinions. If you think it is principal I can split that PR ?

Copy link
Member

Choose a reason for hiding this comment

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

The behavior was intentional: it's even more annoying when you're typing code in insert mode, you try to exit insert mode but during that time the auto-completion popup appeared. You cancel the auto-completion and start typing normal mode commands but these result in text edits.

Ctrl-c is already available as a way to close the completion popup without exiting insert mode. Esc is a way to exit insert mode and clearing the completion is a side effect.

@archseer archseer merged commit 3a7bf1c into helix-editor:master Apr 20, 2022
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.

2 participants