Change many configs to resource scope (#1017)
This commit is contained in:
Родитель
1534e40712
Коммит
b9ea17c2eb
72
package.json
72
package.json
|
@ -240,12 +240,14 @@
|
|||
"mssql.logDebugInfo": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "%mssql.logDebugInfo%"
|
||||
"description": "%mssql.logDebugInfo%",
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.maxRecentConnections": {
|
||||
"type": "number",
|
||||
"default": 5,
|
||||
"description": "%mssql.maxRecentConnections%"
|
||||
"description": "%mssql.maxRecentConnections%",
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.connections": {
|
||||
"type": "array",
|
||||
|
@ -424,7 +426,8 @@
|
|||
"description": "%mssql.connection.emptyPasswordInput%"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.shortcuts": {
|
||||
"type": "object",
|
||||
|
@ -442,42 +445,50 @@
|
|||
"event.saveAsJSON": "",
|
||||
"event.saveAsCSV": "",
|
||||
"event.saveAsExcel": ""
|
||||
}
|
||||
},
|
||||
"scope": "resource"
|
||||
},
|
||||
"mssql.messagesDefaultOpen": {
|
||||
"type": "boolean",
|
||||
"description": "%mssql.messagesDefaultOpen%",
|
||||
"default": true
|
||||
"default": true,
|
||||
"scope": "resource"
|
||||
},
|
||||
"mssql.resultsFontFamily": {
|
||||
"type": "string",
|
||||
"description": "%mssql.resultsFontFamily%",
|
||||
"default": "-apple-system,BlinkMacSystemFont,Segoe WPC,Segoe UI,HelveticaNeue-Light,Ubuntu,Droid Sans,sans-serif"
|
||||
"default": "-apple-system,BlinkMacSystemFont,Segoe WPC,Segoe UI,HelveticaNeue-Light,Ubuntu,Droid Sans,sans-serif",
|
||||
"scope": "resource"
|
||||
},
|
||||
"mssql.resultsFontSize": {
|
||||
"type": "number",
|
||||
"description": "%mssql.resultsFontSize%",
|
||||
"default": 13
|
||||
"default": 13,
|
||||
"scope": "resource"
|
||||
},
|
||||
"mssql.saveAsCsv.includeHeaders": {
|
||||
"type": "boolean",
|
||||
"description": "%mssql.saveAsCsv.includeHeaders%",
|
||||
"default": true
|
||||
"default": true,
|
||||
"scope": "resource"
|
||||
},
|
||||
"mssql.copyIncludeHeaders": {
|
||||
"type": "boolean",
|
||||
"description": "%mssql.copyIncludeHeaders%",
|
||||
"default": false
|
||||
"default": false,
|
||||
"scope": "resource"
|
||||
},
|
||||
"mssql.copyRemoveNewLine": {
|
||||
"type": "boolean",
|
||||
"description": "%mssql.copyRemoveNewLine%",
|
||||
"default": true
|
||||
"default": true,
|
||||
"scope": "resource"
|
||||
},
|
||||
"mssql.showBatchTime": {
|
||||
"type": "boolean",
|
||||
"description": "%mssql.showBatchTime%",
|
||||
"default": false
|
||||
"default": false,
|
||||
"scope": "resource"
|
||||
},
|
||||
"mssql.splitPaneSelection": {
|
||||
"type": "string",
|
||||
|
@ -487,12 +498,14 @@
|
|||
"next",
|
||||
"current",
|
||||
"end"
|
||||
]
|
||||
],
|
||||
"scope": "resource"
|
||||
},
|
||||
"mssql.format.alignColumnDefinitionsInColumns": {
|
||||
"type": "boolean",
|
||||
"description": "%mssql.format.alignColumnDefinitionsInColumns%",
|
||||
"default": false
|
||||
"default": false,
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.format.datatypeCasing": {
|
||||
"type": "string",
|
||||
|
@ -502,7 +515,8 @@
|
|||
"none",
|
||||
"uppercase",
|
||||
"lowercase"
|
||||
]
|
||||
],
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.format.keywordCasing": {
|
||||
"type": "string",
|
||||
|
@ -512,52 +526,62 @@
|
|||
"none",
|
||||
"uppercase",
|
||||
"lowercase"
|
||||
]
|
||||
],
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.format.placeCommasBeforeNextStatement": {
|
||||
"type": "boolean",
|
||||
"description": "%mssql.format.placeCommasBeforeNextStatement%",
|
||||
"default": false
|
||||
"default": false,
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.format.placeSelectStatementReferencesOnNewLine": {
|
||||
"type": "boolean",
|
||||
"description": "%mssql.format.placeSelectStatementReferencesOnNewLine%",
|
||||
"default": false
|
||||
"default": false,
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.applyLocalization": {
|
||||
"type": "boolean",
|
||||
"description": "%mssql.applyLocalization%",
|
||||
"default": false
|
||||
"default": false,
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.query.displayBitAsNumber": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%mssql.query.displayBitAsNumber%"
|
||||
"description": "%mssql.query.displayBitAsNumber%",
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.intelliSense.enableIntelliSense": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%mssql.intelliSense.enableIntelliSense%"
|
||||
"description": "%mssql.intelliSense.enableIntelliSense%",
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.intelliSense.enableErrorChecking": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%mssql.intelliSense.enableErrorChecking%"
|
||||
"description": "%mssql.intelliSense.enableErrorChecking%",
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.intelliSense.enableSuggestions": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%mssql.intelliSense.enableSuggestions%"
|
||||
"description": "%mssql.intelliSense.enableSuggestions%",
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.intelliSense.enableQuickInfo": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "%mssql.intelliSense.enableQuickInfo%"
|
||||
"description": "%mssql.intelliSense.enableQuickInfo%",
|
||||
"scope": "window"
|
||||
},
|
||||
"mssql.intelliSense.lowerCaseSuggestions": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "%mssql.intelliSense.lowerCaseSuggestions%"
|
||||
"description": "%mssql.intelliSense.lowerCaseSuggestions%",
|
||||
"scope": "window"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,14 +348,14 @@ export default class QueryRunner {
|
|||
return includeHeaders;
|
||||
}
|
||||
// else get config option from vscode config
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName);
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, this.uri);
|
||||
includeHeaders = config[Constants.copyIncludeHeaders];
|
||||
return !!includeHeaders;
|
||||
}
|
||||
|
||||
private shouldRemoveNewLines(): boolean {
|
||||
// get config copyRemoveNewLine option from vscode config
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName);
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, this.uri);
|
||||
let removeNewLines: boolean = config[Constants.configCopyRemoveNewLine];
|
||||
return removeNewLines;
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ export default class QueryRunner {
|
|||
|
||||
private sendBatchTimeMessage(batchId: number, executionTime: string): void {
|
||||
// get config copyRemoveNewLine option from vscode config
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName);
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, this.uri);
|
||||
let showBatchTime: boolean = config[Constants.configShowBatchTime];
|
||||
if (showBatchTime) {
|
||||
let message: IResultMessage = {
|
||||
|
|
|
@ -65,7 +65,7 @@ export default class ResultsSerializer {
|
|||
|
||||
private getConfigForCsv(): Contracts.SaveResultsAsCsvRequestParams {
|
||||
// get save results config from vscode config
|
||||
let config = vscode.workspace.getConfiguration(Constants.extensionConfigSectionName);
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, this._uri);
|
||||
let saveConfig = config[Constants.configSaveAsCsv];
|
||||
let saveResultsParams = new Contracts.SaveResultsAsCsvRequestParams();
|
||||
|
||||
|
@ -80,7 +80,7 @@ export default class ResultsSerializer {
|
|||
|
||||
private getConfigForJson(): Contracts.SaveResultsAsJsonRequestParams {
|
||||
// get save results config from vscode config
|
||||
let config = vscode.workspace.getConfiguration(Constants.extensionConfigSectionName);
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, this._uri);
|
||||
let saveConfig = config[Constants.configSaveAsJson];
|
||||
let saveResultsParams = new Contracts.SaveResultsAsJsonRequestParams();
|
||||
|
||||
|
@ -94,7 +94,7 @@ export default class ResultsSerializer {
|
|||
// get save results config from vscode config
|
||||
// Note: we are currently using the configSaveAsCsv setting since it has the option mssql.saveAsCsv.includeHeaders
|
||||
// and we want to have just 1 setting that lists this.
|
||||
let config = vscode.workspace.getConfiguration(Constants.extensionConfigSectionName);
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, this._uri);
|
||||
let saveConfig = config[Constants.configSaveAsCsv];
|
||||
let saveResultsParams = new Contracts.SaveResultsAsExcelRequestParams();
|
||||
|
||||
|
|
|
@ -97,8 +97,12 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
|
|||
} catch (e) {
|
||||
prod = false;
|
||||
}
|
||||
let mssqlConfig = this._vscodeWrapper.getConfiguration(Constants.extensionName);
|
||||
let editorConfig = this._vscodeWrapper.getConfiguration('editor', uri);
|
||||
let queryUri: string;
|
||||
if (this._queryResultsMap.has(uri)) {
|
||||
queryUri = this._queryResultsMap.get(uri).queryRunner.uri;
|
||||
}
|
||||
let mssqlConfig = this._vscodeWrapper.getConfiguration(Constants.extensionName, queryUri);
|
||||
let editorConfig = this._vscodeWrapper.getConfiguration('editor', queryUri);
|
||||
let extensionFontFamily = mssqlConfig.get<string>(Constants.extConfigResultFontFamily).split('\'').join('').split('"').join('');
|
||||
let extensionFontSize = mssqlConfig.get<number>(Constants.extConfigResultFontSize);
|
||||
let fontfamily = extensionFontFamily ?
|
||||
|
@ -133,7 +137,8 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
|
|||
}
|
||||
|
||||
public configRequestHandler(req, res): void {
|
||||
let extConfig = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName);
|
||||
let queryUri = this._queryResultsMap.get(req.query.uri).queryRunner.uri;
|
||||
let extConfig = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, queryUri);
|
||||
let config = new ResultsConfig();
|
||||
for (let key of Constants.extConfigResultKeys) {
|
||||
config[key] = extConfig[key];
|
||||
|
@ -260,7 +265,7 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
|
|||
|
||||
let paneTitle = Utils.formatString(LocalizedConstants.titleResultsPane, queryRunner.title);
|
||||
// Always run this command even if just updating to avoid a bug - tfs 8686842
|
||||
this.displayResultPane(resultsUri, paneTitle);
|
||||
this.displayResultPane(resultsUri, paneTitle, uri);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,14 +335,14 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
|
|||
}
|
||||
|
||||
// Function to render resultspane content
|
||||
public displayResultPane(resultsUri: string, paneTitle: string): void {
|
||||
public displayResultPane(resultsUri: string, paneTitle: string, queryUri: string): void {
|
||||
// Get the active text editor
|
||||
let activeTextEditor = this._vscodeWrapper.activeTextEditor;
|
||||
|
||||
// Check if the results window already exists
|
||||
if (!this.doesResultPaneExist(resultsUri)) {
|
||||
// Wrapper tells us where the new results pane should be placed
|
||||
let resultPaneColumn = this.newResultPaneViewColumn();
|
||||
let resultPaneColumn = this.newResultPaneViewColumn(queryUri);
|
||||
|
||||
// Try and Open new window then reset focus back to the editor
|
||||
vscode.commands.executeCommand('vscode.previewHtml', resultsUri, resultPaneColumn, paneTitle).then(() => {
|
||||
|
@ -586,9 +591,9 @@ export class SqlOutputContentProvider implements vscode.TextDocumentContentProvi
|
|||
* @return ViewColumn to be used
|
||||
* public for testing purposes
|
||||
*/
|
||||
public newResultPaneViewColumn(): vscode.ViewColumn {
|
||||
public newResultPaneViewColumn(queryUri: string): vscode.ViewColumn {
|
||||
// Find configuration options
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName);
|
||||
let config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, queryUri);
|
||||
let splitPaneSelection = config[Constants.configSplitPaneSelection];
|
||||
let viewColumn: vscode.ViewColumn;
|
||||
|
||||
|
|
|
@ -198,7 +198,9 @@ export class DataService {
|
|||
return Promise.resolve(this._config);
|
||||
} else {
|
||||
return new Promise<{[key: string]: string}>((resolve, reject) => {
|
||||
self.http.get('/config').map((res): IResultsConfig => {
|
||||
let url = '/config?'
|
||||
+ '&uri=' + self.uri;
|
||||
self.http.get(url).map((res): IResultsConfig => {
|
||||
return res.json();
|
||||
}).subscribe((result: IResultsConfig) => {
|
||||
self._shortcuts = result.shortcuts;
|
||||
|
@ -216,7 +218,9 @@ export class DataService {
|
|||
return Promise.resolve(this._shortcuts);
|
||||
} else {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
self.http.get('/config').map((res): IResultsConfig => {
|
||||
let url = '/config?'
|
||||
+ '&uri=' + self.uri;
|
||||
self.http.get(url).map((res): IResultsConfig => {
|
||||
return res.json();
|
||||
}).subscribe((result) => {
|
||||
self._shortcuts = result.shortcuts;
|
||||
|
|
|
@ -490,7 +490,7 @@ suite('Query Runner tests', () => {
|
|||
|
||||
function setupWorkspaceConfig(configResult: {[key: string]: any}): void {
|
||||
let config = stubs.createWorkspaceConfiguration(configResult);
|
||||
testVscodeWrapper.setup(x => x.getConfiguration(TypeMoq.It.isAny()))
|
||||
testVscodeWrapper.setup(x => x.getConfiguration(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
||||
.returns(x => {
|
||||
return config;
|
||||
});
|
||||
|
|
|
@ -5,13 +5,13 @@ import ResultsSerializer from './../src/models/resultsSerializer';
|
|||
import { SaveResultsAsCsvRequestParams } from './../src/models/contracts';
|
||||
import SqlToolsServerClient from './../src/languageservice/serviceclient';
|
||||
import VscodeWrapper from './../src/controllers/vscodeWrapper';
|
||||
import { Uri } from 'vscode';
|
||||
import * as vscode from 'vscode';
|
||||
import os = require('os');
|
||||
|
||||
suite('save results tests', () => {
|
||||
|
||||
const testFile = 'file:///my/test/file.sql';
|
||||
let fileUri: Uri;
|
||||
let fileUri: vscode.Uri;
|
||||
let serverClient: TypeMoq.IMock<SqlToolsServerClient>;
|
||||
let vscodeWrapper: TypeMoq.IMock<VscodeWrapper>;
|
||||
|
||||
|
@ -19,10 +19,13 @@ suite('save results tests', () => {
|
|||
|
||||
serverClient = TypeMoq.Mock.ofType(SqlToolsServerClient, TypeMoq.MockBehavior.Strict);
|
||||
vscodeWrapper = TypeMoq.Mock.ofType(VscodeWrapper);
|
||||
vscodeWrapper.setup(x => x.getConfiguration(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(extensionName => {
|
||||
return vscode.workspace.getConfiguration(extensionName);
|
||||
});
|
||||
if (os.platform() === 'win32') {
|
||||
fileUri = Uri.file('c:\\test.csv');
|
||||
fileUri = vscode.Uri.file('c:\\test.csv');
|
||||
} else {
|
||||
fileUri = Uri.file('/test.csv');
|
||||
fileUri = vscode.Uri.file('/test.csv');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ suite('SqlOutputProvider Tests', () => {
|
|||
let configResult: {[key: string]: any} = {};
|
||||
configResult[Constants.configSplitPaneSelection] = value;
|
||||
let config = stubs.createWorkspaceConfiguration(configResult);
|
||||
vscodeWrapper.setup(x => x.getConfiguration(TypeMoq.It.isAny()))
|
||||
vscodeWrapper.setup(x => x.getConfiguration(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
||||
.returns(x => {
|
||||
return config;
|
||||
});
|
||||
|
@ -74,7 +74,7 @@ suite('SqlOutputProvider Tests', () => {
|
|||
setSplitPaneSelectionConfig(c.config);
|
||||
setCurrentEditorColumn(c.position);
|
||||
|
||||
let resultColumn = contentProvider.newResultPaneViewColumn();
|
||||
let resultColumn = contentProvider.newResultPaneViewColumn('test_uri');
|
||||
|
||||
// Ensure each case properly outputs the result pane
|
||||
assert.equal(resultColumn, c.expectedColumn);
|
||||
|
|
|
@ -51,6 +51,7 @@ suite('Web Service Request Handler Tests', () => {
|
|||
startColumn: 0,
|
||||
startLine: 0
|
||||
};
|
||||
queryRunner.setup(x => x.uri).returns(() => uri);
|
||||
contentProvider.runQuery(statusView.object, uri, querySelection, title);
|
||||
contentProvider.getResultsMap.get('tsqloutput:' + uri).queryRunner = queryRunner.object;
|
||||
});
|
||||
|
@ -117,7 +118,13 @@ suite('Web Service Request Handler Tests', () => {
|
|||
});
|
||||
|
||||
test('ConfigRequestHandler properly handles request and renders content', done => {
|
||||
let request = new stubs.ExpressRequest();
|
||||
let testQuery = {
|
||||
resultSetNo: 0,
|
||||
uri: 'tsqloutput:test_uri',
|
||||
batchIndex: 0,
|
||||
format: 'test_format'
|
||||
};
|
||||
let request = new stubs.ExpressRequest(testQuery);
|
||||
// Run tested function
|
||||
contentProvider.configRequestHandler(request, result.object);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче