File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
client/modules/IDE/components Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 2424
2525 // This is the old interface, kept around for now to stay
2626 // backwards-compatible.
27+
28+ //event listener to enable escape key functionality
29+ function addEscapeKeyListener ( cm ) {
30+ const escapeHandler = ( event ) => {
31+ if ( event . key === 'Escape' && cm . state . completionActive ) {
32+ cm . closeHint ( ) ; // Close the hint
33+ cm . focus ( ) ; // Ensure the editor regains focus
34+ document . removeEventListener ( 'keydown' , escapeHandler ) ; // Clean up listener
35+ }
36+ } ;
37+
38+ // Add the event listener when hints are active
39+ document . addEventListener ( 'keydown' , escapeHandler ) ;
40+ }
41+
2742 CodeMirror . showHint = function ( cm , getHints , options ) {
2843 if ( ! getHints ) return cm . showHint ( options ) ;
2944 if ( options && options . async ) getHints . async = true ;
5570
5671 CodeMirror . signal ( this , 'startCompletion' , this ) ;
5772 completion . update ( true ) ;
73+ // Add Escape key listener
74+ addEscapeKeyListener ( this ) ;
5875 } ) ;
5976
6077 CodeMirror . defineExtension ( 'closeHint' , function ( ) {
You can’t perform that action at this time.
0 commit comments