@@ -70,7 +70,7 @@ impl FromStr for Key {
70
70
type Err = Error ;
71
71
72
72
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
73
- let s = s. trim ( ) ;
73
+ let s = s. trim_ascii ( ) ;
74
74
{
75
75
let mut c = s. chars ( ) ;
76
76
if let ( Some ( c) , None ) = ( c. next ( ) , c. next ( ) ) {
@@ -159,7 +159,7 @@ impl FromStr for Mods {
159
159
type Err = Error ;
160
160
161
161
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
162
- match s. trim ( ) {
162
+ match s. trim_ascii ( ) {
163
163
"Control" | "control" | "CONTROL" | "Ctrl" | "ctrl" | "CTRL" => Ok ( Self :: CTRL ) ,
164
164
"Command" | "command" | "COMMAND" | "Cmd" | "cmd" | "CMD" => Ok ( Self :: CMD ) ,
165
165
"Mod" | "mod" | "MOD" => Ok ( Self :: MOD ) ,
@@ -200,7 +200,7 @@ impl FromStr for KeyInput {
200
200
type Err = Error ;
201
201
202
202
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
203
- let mut s = s. trim ( ) . split ( '+' ) ;
203
+ let mut s = s. trim_ascii ( ) . split ( '+' ) ;
204
204
let mut cur = s. next ( ) . unwrap ( ) ; // Iterator by `.split()` is never empty
205
205
let mut mods = Mods :: NONE ;
206
206
loop {
@@ -282,7 +282,7 @@ impl FromStr for KeySeq {
282
282
type Err = Error ;
283
283
284
284
fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
285
- let mut keys = s. split_whitespace ( ) ;
285
+ let mut keys = s. split_ascii_whitespace ( ) ;
286
286
if let Some ( key) = keys. next ( ) {
287
287
let mut seq = Self :: Single ( key. parse ( ) ?) ;
288
288
for key in keys {
@@ -348,6 +348,8 @@ mod tests {
348
348
) ,
349
349
( "Shift+Plus" , KeyInput :: new ( '+' , Mods :: SHIFT ) ) ,
350
350
( "Shift+Space" , KeyInput :: new ( ' ' , Mods :: SHIFT ) ) ,
351
+ ( " " , KeyInput :: new ( ' ' , Mods :: NONE ) ) ,
352
+ ( "Ctrl+ " , KeyInput :: new ( ' ' , Mods :: CTRL ) ) ,
351
353
] ;
352
354
353
355
for ( input, expected) in tests {
@@ -397,6 +399,13 @@ mod tests {
397
399
KeyInput :: new( 'c' , Mods :: MOD ) ,
398
400
] ) ,
399
401
) ,
402
+ (
403
+ " Ctrl+ " ,
404
+ KeySeq :: from ( vec ! [
405
+ KeyInput :: new( ' ' , Mods :: NONE ) ,
406
+ KeyInput :: new( ' ' , Mods :: CTRL ) ,
407
+ ] ) ,
408
+ ) ,
400
409
] ;
401
410
402
411
for ( seq, expected) in tests {
0 commit comments