Skip to content

Commit

Permalink
align first add of launch configuration to preferences
Browse files Browse the repository at this point in the history
fix wrong behavior of creating it always hard coded under .theia folder

Signed-off-by: Amiram Wingarten <amiram.wingarten@sap.com>
  • Loading branch information
amiramw committed Jul 10, 2019
1 parent 021cfc5 commit 1e169ed
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/debug/src/browser/debug-configuration-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,23 @@ export class DebugConfigurationManager {
});
}
protected async doCreate(model: DebugConfigurationModel): Promise<URI> {
const uri = new URI(model.workspaceFolderUri).resolve('.theia/launch.json');
await this.preferences.set('launch', {}); // create dummy launch.json in the correct place
const { configUri } = this.preferences.resolve('launch'); // get uri to write content to it
let uri: URI;
if (configUri && configUri.path.base === 'launch.json') {
uri = configUri;
} else { // fallback
uri = new URI(model.workspaceFolderUri).resolve('.theia/launch.json');
}
const debugType = await this.selectDebugType();
const configurations = debugType ? await this.provideDebugConfigurations(debugType, model.workspaceFolderUri) : [];
const content = this.getInitialConfigurationContent(configurations);
const fileStat = await this.filesystem.getFileStat(uri.toString());
if (!fileStat) {
throw new Error(`file not found: ${uri.toString()}`);
}
try {
await this.filesystem.createFile(uri.toString(), { content });
await this.filesystem.setContent(fileStat, content);
} catch (e) {
if (!FileSystemError.FileExists.is(e)) {
throw e;
Expand Down

0 comments on commit 1e169ed

Please sign in to comment.