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

fix: inconsistent Shift key behavior on Unix and Windows #174

Merged
merged 10 commits into from
Sep 20, 2023

Conversation

ndtoan96
Copy link
Contributor

Fix #166

@ndtoan96
Copy link
Contributor Author

What is your autoformat setting, I use the default one which comes with rust-analyzer, seems like it is different from yours.

@sxyazi
Copy link
Owner

sxyazi commented Sep 18, 2023

uh, I use rustfmt nightly and https://github.com/sxyazi/yazi/blob/main/rustfmt.toml as its config

@sxyazi
Copy link
Owner

sxyazi commented Sep 19, 2023

I tested it and it recognized <S-a> as a:

{ on = [ "<S-a>" ], exec = "arrow 5" },

When I press a triggers arrow 5

@ndtoan96
Copy link
Contributor Author

ndtoan96 commented Sep 19, 2023

In my opinion, a keymap <S-a> does not make sense, we can just use A. If you want to support <S-a> style, then we will have to think about all other cases, for example <C-S-/> vs <C-?>. And if we take different keyboard layouts into the picture (French one for example), things will get quite complicated because we don't know which character is the "shifted" one.

@sxyazi
Copy link
Owner

sxyazi commented Sep 19, 2023

I think not supporting <S-a> should result in nothing happening; let it fail silently, just like Yazi's current behavior, rather than recognizing it as a.

@ndtoan96
Copy link
Contributor Author

I've flashed a mini Linux on my USB to quickly check. There is inconsistency between Linux and Windows key event:

Key Windows Linux
Shift + a Char('A') + SHIFT Char('A') + SHIFT
Shift + / Char('?') + SHIFT Char('?') + 0x0

Then I found this issue: crossterm-rs/crossterm#421

Looks like in the past they fix the inconsistency for alphabetic characters, but not for other shifted characters. I'll report this issue to crossterm and see if they can fix it from upstream. If they cannot, we have to adapt with the different behavior between OS.

@ndtoan96
Copy link
Contributor Author

Can you help me check again? I decided to work around the inconsistency for now because it kinda breaks the app on Windows. I'll come back to this issue later if the crossterm team decides to address it.

config/src/keymap/key.rs Outdated Show resolved Hide resolved
@sxyazi
Copy link
Owner

sxyazi commented Sep 20, 2023

It worked on my side, I'll merge it, thanks @ndtoan96

@sxyazi sxyazi changed the title Shift char keymap fix: inconsistent Shift key behavior on Unix and Windows Sep 20, 2023
@sxyazi sxyazi merged commit 4065a05 into sxyazi:main Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some keymap ("shift" character) does not work on Windows Terminal
2 participants