File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,21 @@ export function activateCodeLens(context: vscode.ExtensionContext) {
1414 // Register the command that the CodeLens will execute
1515 const runRuleCommand = vscode . commands . registerCommand (
1616 'ast-grep.runRule' ,
17- ( text : string ) => {
18- parentPort . postMessage ( 'searchByYAML' , {
19- text,
20- } )
21- vscode . commands . executeCommand ( 'ast-grep.search.input.focus' )
17+ async ( text : string ) => {
18+ await vscode . commands . executeCommand ( 'ast-grep.search.input.focus' )
19+ // if the input box is not ready, retry after a short delay
20+ // since unport is not set up yet
21+ try {
22+ parentPort . postMessage ( 'searchByYAML' , {
23+ text,
24+ } )
25+ } catch ( _e ) {
26+ // wait for input box to show up
27+ await new Promise ( r => setTimeout ( r , 300 ) )
28+ parentPort . postMessage ( 'searchByYAML' , {
29+ text,
30+ } )
31+ }
2232 } ,
2333 )
2434
You can’t perform that action at this time.
0 commit comments