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

Make repeat operator work with completion edits #1640

Merged
merged 15 commits into from
Mar 1, 2022

Conversation

matszczygiel
Copy link
Contributor

@matszczygiel matszczygiel commented Feb 9, 2022

This hopefully fixes the problem with repeating last change when code action occurred. Closes #1517

@matszczygiel matszczygiel marked this pull request as ready for review February 9, 2022 22:01
@matszczygiel
Copy link
Contributor Author

Unfortunately, there are still some problems . It is not ready to merge yet.

helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
helix-term/src/ui/editor.rs Outdated Show resolved Hide resolved
@archseer archseer changed the title Fix #1517 Make repeat operator work with completion edits Feb 10, 2022
@matszczygiel
Copy link
Contributor Author

According to my humble testing it works now. @archseer could you please take a look ?

helix-term/src/ui/editor.rs Outdated Show resolved Hide resolved
helix-term/src/ui/completion.rs Outdated Show resolved Hide resolved
helix-term/src/ui/editor.rs Outdated Show resolved Hide resolved
helix-view/src/editor.rs Outdated Show resolved Hide resolved
Comment on lines +772 to +775
InsertEvent::TriggerCompletion => {
let (_, doc) = current!(cxt.editor);
doc.savepoint();
}
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 this is necessary, it's just for reverting completion changes when you tab through the completion menu. I'd remove InsertEvent::TriggerCompletion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I think it is. When I remove this, the completion changes are applied after the text typed by the user.
Peek 2022-02-17 16-02

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, because you also have that doc.restore on L751. You should remove both savepoint() and restore() then it should work.

Copy link
Contributor Author

@matszczygiel matszczygiel Feb 20, 2022

Choose a reason for hiding this comment

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

@archseer it's the same story when I remove both lines. The save and restore logic is copied from the completion logic, otherwise it doesn't work.

Copy link
Member

Choose a reason for hiding this comment

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

Ah right. This is what happens:

std:: <- completion triggers, doc.savepoint() is called
std::thre <- filters completion items
Enter <- clears back to save point std:: then applies the completion.

I'll do some testing to see if I can avoid that.

helix-term/src/ui/editor.rs Outdated Show resolved Hide resolved
helix-view/src/editor.rs Show resolved Hide resolved
helix-term/src/ui/editor.rs Show resolved Hide resolved
@archseer
Copy link
Member

archseer commented Mar 1, 2022

Thanks for working on this! I'll merge this as is since it fixes a big annoyance. I'll see if I can remove snapshot()/restore() in a follow up.

@archseer archseer merged commit 14e2ced into helix-editor:master Mar 1, 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.

'Repeat Last Change' not working with autocompletion
2 participants