File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -498,12 +498,21 @@ async function activateWithInstalledDistribution(
498498 ) : Promise < void > {
499499 const path = selectedQuery ? selectedQuery . path : window . activeTextEditor ! . document . uri . fsPath ;
500500 if ( path ) {
501+ // Get path of temporary 'qh-markdown' directory in extension context
501502 const tempDirPath = `${ getContextStoragePath ( ctx ) } /qh-markdown/` ;
503+ // Get library name and query file name in the format 'libname/queryname.md
502504 const mdFilePath = path . split ( '/' ) . slice ( - 2 ) . join ( '/' ) . replace ( '.qhelp' , '.md' ) ;
503- const absolutePath = `${ tempDirPath } ${ mdFilePath } ` ;
504- const uri = Uri . file ( absolutePath ) ;
505- await cliServer . generateQueryHelp ( path , 'markdown' , absolutePath ) ;
506- await commands . executeCommand ( 'markdown.showPreviewToSide' , uri ) ;
505+ const absolutePathToMd = `${ tempDirPath } ${ mdFilePath } ` ;
506+ const uri = Uri . file ( absolutePathToMd ) ;
507+ try {
508+ await cliServer . generateQueryHelp ( path , 'markdown' , absolutePathToMd ) ;
509+ await commands . executeCommand ( 'markdown.showPreviewToSide' , uri ) ;
510+ } catch ( err ) {
511+ const errorMessage = err . message . includes ( 'Generating qlhelp in markdown' ) ? (
512+ `Could not generate markdown from ${ path } : Bad formatting in .qhelp file.`
513+ ) : `Could not open a preview of the generated file (${ absolutePathToMd } ).` ;
514+ void helpers . showAndLogErrorMessage ( errorMessage ) ;
515+ }
507516 }
508517 }
509518
You can’t perform that action at this time.
0 commit comments