@@ -393,8 +393,10 @@ export default class ConnectionController {
393
393
this . _connectingConnectionId = connectionId ;
394
394
this . eventEmitter . emit ( DataServiceEventTypes . CONNECTIONS_DID_CHANGE ) ;
395
395
396
- if ( this . _activeDataService ) {
397
- await this . disconnect ( ) ;
396
+ const oldConnectionId = this . _currentConnectionId ;
397
+
398
+ if ( oldConnectionId ) {
399
+ await this . disconnect ( true ) ;
398
400
}
399
401
400
402
this . _statusView . showMessage ( 'Connecting to MongoDB...' ) ;
@@ -433,7 +435,17 @@ export default class ConnectionController {
433
435
}
434
436
435
437
log . info ( 'Successfully connected' ) ;
436
- void vscode . window . showInformationMessage ( 'MongoDB connection successful.' ) ;
438
+
439
+ if ( oldConnectionId ) {
440
+ const currentConnectionName = oldConnectionId
441
+ ? this . getSavedConnectionName ( oldConnectionId )
442
+ : 'previous server' ;
443
+ const nextConnectionName = this . getSavedConnectionName ( connectionId ) ;
444
+
445
+ void vscode . window . showInformationMessage ( `Disconnected from ${ currentConnectionName } and connected to ${ nextConnectionName } .` ) ;
446
+ } else {
447
+ void vscode . window . showInformationMessage ( 'MongoDB connection successful.' ) ;
448
+ }
437
449
438
450
this . _activeDataService = newDataService ;
439
451
this . _currentConnectionId = connectionId ;
@@ -491,7 +503,11 @@ export default class ConnectionController {
491
503
}
492
504
}
493
505
494
- async disconnect ( ) : Promise < boolean > {
506
+ /**
507
+ * @param quiet Don't display non-error notifications to the user.
508
+ * @returns If we disconnected from MongoDB succesfully.
509
+ */
510
+ async disconnect ( quiet = false ) : Promise < boolean > {
495
511
log . info (
496
512
'Disconnect called, currently connected to:' ,
497
513
this . _currentConnectionId
@@ -516,8 +532,11 @@ export default class ConnectionController {
516
532
try {
517
533
// Disconnect from the active connection.
518
534
await this . _activeDataService . disconnect ( ) ;
519
- void vscode . window . showInformationMessage ( 'MongoDB disconnected.' ) ;
520
535
this . _activeDataService = null ;
536
+
537
+ if ( ! quiet ) {
538
+ void vscode . window . showInformationMessage ( 'MongoDB disconnected.' ) ;
539
+ }
521
540
} catch ( error ) {
522
541
// Show an error, however we still reset the active connection to free up the extension.
523
542
void vscode . window . showErrorMessage (
0 commit comments