Skip to content

Commit 4138750

Browse files
authored
Enable #cpp for all users (#12898)
* Enable #cpp for all users * Address PR comments
1 parent 8cb1def commit 4138750

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Extension/src/Debugger/configurationProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
331331

332332
// Run deploy steps
333333
if (config.deploySteps && config.deploySteps.length !== 0) {
334-
const codeVersion: number[] = vscode.version.split('.').map(num => parseInt(num, undefined));
334+
const codeVersion: number[] = util.getVsCodeVersion();
335335
if ((util.isNumber(codeVersion[0]) && codeVersion[0] < 1) || (util.isNumber(codeVersion[0]) && codeVersion[0] === 1 && util.isNumber(codeVersion[1]) && codeVersion[1] < 69)) {
336336
void logger.getOutputChannelLogger().showErrorMessage(localize("vs.code.1.69+.required", "'deploySteps' require VS Code 1.69+."));
337337
return undefined;

Extension/src/LanguageServer/extension.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,15 @@ export async function activate(): Promise<void> {
252252
activeDocument = activeEditor.document;
253253
}
254254

255-
if (util.extensionContext && new CppSettings().experimentalFeatures) {
256-
const tool = vscode.lm.registerTool('cpptools-lmtool-configuration', new CppConfigurationLanguageModelTool());
257-
disposables.push(tool);
255+
if (util.extensionContext) {
256+
// lmTools wasn't stabilized until 1.95, but (as of October 2024)
257+
// cpptools can be installed on older versions of VS Code. See
258+
// https://github.com/microsoft/vscode-cpptools/blob/main/Extension/package.json#L14
259+
const version = util.getVsCodeVersion();
260+
if (version[0] > 1 || (version[0] === 1 && version[1] >= 95)) {
261+
const tool = vscode.lm.registerTool('cpptools-lmtool-configuration', new CppConfigurationLanguageModelTool());
262+
disposables.push(tool);
263+
}
258264
}
259265

260266
await registerRelatedFilesProvider();

Extension/src/common.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,3 +1814,7 @@ export function findExePathInArgs(args: CommandString[]): string | undefined {
18141814

18151815
return undefined;
18161816
}
1817+
1818+
export function getVsCodeVersion(): number[] {
1819+
return vscode.version.split('.').map(num => parseInt(num, undefined));
1820+
}

0 commit comments

Comments
 (0)