@@ -588,6 +588,45 @@ export async function promptToInstallRPackage(name: string, section: string, cwd
588588 } ) ;
589589}
590590
591+ /**
592+ * Prompt to install the bundled "sess" package
593+ */
594+ export async function promptToInstallSessPackage ( cwd ?: string | vscode . Uri ) : Promise < void > {
595+ const _config = config ( ) ;
596+ const sessionWatcher = _config . get < boolean > ( 'sessionWatcher' ) ;
597+ if ( ! sessionWatcher ) {
598+ return ;
599+ }
600+ const sessVersion = await getRPackageVersion ( 'sess' , cwd instanceof vscode . Uri ? cwd . fsPath : cwd ) ;
601+ if ( sessVersion ) {
602+ return ;
603+ }
604+
605+ const sessPath = extensionContext . asAbsolutePath ( 'sess' ) . replace ( / \\ / g, '/' ) ;
606+ const installSessScript = extensionContext . asAbsolutePath ( path . join ( 'R' , 'install_sess.R' ) ) . replace ( / \\ / g, '/' ) ;
607+ const installMsg = 'R package "sess" (shipped with vscode-R) is required for the session watcher to work. Do you want to install it?' ;
608+ await vscode . window . showErrorMessage ( installMsg , 'Yes' , 'No' )
609+ . then ( async function ( select ) {
610+ if ( select === 'Yes' ) {
611+ const rPath = await getRpath ( ) ;
612+ if ( ! rPath ) {
613+ void vscode . window . showErrorMessage ( 'R path not set' , 'OK' ) ;
614+ return ;
615+ }
616+ const repo = await getCranUrl ( '' , cwd instanceof vscode . Uri ? cwd . fsPath : cwd ) ;
617+ const args = [
618+ '--silent' ,
619+ '--no-echo' ,
620+ '--no-save' ,
621+ '--no-restore' ,
622+ '-f' , installSessScript ,
623+ '--args' , sessPath , repo
624+ ] ;
625+ void executeAsTask ( 'Install "sess" package' , rPath , args , true ) ;
626+ }
627+ } ) ;
628+ }
629+
591630/**
592631 * Create temporary directory. Will avoid name clashes. Caller must delete directory after use.
593632 *
0 commit comments