File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import { getLayoutModelForStaticTab } from "@/layout/lib/layoutModelHooks";
2222import * as keyutil from "@/util/keyutil" ;
2323import { fireAndForget } from "@/util/util" ;
2424import * as jotai from "jotai" ;
25+ import { modalsModel } from "./modalmodel" ;
2526
2627const simpleControlShiftAtom = jotai . atom ( false ) ;
2728const globalKeyMap = new Map < string , ( waveEvent : WaveKeyboardEvent ) => boolean > ( ) ;
@@ -384,7 +385,16 @@ function registerGlobalKeys() {
384385 return false ;
385386 }
386387 globalKeyMap . set ( "Cmd:f" , activateSearch ) ;
387- globalKeyMap . set ( "Escape" , deactivateSearch ) ;
388+ globalKeyMap . set ( "Escape" , ( ) => {
389+ if ( modalsModel . hasOpenModals ( ) ) {
390+ modalsModel . popModal ( ) ;
391+ return true ;
392+ }
393+ if ( deactivateSearch ( ) ) {
394+ return true ;
395+ }
396+ return false ;
397+ } ) ;
388398 const allKeys = Array . from ( globalKeyMap . keys ( ) ) ;
389399 // special case keys, handled by web view
390400 allKeys . push ( "Cmd:l" , "Cmd:r" , "Cmd:ArrowRight" , "Cmd:ArrowLeft" ) ;
You can’t perform that action at this time.
0 commit comments