@@ -46,7 +46,7 @@ static MAP_STRING: &str = include_str!("./gnome_to_ghostty.json");
46
46
/// - gnome_to_ghostty_shortcut: A hashmap with a mapping from gnome configuration key
47
47
/// representatioin to ghostty's.
48
48
fn convert_gnome_shortcut_to_ghostty (
49
- gnome_shortcut : & String ,
49
+ gnome_shortcut : & str ,
50
50
gnome_to_ghostty_shortcut : & HashMap < String , String > ,
51
51
) -> Option < String > {
52
52
let ghostty_shortcut = gnome_shortcut
@@ -58,9 +58,9 @@ fn convert_gnome_shortcut_to_ghostty(
58
58
match mapped {
59
59
Some ( ghostty_key) => {
60
60
if ghostty_key. is_empty ( ) || ghostty_key == "disabled" {
61
- return None ;
61
+ None
62
62
} else {
63
- return Some ( ghostty_key. to_string ( ) ) ;
63
+ Some ( ghostty_key. to_string ( ) )
64
64
}
65
65
}
66
66
None => Some ( key. to_string ( ) ) ,
@@ -102,14 +102,7 @@ fn convert_gnome_to_ghostty_shortcuts(
102
102
None => return None ,
103
103
}
104
104
105
- let ghostty_shortcut = if let Some ( shortcut) =
106
- convert_gnome_shortcut_to_ghostty ( binding, & gnome_to_ghostty_shortcut)
107
- {
108
- shortcut
109
- } else {
110
- return None ;
111
- } ;
112
-
105
+ let ghostty_shortcut = convert_gnome_shortcut_to_ghostty ( binding, gnome_to_ghostty_shortcut) ?;
113
106
Some ( ( ghostty_action. unwrap ( ) . to_string ( ) , ghostty_shortcut) )
114
107
} )
115
108
. collect ( )
@@ -231,7 +224,7 @@ fn update_ghostty_config(
231
224
232
225
let config_found: bool = io:: BufReader :: new ( & config_file)
233
226
. lines ( )
234
- . filter_map ( Result :: ok)
227
+ . map_while ( Result :: ok)
235
228
. any ( |line| re. is_match ( & line) ) ;
236
229
237
230
let gnome_shortcuts_path = ghostty_config_dir. join ( "gnome-shortcuts" ) ;
@@ -257,7 +250,7 @@ fn update_ghostty_config(
257
250
} ;
258
251
259
252
for ( action, binding) in & converted_gnome_shortcuts {
260
- if ( avoid_conflict && ( !ghostty_shortcuts. contains_key ( action) && !keybindings. contains_key ( binding) ) ) || !avoid_conflict {
253
+ if ! avoid_conflict || !ghostty_shortcuts. contains_key ( action) && !keybindings. contains_key ( binding) {
261
254
gnome_shortcuts_config
262
255
. write_all ( format ! ( "keybind = {}={}\n " , binding, action) . as_bytes ( ) )
263
256
. unwrap ( ) ;
@@ -279,13 +272,13 @@ fn main() {
279
272
let gnome_shortcuts = get_gnome_shortcuts ( ) ;
280
273
let converted_shortcuts = convert_gnome_to_ghostty_shortcuts ( gnome_shortcuts) ;
281
274
282
- if args. gnome || ( !args. ghostty && !args . gnome ) {
275
+ if args. gnome || !args. ghostty {
283
276
println ! ( "{}" , "Gnome Shortcuts" . italic( ) . bold( ) . bright_blue( ) ) ;
284
277
print_ghostty_shortcuts ( & converted_shortcuts) ;
285
278
}
286
279
287
280
let ghostty_shortcuts = get_ghostty_shortcuts ( ) ;
288
- if args. ghostty || ( !args. ghostty && !args . gnome ) {
281
+ if args. ghostty || !args. gnome {
289
282
println ! ( "{}" , "Ghostty Shortcuts" . italic( ) . bold( ) . bright_blue( ) ) ;
290
283
print_ghostty_shortcuts ( & ghostty_shortcuts) ;
291
284
}
0 commit comments