Fix launcher search: key_name returned code-unit numbers instead of characters
String indexing yields a UTF-16 code unit, so 'a' became "97" and the launcher rejected it. Convert to Char first; the input test now types into the search. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9e7687bea8
commit
57d5376211
2 files changed
+7
-1
No files matched your search
@@ -406,7 +406,7 @@ fn key_name(code : UInt, shift : Bool) -> String {
|
|||||||
for r in rows {
|
for r in rows {
|
||||||
let (first, chars) = r
|
let (first, chars) = r
|
||||||
if code >= first && code < first + chars.length().reinterpret_as_uint() {
|
if code >= first && code < first + chars.length().reinterpret_as_uint() {
|
||||||
let c = chars[(code - first).reinterpret_as_int()]
|
let c = Int::unsafe_to_char(chars[(code - first).reinterpret_as_int()].to_int())
|
||||||
return if shift && c >= 'a' && c <= 'z' {
|
return if shift && c >= 'a' && c <= 'z' {
|
||||||
Int::unsafe_to_char(c.to_int() - 32).to_string()
|
Int::unsafe_to_char(c.to_int() - 32).to_string()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -105,6 +105,12 @@ test "host input reaches the focused client and the launcher popup opens" {
|
|||||||
comp.handle_input(@nested.InputEvent::Key(30U, true), 23U)
|
comp.handle_input(@nested.InputEvent::Key(30U, true), 23U)
|
||||||
let after = drain_msgs(c)
|
let after = drain_msgs(c)
|
||||||
assert_false(has_msg(after, kbd_id, 3U)) // swallowed by the launcher
|
assert_false(has_msg(after, kbd_id, 3U)) // swallowed by the launcher
|
||||||
|
// Typing fills the search field: evdev 20 = t, 18 = e (key 30 = a was typed above).
|
||||||
|
comp.handle_input(@nested.InputEvent::Key(20U, true), 26U)
|
||||||
|
comp.handle_input(@nested.InputEvent::Key(18U, true), 27U)
|
||||||
|
assert_eq(comp.shell.launcher_state.query, "ate")
|
||||||
|
comp.handle_input(@nested.InputEvent::Key(14U, true), 28U)
|
||||||
|
assert_eq(comp.shell.launcher_state.query, "at")
|
||||||
// Off the shell and off any window: default arrow.
|
// Off the shell and off any window: default arrow.
|
||||||
comp.handle_input(@nested.InputEvent::PointerMove(1270.0, 5.0), 25U)
|
comp.handle_input(@nested.InputEvent::PointerMove(1270.0, 5.0), 25U)
|
||||||
assert_eq(comp.desired_cursor(), 1U)
|
assert_eq(comp.desired_cursor(), 1U)
|
||||||
|
|||||||
Reference in new issue
Block a user