Skip to content

Commit 02591a3

Browse files
Merge pull request #65 from gjsjohnmurray/fix-64
fix #64 Add '/hideEmbeddedEntries' boolean to 'intersystems.servers' Also fixes '/default'
2 parents 08e5ed6 + bd195a2 commit 02591a3

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@
175175
"properties": {
176176
"/default": {
177177
"type": "string",
178-
"description": "Name of the default server."
178+
"description": "Name of the server to promote to the top of pick lists."
179+
},
180+
"/hideEmbeddedEntries": {
181+
"type": "boolean",
182+
"description": "Do not append the built-in 'default~*' server definitions to pick lists."
179183
}
180184
},
181185
"additionalProperties": false

src/api/getServerNames.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)