diff --git a/src/vs/workbench/parts/debug/node/debugAdapter.ts b/src/vs/workbench/parts/debug/node/debugAdapter.ts index b43584e06b2..3c5cde01616 100644 --- a/src/vs/workbench/parts/debug/node/debugAdapter.ts +++ b/src/vs/workbench/parts/debug/node/debugAdapter.ts @@ -84,7 +84,7 @@ export class Adapter { objects.mixin(this.rawAdapter, secondRawAdapter, extensionDescription.isBuiltin); } - public getInitialConfigFileContent(): TPromise { + public getInitialConfigurationContent(): TPromise { const editorConfig = this.configurationService.getConfiguration(); if (typeof this.rawAdapter.initialConfigurations === 'string') { // Contributed initialConfigurations is a command that needs to be invoked @@ -105,7 +105,7 @@ export class Adapter { configurations: this.rawAdapter.initialConfigurations || [] }, null, - editorConfig.editor.insertSpaces ? strings.repeat(' ', editorConfig.editor.tabSize) : '\t' + editorConfig.editor && editorConfig.editor.insertSpaces ? strings.repeat(' ', editorConfig.editor.tabSize) : '\t' )); }; diff --git a/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts b/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts index 1c4af2c686b..6a45dbd1069 100644 --- a/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts +++ b/src/vs/workbench/parts/debug/node/debugConfigurationManager.ts @@ -285,7 +285,7 @@ export class ConfigurationManager implements debug.IConfigurationManager { return this.fileService.resolveContent(resource).then(content => true, err => this.quickOpenService.pick(this.adapters, { placeHolder: nls.localize('selectDebug', "Select Environment") }) - .then(adapter => adapter ? adapter.getInitialConfigFileContent() : null) + .then(adapter => adapter ? adapter.getInitialConfigurationContent() : null) .then(content => { if (!content) { return false; diff --git a/src/vs/workbench/parts/debug/test/node/debugAdapter.test.ts b/src/vs/workbench/parts/debug/test/node/debugAdapter.test.ts index f92466f35dc..e91588da46a 100644 --- a/src/vs/workbench/parts/debug/test/node/debugAdapter.test.ts +++ b/src/vs/workbench/parts/debug/test/node/debugAdapter.test.ts @@ -3,10 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import assert = require('assert'); -import paths = require('vs/base/common/paths'); -import platform = require('vs/base/common/platform'); +import * as assert from 'assert'; +import * as paths from 'vs/base/common/paths'; +import * as platform from 'vs/base/common/platform'; import { Adapter } from 'vs/workbench/parts/debug/node/debugAdapter'; +import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; suite('Debug - Adapter', () => { let adapter: Adapter; @@ -49,14 +50,15 @@ suite('Debug - Adapter', () => { }; setup(() => { - adapter = new Adapter(rawAdapter, { extensionFolderPath, id: 'adapter', name: 'myAdapter', version: '1.0.0', publisher: 'vscode', isBuiltin: false, engines: null }, null, null, null); + adapter = new Adapter(rawAdapter, { extensionFolderPath, id: 'adapter', name: 'myAdapter', version: '1.0.0', publisher: 'vscode', isBuiltin: false, engines: null }, + null, new TestConfigurationService(), null); }); teardown(() => { adapter = null; }); - test('adapter attributes', () => { + test('attributes', () => { assert.equal(adapter.type, rawAdapter.type); assert.equal(adapter.label, rawAdapter.label); assert.equal(adapter.program, paths.join(extensionFolderPath, rawAdapter.program)); @@ -77,7 +79,7 @@ suite('Debug - Adapter', () => { assert.equal(!!schemaAttribute['properties']['preLaunchTask'], true); }); - test('adapter merge', () => { + test('merge', () => { const runtimeArgs = ['first arg']; adapter.merge({ type: 'mock', @@ -96,4 +98,21 @@ suite('Debug - Adapter', () => { assert.deepEqual(adapter.runtimeArgs, runtimeArgs); assert.equal(adapter.program, 'a/b/c/d/mockprogram'); }); + + test('initial config file content', () => { + adapter.getInitialConfigurationContent().then(content => { + const expected = ['{', + ' "version": "0.2.0",', + ' "configurations": [', + ' {', + ' "name": "Mock-Debug",', + ' "type": "mock",', + ' "request": "launch",', + ' "program": "readme.md"', + ' }', + ' ]', + '}'].join('\n'); + assert.equal(content, expected); + }, err => assert.fail()); + }); }); \ No newline at end of file