Skip to content

Commit 3106b03

Browse files
authored
Prompt user to enable proposed APIs if server-side folder is open (intersystems-community#1140)
1 parent 1e80283 commit 3106b03

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

docs/SettingsReference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ The extensions in the InterSystems ObjectScript Extension Pack provide many sett
7878
| `"objectscript.serverSourceControl .disableOtherActionTriggers"` | Prevent server-side source control 'other action' triggers from firing. | `boolean` | `false` | |
7979
| `"objectscript.showExplorer"` | Show the ObjectScript Explorer view. | `boolean` | `true` | |
8080
| `"objectscript.showGeneratedFileDecorations"` | Controls whether a badge is shown in the file explorer and open editors view for generated files. | `boolean` | `true` | |
81+
| `"objectscript.showProposedApiPrompt"` | Controls whether a prompt to enable VS Code proposed APIs is shown when a server-side workspace folder is opened. | `boolean` | `true` | |
8182
| `"objectscript.studioActionDebugOutput"` | Log in JSON format the action that VS Code should perform as requested by the server. | `boolean` | `false` | Actions will be logged to the `ObjectScript` Output channel. |
8283
| `"objectscript.suppressCompileErrorMessages"` | Suppress popup messages about errors during compile, but still focus on Output view. | `boolean` | `false` | |
8384
| `"objectscript.suppressCompileMessages"` | Suppress popup messages about successful compile. | `boolean` | `true` | |

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,11 @@
14771477
"description": "Controls whether a badge is shown in the file explorer and open editors view for generated files.",
14781478
"type": "boolean",
14791479
"default": true
1480+
},
1481+
"objectscript.showProposedApiPrompt": {
1482+
"description": "Controls whether a prompt to enable VS Code proposed APIs is shown when a server-side workspace folder is opened.",
1483+
"type": "boolean",
1484+
"default": true
14801485
}
14811486
}
14821487
},

src/extension.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,38 @@ function languageServer(install = true): vscode.Extension<any> {
553553
return extension;
554554
}
555555

556+
/** Show the proposed API prompt if required */
557+
function proposedApiPrompt(active: boolean, added?: readonly vscode.WorkspaceFolder[]): void {
558+
if (
559+
(added || vscode.workspace.workspaceFolders || []).some((e) => filesystemSchemas.includes(e.uri.scheme)) &&
560+
!active &&
561+
config("showProposedApiPrompt")
562+
) {
563+
// Prompt the user with the proposed api install instructions
564+
vscode.window
565+
.showInformationMessage(
566+
"[Searching across](https://code.visualstudio.com/docs/editor/codebasics#_search-across-files) and [quick opening](https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_quick-open) server-side files requires [VS Code proposed APIs](https://code.visualstudio.com/api/advanced-topics/using-proposed-api). Show the instructions?",
567+
"Yes",
568+
"Later",
569+
"Never"
570+
)
571+
.then(async (action) => {
572+
switch (action) {
573+
case "Yes":
574+
vscode.env.openExternal(
575+
vscode.Uri.parse("https://github.com/intersystems-community/vscode-objectscript#enable-proposed-apis")
576+
);
577+
break;
578+
case "Never":
579+
config().update("showProposedApiPrompt", false, vscode.ConfigurationTarget.Global);
580+
break;
581+
case "Later":
582+
default:
583+
}
584+
});
585+
}
586+
}
587+
556588
// The URIs of all classes that have been opened. Used when objectscript.openClassContracted is true.
557589
let openedClasses: string[];
558590

@@ -744,6 +776,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
744776
// Create this here so we can fire its event
745777
const fileDecorationProvider = new FileDecorationProvider();
746778

779+
// Show the proposed API prompt if required
780+
proposedApiPrompt(proposed.length > 0);
781+
747782
context.subscriptions.push(
748783
reporter,
749784
panel,
@@ -1270,6 +1305,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
12701305
}),
12711306
vscode.commands.registerCommand("vscode-objectscript.modifyWsFolder", modifyWsFolder),
12721307
vscode.commands.registerCommand("vscode-objectscript.openErrorLocation", openErrorLocation),
1308+
vscode.workspace.onDidChangeWorkspaceFolders((e) => {
1309+
// Show the proposed API prompt if required
1310+
proposedApiPrompt(proposed.length > 0, e.added);
1311+
}),
12731312

12741313
/* Anything we use from the VS Code proposed API */
12751314
...proposed

0 commit comments

Comments
 (0)