Skip to content

Commit da17254

Browse files
Jim Griesmerbobbrow
authored andcommitted
Provide user hint through IntelliSense fallback msg that vcpkg is installed and is being used. (#1910)
1 parent 3ddc229 commit da17254

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

Extension/cpp_snippets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"classi": {
99
"prefix": "classi",
10-
"body": "\nclass ${1:${TM_FILENAME_BASE}}\n{\nprivate:\n\t${2:/* data */}\npublic:\n\t${1}::${1}(${3:/* args */}) { $0 }\n\t${1}::~${1}() { }\n};",
10+
"body": "\nclass ${1:${TM_FILENAME_BASE}}\n{\nprivate:\n\t${2:/* data */}\npublic:\n\t${1}(${3:/* args */}) { $0}\n\t~${1}() { }\n};",
1111
"description": "Code snippet for class with inlined constructor/destructor",
1212
"scope": "source.c++, source.objc++"
1313
},

Extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@
13061306
"vscode-debugadapter": "~1.24.0",
13071307
"vscode-debugprotocol": "~1.24.0",
13081308
"vscode-extension-telemetry": "~0.0.11",
1309-
"vscode-languageclient": "~3.4.5",
1309+
"vscode-languageclient": "3.5.1",
13101310
"yauzl": "~2.8.0"
13111311
},
13121312
"runtimeDependencies": [

Extension/src/LanguageServer/client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,10 @@ class DefaultClient implements Client {
686686
if (showIntelliSenseFallbackMessage.Value) {
687687
let learnMorePanel: string = "Learn More";
688688
let dontShowAgain: string = "Don't Show Again";
689-
vscode.window.showInformationMessage("Configure includePath for better IntelliSense results.", learnMorePanel, dontShowAgain).then((value) => {
689+
let fallbackMsg: string = this.configuration.VcpkgInstalled ?
690+
"Update your IntelliSense settings or use Vcpkg to install libraries to help find missing headers." :
691+
"Configure your IntelliSense settings to help find missing headers.";
692+
vscode.window.showInformationMessage(fallbackMsg, learnMorePanel, dontShowAgain).then((value) => {
690693
switch (value) {
691694
case learnMorePanel:
692695
let uri: vscode.Uri = vscode.Uri.parse(`https://go.microsoft.com/fwlink/?linkid=864631`);

Extension/src/LanguageServer/configurations.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ export class CppProperties {
156156
this.handleConfigurationChange();
157157
}
158158

159+
public get VcpkgInstalled(): boolean {
160+
return this.vcpkgIncludes.length > 0;
161+
}
162+
159163
private onConfigurationsChanged(): void {
160164
this.configurationsChanged.fire(this.Configurations);
161165
}
@@ -234,28 +238,29 @@ export class CppProperties {
234238
// Check for vcpkg instance and include relevent paths if found.
235239
if (await util.checkFileExists(util.getVcpkgPathDescriptorFile())) {
236240
let vcpkgRoot: string = await util.readFileText(util.getVcpkgPathDescriptorFile());
237-
let vcpkgInstallPath: string = path.join(vcpkgRoot.trim(), "/installed");
238-
if (await util.checkDirectoryExists(vcpkgInstallPath)) {
239-
let list: string[] = await util.readDir(vcpkgInstallPath);
240-
// For every *directory* in the list (non-recursive)
241-
list.forEach((entry) => {
242-
if (entry !== "vcpkg") {
243-
let pathToCheck: string = path.join(vcpkgInstallPath, entry);
244-
if (fs.existsSync(pathToCheck)) {
245-
let p: string = path.join(pathToCheck, "include");
246-
if (fs.existsSync(p)) {
247-
this.vcpkgIncludes.push(p);
241+
if (await util.checkDirectoryExists(vcpkgRoot)) {
242+
let vcpkgInstalledPath: string = path.join(vcpkgRoot.trim(), "/installed");
243+
let list: string[] = await util.readDir(vcpkgInstalledPath);
244+
if (list !== undefined) {
245+
// For every *directory* in the list (non-recursive). Each directory is basically a platform.
246+
list.forEach((entry) => {
247+
if (entry !== "vcpkg") {
248+
let pathToCheck: string = path.join(vcpkgInstalledPath, entry);
249+
if (fs.existsSync(pathToCheck)) {
250+
let p: string = path.join(pathToCheck, "include");
251+
if (fs.existsSync(p)) {
252+
this.vcpkgIncludes.push(p);
253+
}
248254
}
249255
}
250-
}
251-
});
256+
});
257+
}
252258
}
253259
}
254260
} catch (error) {} finally {
255261
this.vcpkgPathReady = true;
256262
this.handleConfigurationChange();
257263
}
258-
259264
}
260265

261266
private getConfigIndexForPlatform(config: any): number {

0 commit comments

Comments
 (0)