diff --git a/src/sql/parts/query/common/queryResultsInput.ts b/src/sql/parts/query/common/queryResultsInput.ts index f51f6a6caf..e826cd86e0 100644 --- a/src/sql/parts/query/common/queryResultsInput.ts +++ b/src/sql/parts/query/common/queryResultsInput.ts @@ -14,16 +14,21 @@ import { GridPanelState } from 'sql/parts/query/editor/gridPanel'; import { MessagePanelState } from 'sql/parts/query/editor/messagePanel'; import { QueryPlanState } from 'sql/parts/queryPlan/queryPlan'; import { ChartState } from 'sql/parts/query/editor/charting/chartView'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; export class ResultsViewState { public gridPanelState: GridPanelState = new GridPanelState(); - public messagePanelState: MessagePanelState = new MessagePanelState(); + public messagePanelState: MessagePanelState = new MessagePanelState(this.configurationService); public chartState: ChartState = new ChartState(); public queryPlanState: QueryPlanState = new QueryPlanState(); public gridPanelSize: number; public messagePanelSize: number; public activeTab: string; public visibleTabs: Set = new Set(); + + constructor(@IConfigurationService private configurationService: IConfigurationService) { + + } } /** @@ -45,9 +50,11 @@ export class QueryResultsInput extends EditorInput { public readonly onRestoreViewStateEmitter = new Emitter(); public readonly onSaveViewStateEmitter = new Emitter(); - public readonly state = new ResultsViewState(); + public readonly state = new ResultsViewState(this.configurationService); - constructor(private _uri: string) { + constructor(private _uri: string, + @IConfigurationService private configurationService: IConfigurationService + ) { super(); this._visible = false; this._hasBootstrapped = false; diff --git a/src/sql/parts/query/editor/messagePanel.ts b/src/sql/parts/query/editor/messagePanel.ts index 000c501bf1..78ac60c5a6 100644 --- a/src/sql/parts/query/editor/messagePanel.ts +++ b/src/sql/parts/query/editor/messagePanel.ts @@ -25,7 +25,7 @@ import { OpenMode, ClickBehavior, ICancelableEvent, IControllerOptions } from 'v import { WorkbenchTreeController } from 'vs/platform/list/browser/listService'; import { IMouseEvent } from 'vs/base/browser/mouseEvent'; import { $ } from 'vs/base/browser/builder'; -import { isArray } from 'vs/base/common/types'; +import { isArray, isUndefinedOrNull } from 'vs/base/common/types'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditor } from 'vs/editor/common/editorCommon'; @@ -62,6 +62,13 @@ const TemplateIds = { export class MessagePanelState { public scrollPosition: number; public collapsed = false; + + constructor(@IConfigurationService configurationService: IConfigurationService) { + let messagesOpenedSettings = configurationService.getValue('sql.messagesDefaultOpen'); + if (!isUndefinedOrNull(messagesOpenedSettings)) { + this.collapsed = !messagesOpenedSettings; + } + } } export class MessagePanel extends ViewletPanel { diff --git a/src/sqltest/parts/query/editor/queryEditor.test.ts b/src/sqltest/parts/query/editor/queryEditor.test.ts index ebe7fddc9b..123a07d78e 100644 --- a/src/sqltest/parts/query/editor/queryEditor.test.ts +++ b/src/sqltest/parts/query/editor/queryEditor.test.ts @@ -110,18 +110,26 @@ suite('SQL QueryEditor Tests', () => { editorDescriptorService = TypeMoq.Mock.ofType(EditorDescriptorService, TypeMoq.MockBehavior.Loose); editorDescriptorService.setup(x => x.getEditor(TypeMoq.It.isAny())).returns(() => descriptor); + configurationService = TypeMoq.Mock.ofInstance({ + getValue: () => undefined, + onDidChangeConfiguration: () => undefined + } as any); + configurationService.setup(x => x.getValue(TypeMoq.It.isAny())).returns(() => { + return { enablePreviewFeatures: true }; + }); + // Create a QueryInput let filePath = 'someFile.sql'; let uri: URI = URI.parse(filePath); let fileInput = new UntitledEditorInput(uri, false, '', '', '', instantiationService.object, undefined, undefined, undefined); - let queryResultsInput: QueryResultsInput = new QueryResultsInput(uri.fsPath); + let queryResultsInput: QueryResultsInput = new QueryResultsInput(uri.fsPath, configurationService.object); queryInput = new QueryInput('first', fileInput, queryResultsInput, undefined, undefined, undefined, undefined, undefined); // Create a QueryInput to compare to the previous one let filePath2 = 'someFile2.sql'; let uri2: URI = URI.parse(filePath2); let fileInput2 = new UntitledEditorInput(uri2, false, '', '', '', instantiationService.object, undefined, undefined, undefined); - let queryResultsInput2: QueryResultsInput = new QueryResultsInput(uri2.fsPath); + let queryResultsInput2: QueryResultsInput = new QueryResultsInput(uri2.fsPath, configurationService.object); queryInput2 = new QueryInput('second', fileInput2, queryResultsInput2, undefined, undefined, undefined, undefined, undefined); // Mock IMessageService @@ -136,14 +144,6 @@ suite('SQL QueryEditor Tests', () => { // Create a QueryModelService queryModelService = new QueryModelService(instantiationService.object, notificationService.object); - - configurationService = TypeMoq.Mock.ofInstance({ - getValue: () => undefined, - onDidChangeConfiguration: () => undefined - } as any); - configurationService.setup(x => x.getValue(TypeMoq.It.isAny())).returns(() => { - return { enablePreviewFeatures: true }; - }); }); test('createEditor creates only the taskbar', (done) => { @@ -393,7 +393,7 @@ suite('SQL QueryEditor Tests', () => { done(); }); test('Test that we attempt to dispose query when the queryInput is disposed', (done) => { - let queryResultsInput = new QueryResultsInput('testUri'); + let queryResultsInput = new QueryResultsInput('testUri', configurationService.object); queryInput['_results'] = queryResultsInput; queryInput.dispose(); queryModelService.verify(x => x.disposeQuery(TypeMoq.It.isAnyString()), TypeMoq.Times.once());