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

[VIM-1503]Adding option to "fix" the usability problem involving international keyboards and dead keys. #847

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bruno-ortiz
Copy link

Hi! First time contributing here. Please tell me if something could have been done better and I'll try to fix it.

Trying to fix this error: https://youtrack.jetbrains.com/issue/VIM-1503

The best that I could think of was to create an option for those that use this types of keyboard.

@citizenmatt
Copy link
Member

Thanks for the PR! I'm not entirely sure what it's doing - could you give some scenarios (inserting text, motions, etc.) and how it fixes the problems, please?

@bruno-ortiz
Copy link
Author

Hey @citizenmatt, sure! I'll try to explain:
Assume that in this examples the cursor is represented as the '*' char.
Whats happens without the PR:

val test = "Lorem ipsum do*lor sit amet"
// For some reason, if I try to select the entire sentence using the 'vi"' command, 
// it erases the character under the cursor and then selects the sentence. 
// In the example above, the letter 'o' will be erased.
val test = "*Lorem ipsum dlor sit amet*"

The code in this PR, tries to keep track of what "text" is under the cursor in the moment that an action is being executed. Thats what the preExecute method does in the EditorActionHandlerBase class.
And then I created a parent class for all textObject motions, that overrides the preExecute method to reinsert the text where it was previously deleted.
Example with the PR:

val test = "Lorem ipsum do*lor sit amet"
// Now when I try to select the entire sentence using the 'vi"' command, 
// it selects the entire sentence correctly.
val test = "*Lorem ipsum dolor sit amet*"

@AlexPl292 AlexPl292 self-requested a review March 19, 2024 08:31
@bruno-ortiz
Copy link
Author

Hey @citizenmatt, @AlexPl292.. Is this PR missing something to be reviewed? I don't mean to be annoying or demand anything, but this issue is really annoying for my workflow.
I'll gladly discuss/change anything about the PR :)

@citizenmatt
Copy link
Member

Hi Bruno. Apologies for the silence - there's not much bandwidth to look at stuff right now. Thanks for the contribution, but I must admit that I have a few reservations with this approach. I tried it locally, and after enabling :set fixdeadkeys, I can't get vi" to work directly. I still need to type something like vi"<Space> - the " is still highlighted as a composing character until I do something to finish it, such as <Space> or <Escape>. However, once I press the extra key, it does work as expected.

My main issue is that this is a workaround for a specific problem, rather than fixing the root cause. So it means that vi" can work (with additional keypress) and it doesn't replace the text, and this is great. However, it doesn't help with something like vf", or other dead keys from other keymaps (<A-N>) which will still overwrite the text. Unfortunately, I think we need to go a bit more low level in Swing to handle this properly, working with input methods to try and prevent the editor from drawing the composing character when in normal or visual mode.

This approach would require further investigation though, possibly using EditorComponent.enableInputMethods when the mode changes, or adding a custom IdeEventQueue event dispatcher that consumes input method events based on target and mode, but I'm not sure on the implications of these appraoches.

There are simpler workarounds, though, such as using a different keymap, if possible. The ABC keymap on the Mac doesn't have dead keys for the quote symbols, and something like Ukulele can create new keymaps that don't have any dead keys.

Thanks again for the contribution. I'll leave it up to @AlexPl292 to decide what to do with this PR as it stands. It might be worth taking on as a workaround until someone can take a look at other Swing based implementations (invitation is open to all! 😁)

@bruno-ortiz
Copy link
Author

bruno-ortiz commented Apr 2, 2024

Hey @citizenmatt thanks for the reply! I understand that this is a "hacky" solution, and you guys may have reservations against merging this PR(no hard feelings). About the need to press the extra key <Space> or <Esc>, unfortunately this is how it works for the international keyboard, even in Vim or NeoVim I have to issue the command vi"<Space>, so I think that this is not a problem.
About the other commands, maybe we could tackle in other PRs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants