@@ -9,7 +9,6 @@ import { getOrAskForProgram } from './debugConfigProvider';
99import { adaExtState , mainOutputChannel } from './extension' ;
1010import { getProjectFileRelPath } from './helpers' ;
1111import { CustomTaskDefinition , getEnclosingSymbol } from './taskProviders' ;
12- import { LanguageClient } from 'vscode-languageclient/node' ;
1312
1413export function registerCommands ( context : vscode . ExtensionContext , clients : ExtensionState ) {
1514 context . subscriptions . push ( vscode . commands . registerCommand ( 'ada.otherFile' , otherFileHandler ) ) ;
@@ -52,15 +51,11 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
5251 'ada.addMissingDirsToWorkspace' ,
5352 async (
5453 // eslint-disable-next-line @typescript-eslint/no-inferrable-types
55- displayPopupWhenMissing : boolean = false ,
54+ atStartup : boolean = false ,
5655 // eslint-disable-next-line @typescript-eslint/no-inferrable-types
57- displayPopupOnSuccess : boolean = true
56+ displayYesNoPopup : boolean = true
5857 ) => {
59- await checkSrcDirectories (
60- clients . adaClient ,
61- displayPopupWhenMissing ,
62- displayPopupOnSuccess
63- ) ;
58+ await checkSrcDirectories ( atStartup , displayYesNoPopup ) ;
6459 }
6560 )
6661 ) ;
@@ -362,26 +357,27 @@ const otherFileHandler = () => {
362357 * Do nothing if the user did not setup any workspace file.
363358 *
364359 * @param alsClient - the running ALS client
365- * @param displayPopupWhenMissing - whether or not we should display a yes/no popup
360+ * @param atStartup - whether or not the command is triggered when activating the extension
361+ * or explicitly by the user later via the Command Palette
362+ * @param displayYesNoPopup - whether or not we should display a yes/no popup
366363 * when missing directories
367- * @param displayPopupOnSuccess - whether or not we should display a popup to notify
368- * the user that there is no missing directory
369364 */
370- export async function checkSrcDirectories (
371- alsClient : LanguageClient ,
372- displayPopupWhenMissing = true ,
373- displayPopupOnSuccess = true
374- ) {
365+ export async function checkSrcDirectories ( atStartup = false , displayYesNoPopup = true ) {
375366 type ALSSourceDirDescription = {
376367 name : string ;
377368 uri : string ;
378369 } ;
379370
380371 const foldersInSettings = vscode . workspace . getConfiguration ( ) . get ( 'folders' ) ;
372+ const alsClient = adaExtState . adaClient ;
373+ const doNotShowAgainKey = 'ada.addMissingDirsToWorkspace.doNotShowAgain' ;
374+ const doNotShowAgain = adaExtState . context . workspaceState . get ( doNotShowAgainKey ) ;
381375
382376 // Don't propose any popup if we multi-root workspace folders are already set
383- // explicitly in the workspace's settings.
384- if ( foldersInSettings === undefined ) {
377+ // explicitly in the workspace's settings, or if the command has been
378+ // triggered at startup while the user previously clicked on the
379+ // 'Don't show again' button for this workspace
380+ if ( foldersInSettings === undefined && ! ( atStartup && doNotShowAgain ) ) {
385381 const sourceDirs : ALSSourceDirDescription [ ] = ( await alsClient . sendRequest (
386382 ExecuteCommandRequest . type ,
387383 {
@@ -429,17 +425,30 @@ export async function checkSrcDirectories(
429425 if ( workspaceDirsToAdd . length > 0 ) {
430426 let doAdd = true ;
431427
432- if ( displayPopupWhenMissing ) {
428+ if ( displayYesNoPopup ) {
429+ const buttons : ( 'Yes' | 'No' | "Don't Show Again" ) [ ] = [ 'Yes' , 'No' ] ;
430+
431+ // Show the 'Don't Show Again' button only at startup
432+ if ( atStartup ) {
433+ buttons . push ( "Don't Show Again" ) ;
434+ }
435+
433436 await vscode . window
434437 . showInformationMessage (
435438 'Some project source directories are not \
436- listed in your workspace: do you want to add them?' ,
437- 'Yes' ,
438- 'No'
439+ listed in your workspace: do you want to add them?' ,
440+ ...buttons
439441 )
440442 . then ( ( answer ) => {
441443 if ( answer !== 'Yes' ) {
442444 doAdd = false ;
445+
446+ if ( answer === "Don't Show Again" ) {
447+ void adaExtState . context . workspaceState . update (
448+ doNotShowAgainKey ,
449+ true
450+ ) ;
451+ }
443452 }
444453 } ) ;
445454 }
@@ -453,7 +462,7 @@ export async function checkSrcDirectories(
453462 ...workspaceDirsToAdd
454463 ) ;
455464 }
456- } else if ( displayPopupOnSuccess ) {
465+ } else if ( ! atStartup ) {
457466 void vscode . window . showInformationMessage (
458467 "All the project's source directories are already \
459468 available in the current workspace."
0 commit comments