@@ -7,21 +7,30 @@ export function getServerNames(scope?: vscode.ConfigurationScope): ServerName[]
77 const servers = vscode . workspace . getConfiguration ( 'intersystems' , scope ) . get ( 'servers' ) ;
88
99 if ( typeof servers === 'object' && servers ) {
10- const myDefault : string = vscode . workspace . getConfiguration ( 'intersystems.servers' , scope ) . inspect ( '/default' ) ?. defaultValue ? '' : servers [ '/default' ] || '' ;
10+
11+ // Helper function to return true iff inspected setting is not explicitly set at any level
12+ const notSet = ( inspected ) :boolean => {
13+ return ! inspected ?. globalLanguageValue && ! inspected ?. globalValue && ! inspected ?. workspaceFolderLanguageValue && ! inspected ?. workspaceFolderValue && ! inspected ?. workspaceLanguageValue && ! inspected ?. workspaceValue ;
14+ }
15+
16+ // If a valid default has been explicitly nominated, add it first
17+ const inspectedDefault = vscode . workspace . getConfiguration ( 'intersystems.servers' , scope ) . inspect ( '/default' ) ;
18+ const myDefault : string = notSet ( inspectedDefault ) ? '' : servers [ '/default' ] || '' ;
1119 if ( myDefault . length > 0 && servers [ myDefault ] ) {
1220 names . push ( {
1321 name : myDefault ,
1422 description : `${ servers [ myDefault ] . description || '' } (default)` ,
1523 detail : serverDetail ( servers [ myDefault ] )
1624 } ) ;
1725 }
26+
27+ // Process the rest
1828 for ( const key in servers ) {
1929 if ( ! key . startsWith ( '/' ) && key !== myDefault ) {
2030 const inspected = vscode . workspace . getConfiguration ( 'intersystems.servers' , scope ) . inspect ( key ) ;
2131
22- // At least in VS Code 1.49 the defaultValue unexpectedly returns undefined
23- // even for keys that are defined in package.json as defaults. So we have to check negatively all the other possibilities.
24- if ( ! inspected ?. globalLanguageValue && ! inspected ?. globalValue && ! inspected ?. workspaceFolderLanguageValue && ! inspected ?. workspaceFolderValue && ! inspected ?. workspaceLanguageValue && ! inspected ?. workspaceValue ) {
32+ // Collect embedded (default~*) servers separately
33+ if ( notSet ( inspected ) ) {
2534 defaultNames . push ( {
2635 name : key ,
2736 description : servers [ key ] . description || '' ,
@@ -37,7 +46,11 @@ export function getServerNames(scope?: vscode.ConfigurationScope): ServerName[]
3746 }
3847 }
3948 }
40- names . push ( ...defaultNames ) ;
49+
50+ // Append the embedded servers unless suppressed
51+ if ( ! vscode . workspace . getConfiguration ( 'intersystems.servers' , scope ) . get ( '/hideEmbeddedEntries' ) ) {
52+ names . push ( ...defaultNames ) ;
53+ }
4154 return names ;
4255}
4356
0 commit comments