Skip to content

Commit 9ab829b

Browse files
authored
fix Shift+Tab normalized to Tab (#1132)
1 parent ce6227b commit 9ab829b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/lib/fcitx-utils/key.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ bool Key::isVirtual() const { return states_.test(KeyState::Virtual); }
470470

471471
Key Key::normalize() const {
472472
Key key(*this);
473+
474+
if (key.sym_ == FcitxKey_ISO_Left_Tab) {
475+
key.sym_ = FcitxKey_Tab;
476+
}
477+
473478
/* key state != 0 */
474479
key.states_ =
475480
key.states_ & KeyStates({KeyState::Ctrl_Alt_Shift, KeyState::Super,
@@ -495,17 +500,14 @@ Key Key::normalize() const {
495500
if ((key.states_ & KeyState::Shift) &&
496501
(((Key(key.sym_).isSimple() ||
497502
keySymToUnicode(key.sym_) != 0) &&
498-
key.sym_ != FcitxKey_space && key.sym_ != FcitxKey_Return) ||
503+
key.sym_ != FcitxKey_space && key.sym_ != FcitxKey_Return &&
504+
key.sym_ != FcitxKey_Tab) ||
499505
(key.sym_ >= FcitxKey_KP_0 && key.sym_ <= FcitxKey_KP_9))) {
500506
key.states_ ^= KeyState::Shift;
501507
}
502508
}
503509
}
504510

505-
if (key.sym_ == FcitxKey_ISO_Left_Tab) {
506-
key.sym_ = FcitxKey_Tab;
507-
}
508-
509511
return key;
510512
}
511513

test/testkey.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ int main() {
7474
FCITX_ASSERT(fcitx::Key("S").check(fcitx::Key("Shift+S").normalize()));
7575
FCITX_ASSERT(
7676
fcitx::Key("Shift+F4").check(fcitx::Key("Shift+F4").normalize()));
77+
FCITX_ASSERT(
78+
fcitx::Key("Shift+Tab").check(fcitx::Key("Shift+Tab").normalize()));
79+
FCITX_ASSERT(fcitx::Key("Shift+Return")
80+
.check(fcitx::Key("Shift+Return").normalize()));
81+
FCITX_ASSERT(
82+
fcitx::Key("Shift+space").check(fcitx::Key("Shift+space").normalize()));
7783
FCITX_ASSERT(
7884
fcitx::Key("Control+A").check(fcitx::Key("Control+a").normalize()));
7985
FCITX_ASSERT(fcitx::Key("Alt+exclam")

0 commit comments

Comments
 (0)