windows: Fix `ctrl-r` showing the control character (#34171)

张小白 created

Release Notes:

- N/A

Change summary

crates/gpui/src/platform/windows/events.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Detailed changes

crates/gpui/src/platform/windows/events.rs 🔗

@@ -1248,7 +1248,9 @@ fn parse_char_message(wparam: WPARAM, state_ptr: &Rc<WindowsWindowStatePtr>) ->
         }
         _ => {
             lock.pending_surrogate = None;
-            String::from_utf16(&[code_point]).ok()
+            char::from_u32(code_point as u32)
+                .filter(|c| !c.is_control())
+                .map(|c| c.to_string())
         }
     }
 }