This commit is contained in:
Sean McManus 2022-02-28 14:08:26 -08:00
Родитель accd0fb4af
Коммит 401748513a
2 изменённых файлов: 52 добавлений и 21 удалений

Просмотреть файл

@ -526,6 +526,15 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
}
}
public async getLaunchConfigs(folder: vscode.WorkspaceFolder | undefined): Promise<vscode.WorkspaceConfiguration[] | undefined> {
let configs: vscode.WorkspaceConfiguration[] | undefined = vscode.workspace.getConfiguration('launch', folder).get('configurations');
if (!configs) {
return undefined;
}
configs = configs.filter(config => (config.name && config.type === DebuggerType.cppvsdbg || config.type === DebuggerType.cppdbg) && config.request === "launch");
return configs;
}
public async buildAndRun(textEditor: vscode.TextEditor): Promise<void> {
// Turn off the debug mode.
return this.buildAndDebug(textEditor, false);
@ -545,6 +554,36 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv
configs = configs.concat(await this.provideDebugConfigurationsForType(DebuggerType.cppvsdbg, folder));
}
if (folder) {
// Get existing debug configurations from launch.json.
let existingConfigs: vscode.DebugConfiguration[] | undefined = (await this.getLaunchConfigs(folder))?.map(config =>
({name: config.name,
type: config.type,
request: config.request,
detail: config.detail ? config.detail : localize("pre.Launch.Task", "preLaunchTask: {0}", config.preLaunchTask),
preLaunchTask: config.preLaunchTask,
existing: TaskConfigStatus.configured
}));
// Remove the detected configs that are already configured once in launch.json.
const dedupExistingConfigs: vscode.DebugConfiguration[] = configs.filter(detectedConfig => {
let isAlreadyConfigured: boolean = false;
if (existingConfigs && existingConfigs.length !== 0) {
for (const config of existingConfigs) {
if (config.name === detectedConfig.name &&
(config.preLaunchTask as string) === (detectedConfig.preLaunchTask as string) &&
config.type === detectedConfig.type &&
config.request === detectedConfig.request) {
isAlreadyConfigured = true;
break;
}
}
}
return !isAlreadyConfigured;
});
configs = existingConfigs ? existingConfigs.concat(dedupExistingConfigs) : dedupExistingConfigs;
}
const defaultConfig: vscode.DebugConfiguration[] = configs.filter((config: vscode.DebugConfiguration) => (config.hasOwnProperty("isDefault") && config.isDefault));
interface MenuItem extends vscode.QuickPickItem {
configuration: vscode.DebugConfiguration;

Просмотреть файл

@ -712,29 +712,21 @@ export class CppSettings extends Settings {
return true;
}
}
if (editorConfigSettings.root !== undefined) {
if (typeof editorConfigSettings.root === "boolean") {
if (editorConfigSettings.root) {
return true;
}
} else if (typeof editorConfigSettings.root === "string") {
if (editorConfigSettings.root.toLowerCase() === "true") {
return true;
switch (typeof editorConfigSettings.root) {
case "boolean":
return editorConfigSettings.root;
case "string":
return editorConfigSettings.root.toLowerCase() === "true";
default:
return false;
}
}
}
} else {
const clangFormatPath1: string = path.join(parentPath, ".clang-format");
if (fs.existsSync(clangFormatPath1)) {
return true;
} else {
}
const clangFormatPath2: string = path.join(parentPath, "_clang-format");
if (fs.existsSync(clangFormatPath2)) {
return true;
}
}
}
return false;
return fs.existsSync(clangFormatPath2);
};
// Scan parent paths to see which we find first, ".clang-format" or ".editorconfig"
const fsPath: string = document.uri.fsPath;