Skip to content

Commit e4a9ddb

Browse files
authored
Add windowsErrorReportingMode. (#13929)
* Add windowsErrorReportingMode.
1 parent b454c98 commit e4a9ddb

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

Extension/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,6 +3379,17 @@
33793379
"default": "default",
33803380
"markdownDescription": "%c_cpp.configuration.copilotHover.markdownDescription%",
33813381
"scope": "window"
3382+
},
3383+
"C_Cpp.windowsErrorReportingMode": {
3384+
"type": "string",
3385+
"enum": [
3386+
"default",
3387+
"enabled",
3388+
"disabled"
3389+
],
3390+
"default": "default",
3391+
"markdownDescription": "%c_cpp.configuration.windowsErrorReportingMode.markdownDescription%",
3392+
"scope": "window"
33823393
}
33833394
}
33843395
}

Extension/package.nls.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,12 @@
790790
"{Locked=\"`disabled`\"} {Locked=\"Copilot\"}"
791791
]
792792
},
793+
"c_cpp.configuration.windowsErrorReportingMode.markdownDescription": {
794+
"message": "If `disabled`, Windows Error Reporting will be disabled. If `default`, Windows Error Reporting will be enabled, but it becomes disabled after the first crash in the current session. Changing the setting doesn't affect currently running IntelliSense processes.",
795+
"comment": [
796+
"{Locked=\"`disabled`\"} {Locked=\"`default`\"} {Locked=\"`IntelliSense`\"}"
797+
]
798+
},
793799
"c_cpp.configuration.renameRequiresIdentifier.markdownDescription": {
794800
"message": "If `true`, 'Rename Symbol' will require a valid C/C++ identifier.",
795801
"comment": [
@@ -1084,4 +1090,4 @@
10841090
"c_cpp.configuration.refactoring.includeHeader.never.description": "Never include the header file.",
10851091
"c_cpp.languageModelTools.configuration.displayName": "C/C++ configuration",
10861092
"c_cpp.languageModelTools.configuration.userDescription": "Configuration of the active C or C++ file, like language standard version and target platform."
1087-
}
1093+
}

Extension/src/LanguageServer/client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export function hasTrustedCompilerPaths(): boolean {
9090
// Data shared by all clients.
9191
let languageClient: LanguageClient;
9292
let firstClientStarted: Promise<{ wasShutdown: boolean }>;
93+
let languageClientHasCrashed: boolean = false;
9394
let languageClientCrashedNeedsRestart: boolean = false;
9495
const languageClientCrashTimes: number[] = [];
9596
let compilerDefaults: configs.CompilerDefaults | undefined;
@@ -1600,6 +1601,7 @@ export class DefaultClient implements Client {
16001601
codeAnalysisMaxMemory: workspaceSettings.codeAnalysisMaxMemory,
16011602
codeAnalysisUpdateDelay: workspaceSettings.codeAnalysisUpdateDelay,
16021603
copilotHover: workspaceSettings.copilotHover,
1604+
windowsErrorReportingMode: workspaceSettings.windowsErrorReportingMode,
16031605
workspaceFolderSettings: workspaceFolderSettingsParams
16041606
};
16051607
}
@@ -1688,6 +1690,7 @@ export class DefaultClient implements Client {
16881690
errorHandler: {
16891691
error: (_error, _message, _count) => ({ action: ErrorAction.Continue }),
16901692
closed: () => {
1693+
languageClientHasCrashed = true;
16911694
languageClientCrashTimes.push(Date.now());
16921695
languageClientCrashedNeedsRestart = true;
16931696
let restart: boolean = true;
@@ -1752,6 +1755,12 @@ export class DefaultClient implements Client {
17521755

17531756
if (usesCrashHandler()) {
17541757
watchForCrashes(await languageClient.sendRequest(PreInitializationRequest, null));
1758+
} else if (os.platform() === "win32") {
1759+
const settings: CppSettings = new CppSettings();
1760+
if ((settings.windowsErrorReportingMode === "default" && !languageClientHasCrashed) ||
1761+
settings.windowsErrorReportingMode === "enabled") {
1762+
await languageClient.sendRequest(PreInitializationRequest, null);
1763+
}
17551764
}
17561765

17571766
// Move initialization to a separate message, so we can see log output from it.

Extension/src/LanguageServer/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export interface SettingsParams {
164164
codeAnalysisUpdateDelay: number;
165165
workspaceFolderSettings: WorkspaceFolderSettingsParams[];
166166
copilotHover: string;
167+
windowsErrorReportingMode: string;
167168
}
168169

169170
function getTarget(): vscode.ConfigurationTarget {
@@ -478,6 +479,7 @@ export class CppSettings extends Settings {
478479
}
479480
return this.getAsString("copilotHover");
480481
}
482+
public get windowsErrorReportingMode(): string { return this.getAsString("windowsErrorReportingMode"); }
481483
public get cppContextProviderParams(): string | undefined {
482484
const value = super.Section.get<any>("copilotContextProviderParams");
483485
if (isString(value)) {

0 commit comments

Comments
 (0)