@@ -326,11 +326,7 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
326
326
Task :: none ( )
327
327
}
328
328
Message :: ToggleTabBar => {
329
- if self . with_tab_bar {
330
- self . with_tab_bar = false ;
331
- } else {
332
- self . with_tab_bar = true ;
333
- }
329
+ self . with_tab_bar = !self . with_tab_bar ;
334
330
Task :: none ( )
335
331
}
336
332
Message :: ShowTabBar => {
@@ -342,11 +338,7 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
342
338
Task :: none ( )
343
339
}
344
340
Message :: ToggleNavBar => {
345
- if self . with_nav_bar {
346
- self . with_nav_bar = false ;
347
- } else {
348
- self . with_nav_bar = true ;
349
- }
341
+ self . with_nav_bar = !self . with_nav_bar ;
350
342
Task :: none ( )
351
343
}
352
344
Message :: ShowNavBar => {
@@ -358,11 +350,7 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
358
350
Task :: none ( )
359
351
}
360
352
Message :: ToggleBookmarkBar => {
361
- if self . with_bookmark_bar {
362
- self . with_bookmark_bar = false ;
363
- } else {
364
- self . with_bookmark_bar = true ;
365
- }
353
+ self . with_bookmark_bar = !self . with_bookmark_bar ;
366
354
Task :: none ( )
367
355
}
368
356
Message :: ShowBookmarkBar => {
@@ -375,9 +363,18 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
375
363
}
376
364
Message :: CommandPalatteQueryChanged ( query) => {
377
365
self . command_window_state . query = query. clone ( ) ;
366
+ self . command_window_state . filtered_results =
367
+ self . command_window_state . possible_results . clone ( ) ;
368
+
369
+ if let Some ( url) = to_url ( query. as_str ( ) ) {
370
+ self . command_window_state
371
+ . filtered_results
372
+ . push ( ResultType :: Url ( url. to_string ( ) ) ) ;
373
+ }
374
+
378
375
self . command_window_state . filtered_results = self
379
376
. command_window_state
380
- . possible_results
377
+ . filtered_results
381
378
. clone ( )
382
379
. into_iter ( )
383
380
. filter ( |command| {
@@ -390,7 +387,7 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
390
387
. to_lowercase ( )
391
388
. contains ( & query. to_lowercase ( ) )
392
389
} )
393
- . collect ( ) ;
390
+ . collect :: < Vec < _ > > ( ) ;
394
391
Task :: none ( )
395
392
}
396
393
Message :: CommandPalatteKeyboardEvent ( event) => {
@@ -413,11 +410,8 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
413
410
}
414
411
match key {
415
412
key:: Key :: Named ( key:: Named :: Escape ) => {
416
- self . command_window_state . query = String :: new ( ) ;
417
- self . command_window_state . filtered_results =
418
- self . command_window_state . possible_results . clone ( ) ;
419
- self . command_window_state . selected_item = None ;
420
-
413
+ self . command_window_state =
414
+ CommandWindowState :: new ( self . bookmarks . clone ( ) ) ;
421
415
Task :: done ( Message :: HideOverlay )
422
416
}
423
417
key:: Key :: Named ( key:: Named :: ArrowDown ) => {
@@ -429,6 +423,7 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
429
423
Task :: none ( )
430
424
}
431
425
key:: Key :: Named ( key:: Named :: Backspace ) => {
426
+ self . command_window_state . has_error = false ;
432
427
self . command_window_state . first_item ( ) ;
433
428
if self . command_window_state . query . is_empty ( ) {
434
429
Task :: none ( )
@@ -441,13 +436,15 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
441
436
}
442
437
}
443
438
key:: Key :: Named ( key:: Named :: Space ) => {
439
+ self . command_window_state . has_error = false ;
444
440
self . command_window_state . first_item ( ) ;
445
441
Task :: done ( Message :: CommandPalatteQueryChanged ( format ! (
446
442
"{} " ,
447
443
self . command_window_state. query
448
444
) ) )
449
445
}
450
446
key:: Key :: Character ( char) => {
447
+ self . command_window_state . has_error = false ;
451
448
self . command_window_state . first_item ( ) ;
452
449
Task :: done ( Message :: CommandPalatteQueryChanged ( format ! (
453
450
"{}{}" ,
@@ -465,12 +462,13 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
465
462
ResultType :: Bookmarks ( bookmark) => {
466
463
Message :: GoToUrl ( bookmark. url ( ) . to_string ( ) )
467
464
}
465
+ ResultType :: Url ( url) => {
466
+ Message :: GoToUrl ( url. to_string ( ) )
467
+ }
468
468
} ;
469
469
470
- self . command_window_state . query = String :: new ( ) ;
471
- self . command_window_state . filtered_results =
472
- self . command_window_state . possible_results . clone ( ) ;
473
- self . command_window_state . selected_item = None ;
470
+ self . command_window_state =
471
+ CommandWindowState :: new ( self . bookmarks . clone ( ) ) ;
474
472
475
473
return Task :: batch ( [
476
474
Task :: done ( task) ,
@@ -479,13 +477,9 @@ impl<Engine: BrowserEngine> IcyBrowser<Engine> {
479
477
}
480
478
}
481
479
}
482
- // TODO: maybe make red to show none was selected
483
- self . command_window_state . query = String :: new ( ) ;
484
- self . command_window_state . filtered_results =
485
- self . command_window_state . possible_results . clone ( ) ;
486
- self . command_window_state . selected_item = None ;
487
480
488
- Task :: done ( Message :: HideOverlay )
481
+ self . command_window_state . has_error = true ;
482
+ Task :: none ( )
489
483
}
490
484
491
485
_ => Task :: none ( ) ,
0 commit comments