@@ -9,7 +9,6 @@ import { getOrAskForProgram } from './debugConfigProvider';
9
9
import { adaExtState , mainOutputChannel } from './extension' ;
10
10
import { getProjectFileRelPath } from './helpers' ;
11
11
import { CustomTaskDefinition , getEnclosingSymbol } from './taskProviders' ;
12
- import { LanguageClient } from 'vscode-languageclient/node' ;
13
12
14
13
export function registerCommands ( context : vscode . ExtensionContext , clients : ExtensionState ) {
15
14
context . subscriptions . push ( vscode . commands . registerCommand ( 'ada.otherFile' , otherFileHandler ) ) ;
@@ -52,15 +51,11 @@ export function registerCommands(context: vscode.ExtensionContext, clients: Exte
52
51
'ada.addMissingDirsToWorkspace' ,
53
52
async (
54
53
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
55
- displayPopupWhenMissing : boolean = false ,
54
+ atStartup : boolean = false ,
56
55
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
57
- displayPopupOnSuccess : boolean = true
56
+ displayYesNoPopup : boolean = true
58
57
) => {
59
- await checkSrcDirectories (
60
- clients . adaClient ,
61
- displayPopupWhenMissing ,
62
- displayPopupOnSuccess
63
- ) ;
58
+ await checkSrcDirectories ( atStartup , displayYesNoPopup ) ;
64
59
}
65
60
)
66
61
) ;
@@ -362,26 +357,27 @@ const otherFileHandler = () => {
362
357
* Do nothing if the user did not setup any workspace file.
363
358
*
364
359
* @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
366
363
* 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
369
364
*/
370
- export async function checkSrcDirectories (
371
- alsClient : LanguageClient ,
372
- displayPopupWhenMissing = true ,
373
- displayPopupOnSuccess = true
374
- ) {
365
+ export async function checkSrcDirectories ( atStartup = false , displayYesNoPopup = true ) {
375
366
type ALSSourceDirDescription = {
376
367
name : string ;
377
368
uri : string ;
378
369
} ;
379
370
380
371
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 ) ;
381
375
382
376
// 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 ) ) {
385
381
const sourceDirs : ALSSourceDirDescription [ ] = ( await alsClient . sendRequest (
386
382
ExecuteCommandRequest . type ,
387
383
{
@@ -429,17 +425,30 @@ export async function checkSrcDirectories(
429
425
if ( workspaceDirsToAdd . length > 0 ) {
430
426
let doAdd = true ;
431
427
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
+
433
436
await vscode . window
434
437
. showInformationMessage (
435
438
'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
439
441
)
440
442
. then ( ( answer ) => {
441
443
if ( answer !== 'Yes' ) {
442
444
doAdd = false ;
445
+
446
+ if ( answer === "Don't Show Again" ) {
447
+ void adaExtState . context . workspaceState . update (
448
+ doNotShowAgainKey ,
449
+ true
450
+ ) ;
451
+ }
443
452
}
444
453
} ) ;
445
454
}
@@ -453,7 +462,7 @@ export async function checkSrcDirectories(
453
462
...workspaceDirsToAdd
454
463
) ;
455
464
}
456
- } else if ( displayPopupOnSuccess ) {
465
+ } else if ( ! atStartup ) {
457
466
void vscode . window . showInformationMessage (
458
467
"All the project's source directories are already \
459
468
available in the current workspace."
0 commit comments