Skip to content

Commit 478ab22

Browse files
authored
Adopt new VS Code APIs to improve QuickPicks (#1709)
1 parent 388600e commit 478ab22

File tree

8 files changed

+88
-175
lines changed

8 files changed

+88
-175
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
}
4949
],
5050
"engines": {
51-
"vscode": "^1.104.0"
51+
"vscode": "^1.109.0"
5252
},
5353
"enabledApiProposals": [
5454
"fileSearchProvider",
@@ -1775,7 +1775,7 @@
17751775
"test": "node ./out/test/runTest.js",
17761776
"lint": "eslint src/**",
17771777
"lint-fix": "eslint --fix src/**",
1778-
"download-api": "dts dev 1.104.0",
1778+
"download-api": "dts dev 1.109.0",
17791779
"postinstall": "npm run download-api"
17801780
},
17811781
"devDependencies": {
@@ -1786,7 +1786,7 @@
17861786
"@types/mocha": "^7.0.2",
17871787
"@types/node": "22.13.14",
17881788
"@types/semver": "7.5.4",
1789-
"@types/vscode": "1.104.0",
1789+
"@types/vscode": "1.109.0",
17901790
"@types/ws": "8.18.0",
17911791
"@types/xmldom": "^0.1.34",
17921792
"@typescript-eslint/eslint-plugin": "^8.15.0",

src/commands/export.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export async function exportAll(): Promise<any> {
239239
files = await vscode.window.showQuickPick(files, {
240240
canPickMany: true,
241241
ignoreFocusOut: true,
242-
placeHolder: "Uncheck a file to exclude it. Press 'Escape' to cancel export.",
242+
prompt: "Uncheck a file to exclude it. Press 'Escape' to cancel export.",
243243
title: "Files to Export",
244244
});
245245
if (files === undefined) {
@@ -355,7 +355,7 @@ export async function exportDocumentsToXMLFile(): Promise<void> {
355355
const confirmed = await new Promise<boolean>((resolve) => {
356356
const quickPick = vscode.window.createQuickPick();
357357
quickPick.title = `Export the following ${documents.length > 1 ? `${documents.length} documents` : "document"}?`;
358-
quickPick.placeholder = "Click any item to confirm, or 'Escape' to cancel";
358+
quickPick.prompt = "Click any item to confirm, or 'Escape' to cancel";
359359
quickPick.ignoreFocusOut = true;
360360
quickPick.onDidAccept(() => {
361361
resolve(true);

src/commands/project.ts

Lines changed: 29 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,24 @@ async function pickAdditions(
427427
return new Promise<string[]>((resolve) => {
428428
let result: string[] = [];
429429
const quickPick = vscode.window.createQuickPick<PickAdditionsItem>();
430-
quickPick.title = `Select items in namespace '${api.ns.toUpperCase()}' to add to project '${project}'.`;
430+
quickPick.title = `Select items in namespace '${api.ns}' to add to project '${project}'.`;
431431
quickPick.ignoreFocusOut = true;
432432
quickPick.canSelectMany = true;
433433
quickPick.keepScrollPosition = true;
434434
quickPick.matchOnDescription = true;
435435
quickPick.buttons = [
436-
{ iconPath: new vscode.ThemeIcon("library"), tooltip: "Show system items" },
437-
{ iconPath: new vscode.ThemeIcon("server-process"), tooltip: "Show generated items" },
436+
{
437+
iconPath: new vscode.ThemeIcon("library"),
438+
tooltip: "System",
439+
location: vscode.QuickInputButtonLocation.Input,
440+
toggle: { checked: false },
441+
},
442+
{
443+
iconPath: new vscode.ThemeIcon("server-process"),
444+
tooltip: "Generated",
445+
location: vscode.QuickInputButtonLocation.Input,
446+
toggle: { checked: false },
447+
},
438448
];
439449

440450
const getCSPRootItems = (): Promise<PickAdditionsItem[]> => {
@@ -548,67 +558,26 @@ async function pickAdditions(
548558
});
549559
quickPick.onDidTriggerButton((button) => {
550560
quickPick.busy = true;
551-
if (button.tooltip.charAt(0) == "S") {
552-
if (button.tooltip.includes("system")) {
553-
// Update the button
554-
quickPick.buttons = [
555-
{ iconPath: new vscode.ThemeIcon("library"), tooltip: "Hide system items" },
556-
quickPick.buttons[1],
557-
];
558-
// Change value of correct parameter in array
559-
sys = "1";
560-
if (["RTN", "INC", "OTH"].includes(category)) {
561-
parameters[0] = sys;
562-
} else if (category != undefined) {
563-
parameters[1] = sys;
564-
} else {
565-
parameters[0] = sys;
566-
parameters[4] = sys;
567-
}
561+
// Change value of correct parameter in array
562+
if (button.tooltip == "System") {
563+
sys = button.toggle.checked ? "1" : "0";
564+
if (["RTN", "INC", "OTH"].includes(category)) {
565+
parameters[0] = sys;
566+
} else if (category != undefined) {
567+
parameters[1] = sys;
568568
} else {
569-
quickPick.buttons = [
570-
quickPick.buttons[0],
571-
{ iconPath: new vscode.ThemeIcon("server-process"), tooltip: "Hide generated items" },
572-
];
573-
gen = "1";
574-
if (["RTN", "INC", "OTH"].includes(category)) {
575-
parameters[1] = gen;
576-
} else if (category != undefined) {
577-
parameters[2] = gen;
578-
} else {
579-
parameters[1] = gen;
580-
parameters[5] = gen;
581-
}
569+
parameters[0] = sys;
570+
parameters[4] = sys;
582571
}
583572
} else {
584-
if (button.tooltip.includes("system")) {
585-
quickPick.buttons = [
586-
{ iconPath: new vscode.ThemeIcon("library"), tooltip: "Show system items" },
587-
quickPick.buttons[1],
588-
];
589-
sys = "0";
590-
if (["RTN", "INC", "OTH"].includes(category)) {
591-
parameters[0] = sys;
592-
} else if (category != undefined) {
593-
parameters[1] = sys;
594-
} else {
595-
parameters[0] = sys;
596-
parameters[4] = sys;
597-
}
573+
gen = button.toggle.checked ? "1" : "0";
574+
if (["RTN", "INC", "OTH"].includes(category)) {
575+
parameters[1] = gen;
576+
} else if (category != undefined) {
577+
parameters[2] = gen;
598578
} else {
599-
quickPick.buttons = [
600-
quickPick.buttons[0],
601-
{ iconPath: new vscode.ThemeIcon("server-process"), tooltip: "Show generated items" },
602-
];
603-
gen = "0";
604-
if (["RTN", "INC", "OTH"].includes(category)) {
605-
parameters[1] = gen;
606-
} else if (category != undefined) {
607-
parameters[2] = gen;
608-
} else {
609-
parameters[1] = gen;
610-
parameters[5] = gen;
611-
}
579+
parameters[1] = gen;
580+
parameters[5] = gen;
612581
}
613582
}
614583
// Refresh the items list

src/commands/showAllClassMembers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ SELECT Name, Origin, 'x' AS MemberType, Parent, Internal, 0 AS NotInheritable, M
125125
}),
126126
{
127127
title: `All members of ${cls}`,
128-
placeHolder: "Pick a member to show it in the editor",
128+
prompt: "Pick a member to show it in the editor",
129129
}
130130
);
131131
if (!member) return;

src/commands/unitTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ async function runHandler(
405405
{
406406
matchOnDetail: true,
407407
title: `Cannot ${action} tests from multiple roots at once`,
408-
placeHolder: `Pick a root to ${action} tests from`,
408+
prompt: `Pick a root to ${action} tests from`,
409409
}
410410
);
411411
if (picked) {

src/commands/xmlToUdl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export async function extractXMLFileContents(xmlUri?: vscode.Uri): Promise<void>
157157
canPickMany: true,
158158
ignoreFocusOut: true,
159159
title: "Pick the documents to extract",
160-
placeHolder: "Files are created using your 'objectscript.export' settings",
160+
prompt: "Files are created using your 'objectscript.export' settings",
161161
}
162162
);
163163
if (docsToExtract == undefined || docsToExtract.length == 0) {

0 commit comments

Comments
 (0)