Ignore the launch.json save error when clicking run/debug codelens (#673)

Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
This commit is contained in:
Jinbo Wang 2019-09-25 14:50:19 +08:00 committed by GitHub
parent a9da070895
commit 631236e908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -150,9 +150,15 @@ async function constructDebugConfig(mainClass: string, projectName: string, work
// Persist the default debug configuration only if the workspace exists. // Persist the default debug configuration only if the workspace exists.
if (workspace) { if (workspace) {
// Insert the default debug configuration to the beginning of launch.json. try {
rawConfigs.splice(0, 0, debugConfig); // Insert the default debug configuration to the beginning of launch.json.
await launchConfigurations.update("configurations", rawConfigs, vscode.ConfigurationTarget.WorkspaceFolder); rawConfigs.splice(0, 0, debugConfig);
await launchConfigurations.update("configurations", rawConfigs, vscode.ConfigurationTarget.WorkspaceFolder);
} catch (error) {
// When launch.json has unsaved changes before invoking the update api, it will throw the error below:
// 'Unable to write into launch configuration file because the file is dirty. Please save it first and then try again.'
// It's safe to ignore it because the only impact is the configuration is not saved, but you can continue to start the debugger.
}
} }
} }