Skip to content

Commit aa43e5e

Browse files
committed
fix(key_event): KeySequence::repr() prefer unescaped punctuation characters
1 parent bad8ab1 commit aa43e5e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/key_event.cc

+10
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ KeySequence::KeySequence(const string& repr) {
8989
clear();
9090
}
9191

92+
static bool is_unescaped_character(const KeyEvent& key_event) {
93+
int ch = key_event.keycode();
94+
return key_event.modifier() == 0 &&
95+
ch >= 0x20 && ch <= 0x7e &&
96+
ch != '{' && ch != '}';
97+
}
98+
9299
string KeySequence::repr() const {
93100
std::ostringstream result;
94101
string k;
@@ -97,6 +104,9 @@ string KeySequence::repr() const {
97104
if (k.size() == 1) {
98105
result << k;
99106
}
107+
else if (is_unescaped_character(*it)) {
108+
result << char(it->keycode());
109+
}
100110
else {
101111
result << '{' << k << '}';
102112
}

0 commit comments

Comments
 (0)