@@ -8,12 +8,12 @@ import { Code } from './code';
88
99export class QuickOpen {
1010
11- static QUICK_OPEN = 'div.monaco- quick-open -widget' ;
12- static QUICK_OPEN_HIDDEN = 'div.monaco- quick-open-widget[aria-hidden="true"]' ;
13- static QUICK_OPEN_INPUT = `${ QuickOpen . QUICK_OPEN } .quick-open- input input ` ;
14- static QUICK_OPEN_FOCUSED_ELEMENT = `${ QuickOpen . QUICK_OPEN } .quick-open-tree .monaco-tree-row .focused .monaco-highlighted-label` ;
15- static QUICK_OPEN_ENTRY_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry' ;
16- static QUICK_OPEN_ENTRY_LABEL_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry . label-name' ;
11+ static QUICK_OPEN = '. quick-input -widget' ;
12+ static QUICK_OPEN_INPUT = ` ${ QuickOpen . QUICK_OPEN } . quick-input-box input` ;
13+ static QUICK_OPEN_ROW = `${ QuickOpen . QUICK_OPEN } .quick-input-list .monaco-list-row ` ;
14+ static QUICK_OPEN_FOCUSED_ELEMENT = `${ QuickOpen . QUICK_OPEN_ROW } .focused .monaco-highlighted-label` ;
15+ static QUICK_OPEN_ENTRY_LABEL = ` ${ QuickOpen . QUICK_OPEN_ROW } .label-name` ;
16+ static QUICK_OPEN_ENTRY_LABEL_SPAN = ` ${ QuickOpen . QUICK_OPEN_ROW } .monaco-highlighted- label span` ;
1717
1818 constructor ( private code : Code , private editors : Editors ) { }
1919
@@ -64,7 +64,7 @@ export class QuickOpen {
6464 }
6565
6666 private async waitForQuickOpenClosed ( ) : Promise < void > {
67- await this . code . waitForElement ( QuickOpen . QUICK_OPEN_HIDDEN ) ;
67+ await this . code . waitForElement ( QuickOpen . QUICK_OPEN , r => ! ! r && r . attributes . style . indexOf ( 'display: none;' ) !== - 1 ) ;
6868 }
6969
7070 async submit ( text : string ) : Promise < void > {
@@ -74,26 +74,30 @@ export class QuickOpen {
7474 }
7575
7676 async selectQuickOpenElement ( index : number ) : Promise < void > {
77- await this . waitForQuickOpenOpened ( ) ;
78- for ( let from = 0 ; from < index ; from ++ ) {
79- await this . code . dispatchKeybinding ( 'down' ) ;
80- }
77+ this . activateQuickOpenElement ( index ) ;
8178 await this . code . dispatchKeybinding ( 'enter' ) ;
8279 await this . waitForQuickOpenClosed ( ) ;
8380 }
8481
8582 async waitForQuickOpenElements ( accept : ( names : string [ ] ) => boolean ) : Promise < void > {
86- await this . code . waitForElements ( QuickOpen . QUICK_OPEN_ENTRY_LABEL_SELECTOR , false , els => accept ( els . map ( e => e . textContent ) ) ) ;
83+ await this . code . waitForElements ( QuickOpen . QUICK_OPEN_ENTRY_LABEL , false , els => accept ( els . map ( e => e . textContent ) ) ) ;
8784 }
8885
89- async runCommand ( command : string ) : Promise < void > {
90- await this . openQuickOpen ( `> ${ command } ` ) ;
86+ async runCommand ( commandId : string ) : Promise < void > {
87+ await this . openQuickOpen ( `>${ commandId } ` ) ;
9188
9289 // wait for best choice to be focused
93- await this . code . waitForTextContent ( QuickOpen . QUICK_OPEN_FOCUSED_ELEMENT , command ) ;
90+ await this . code . waitForTextContent ( QuickOpen . QUICK_OPEN_FOCUSED_ELEMENT ) ;
9491
9592 // wait and click on best choice
96- await this . code . waitAndClick ( QuickOpen . QUICK_OPEN_FOCUSED_ELEMENT ) ;
93+ await this . selectQuickOpenElement ( 0 ) ;
94+ }
95+
96+ async activateQuickOpenElement ( index : number ) : Promise < void > {
97+ await this . waitForQuickOpenOpened ( ) ;
98+ for ( let from = 0 ; from < index ; from ++ ) {
99+ await this . code . dispatchKeybinding ( 'down' ) ;
100+ }
97101 }
98102
99103 async openQuickOutline ( ) : Promise < void > {
@@ -106,7 +110,7 @@ export class QuickOpen {
106110 await this . code . dispatchKeybinding ( 'ctrl+shift+o' ) ;
107111 }
108112
109- const text = await this . code . waitForTextContent ( 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties div.monaco-tree-row .quick-open-entry .monaco-icon-label .label-name .monaco-highlighted-label span' ) ;
113+ const text = await this . code . waitForTextContent ( QuickOpen . QUICK_OPEN_ENTRY_LABEL_SPAN ) ;
110114
111115 if ( text !== 'No symbol information for the file' ) {
112116 return ;
0 commit comments