Skip to content

Commit

Permalink
Merge branch 'master' into updatePackages
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Bist committed Dec 12, 2019
2 parents 3c27556 + e3d42ca commit cbdee57
Show file tree
Hide file tree
Showing 25 changed files with 330 additions and 161 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ See [the SQL developer tutorial] to develop an app with C#, Java, Node.js, PHP,
## What's new in 1.8.0
* Added support for scripting context menu actions on the Object Explorer
* Added support for adding a new firewall rule to a server
* Separate database connections from server connections
* Added differentiation between database connections and server connections
* Reduced extension size from 10 MB to 6MB
* Open pinned doc when starting a new query
* Fixed scrolling and heights for multiple result sets
* Fixed using correct database for new query from Object Explorer
* Fixed results font size from settings not respected
* Fixed bug to use the correct database for new query from Object Explorer

## Version 1.7.1
* Release date: November 11, 2019
Expand Down
6 changes: 0 additions & 6 deletions localization/xliff/enu/constants/localizedConstants.enu.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@
<trans-unit id="msgPromptRetryFirewallRuleNotSignedIn">
<source xml:lang="en">Your client IP address does not have access to the server. Sign in to an Azure account and create a new firewall rule to enable access.</source>
</trans-unit>
<trans-unit id="msgPromptRetryFirewallRuleNotActivated">
<source xml:lang="en">Your client IP address does not have access to the server. Activate the Azure Account extension and sign in to an Azure account and create a new firewall rule to enable access.</source>
</trans-unit>
<trans-unit id="msgPromptRetryFirewallRuleSignedIn">
<source xml:lang="en">Account signed In. Create new firewall rule? </source>
</trans-unit>
Expand Down Expand Up @@ -266,9 +263,6 @@
<trans-unit id="downloadAndInstallLabel">
<source xml:lang="en">Download and Install</source>
</trans-unit>
<trans-unit id="activateLabel">
<source xml:lang="en">Activate</source>
</trans-unit>
<trans-unit id="createFirewallRuleLabel">
<source xml:lang="en">Create Firewall Rule</source>
</trans-unit>
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,17 @@
{
"command": "mssql.removeObjectExplorerNode",
"when": "view == objectExplorer && viewItem =~ /^(disconnectedServer|Server)$/",
"group": "MS_SQL@3"
"group": "MS_SQL@4"
},
{
"command": "mssql.refreshObjectExplorerNode",
"when": "view == objectExplorer && viewItem != disconnectedServer",
"group": "MS_SQL@2"
"group": "MS_SQL@10"
},
{
"command": "mssql.disconnectObjectExplorerNode",
"when": "view == objectExplorer && viewItem == Server",
"group": "MS_SQL@4"
"group": "MS_SQL@3"
},
{
"command": "mssql.scriptSelect",
Expand All @@ -223,22 +223,22 @@
{
"command": "mssql.scriptCreate",
"when": "view == objectExplorer && viewItem =~ /^(Table|View|AggregateFunction|PartitionFunction|ScalarValuedFunction|Schema|StoredProcedure|TableValuedFunction|User|UserDefinedTableType)$/",
"group": "MS_SQL@1"
"group": "MS_SQL@2"
},
{
"command": "mssql.scriptDelete",
"when": "view == objectExplorer && viewItem =~ /^(Table|View|AggregateFunction|PartitionFunction|ScalarValuedFunction|Schema|StoredProcedure|TableValuedFunction|User|UserDefinedTableType)$/",
"group": "MS_SQL@1"
"group": "MS_SQL@3"
},
{
"command": "mssql.scriptExecute",
"when": "view == objectExplorer && viewItem =~ /^(StoredProcedure)$/",
"group": "MS_SQL@1"
"group": "MS_SQL@5"
},
{
"command": "mssql.scriptAlter",
"when": "view == objectExplorer && viewItem =~ /^(AggregateFunction|PartitionFunction|ScalarValuedFunction|StoredProcedure|TableValuedFunction|View)$/",
"group": "MS_SQL@1"
"group": "MS_SQL@4"
}
],
"commandPalette": [
Expand Down
2 changes: 1 addition & 1 deletion src/configurations/dev.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"service": {
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/v{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
"version": "2.0.0-release.30",
"version": "2.0.0-release.39",
"downloadFileNames": {
"Windows_7_86": "win-x86-netcoreapp2.2.zip",
"Windows_7_64": "win-x64-netcoreapp2.2.zip",
Expand Down
19 changes: 9 additions & 10 deletions src/controllers/connectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,38 +788,37 @@ export default class ConnectionManager {
return this.connectionUI.removeProfile();
}

public onDidCloseTextDocument(doc: vscode.TextDocument): void {
let docUri: string = doc.uri.toString();
public async onDidCloseTextDocument(doc: vscode.TextDocument): Promise<void> {
let docUri: string = doc.uri.toString(true);

// If this file isn't connected, then don't do anything
if (!this.isConnected(docUri)) {
return;
}

// Disconnect the document's connection when we close it
this.disconnect(docUri);
await this.disconnect(docUri);
}

public onDidOpenTextDocument(doc: vscode.TextDocument): void {
let uri = doc.uri.toString();
let uri = doc.uri.toString(true);
if (doc.languageId === 'sql' && typeof(this._connections[uri]) === 'undefined') {
this.statusView.notConnected(uri);
}
}

public transferFileConnection(oldFileUri: string, newFileUri: string): void {
public async transferFileConnection(oldFileUri: string, newFileUri: string): Promise<void> {
// Is the new file connected or the old file not connected?
if (!this.isConnected(oldFileUri) || this.isConnected(newFileUri)) {
return;
}

// Connect the saved uri and disconnect the untitled uri on successful connection
let creds: Interfaces.IConnectionCredentials = this._connections[oldFileUri].credentials;
this.connect(newFileUri, creds).then(result => {
if (result) {
this.disconnect(oldFileUri);
}
});
let result = await this.connect(newFileUri, creds)
if (result) {
await this.disconnect(oldFileUri);
}
}

private getIsServerLinux(osVersion: string): string {
Expand Down
32 changes: 17 additions & 15 deletions src/controllers/mainController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default class MainController implements vscode.Disposable {
this.scriptNode(node, ScriptOperation.Alter)));

// Add handlers for VS Code generated commands
this._vscodeWrapper.onDidCloseTextDocument(params => this.onDidCloseTextDocument(params));
this._vscodeWrapper.onDidCloseTextDocument(async (params) => await this.onDidCloseTextDocument(params));
this._vscodeWrapper.onDidOpenTextDocument(params => this.onDidOpenTextDocument(params));
this._vscodeWrapper.onDidSaveTextDocument(params => this.onDidSaveTextDocument(params));
this._vscodeWrapper.onDidChangeConfiguration(params => this.onDidChangeConfiguration(params));
Expand Down Expand Up @@ -280,7 +280,7 @@ export default class MainController implements vscode.Disposable {
}
const selectStatement = await this._scriptingService.script(node, nodeUri, operation);
const editor = await this._untitledSqlDocumentService.newQuery(selectStatement);
let uri = editor.document.uri.toString();
let uri = editor.document.uri.toString(true);
let title = path.basename(editor.document.fileName);
const queryUriPromise = new Deferred<boolean>();
await this.connectionManager.connect(uri, connectionCreds, queryUriPromise);
Expand Down Expand Up @@ -740,7 +740,7 @@ export default class MainController implements vscode.Disposable {
if (this.canRunCommand()) {
// from the object explorer context menu
const editor = await this._untitledSqlDocumentService.newQuery(content);
const uri = editor.document.uri.toString();
const uri = editor.document.uri.toString(true);
if (node) {
// connect to the node if the command came from the context
const connectionCreds = node.connectionCredentials;
Expand All @@ -749,9 +749,9 @@ export default class MainController implements vscode.Disposable {
// connect it first
await this.createObjectExplorerSession(node.connectionCredentials);
}
this._statusview.languageFlavorChanged(uri.toString(), Constants.mssqlProviderName);
await this.connectionManager.connect(uri.toString(), connectionCreds);
this._statusview.sqlCmdModeChanged(uri.toString(), false);
this._statusview.languageFlavorChanged(uri, Constants.mssqlProviderName);
await this.connectionManager.connect(uri, connectionCreds);
this._statusview.sqlCmdModeChanged(uri, false);
await this.connectionManager.connectionStore.removeRecentlyUsed(<IConnectionProfile>connectionCreds);
return true;
} else {
Expand All @@ -762,7 +762,7 @@ export default class MainController implements vscode.Disposable {
if (credentials) {
await this.createObjectExplorerSession(credentials);
}
this._statusview.sqlCmdModeChanged(uri.toString(), false);
this._statusview.sqlCmdModeChanged(uri, false);
return true;
}
}
Expand Down Expand Up @@ -800,12 +800,12 @@ export default class MainController implements vscode.Disposable {
* or a renamed file
* @param doc The document that was closed
*/
public onDidCloseTextDocument(doc: vscode.TextDocument): void {
public async onDidCloseTextDocument(doc: vscode.TextDocument): Promise<void> {
if (this._connectionMgr === undefined) {
// Avoid processing events before initialization is complete
return;
}
let closedDocumentUri: string = doc.uri.toString();
let closedDocumentUri: string = doc.uri.toString(true);
let closedDocumentUriScheme: string = doc.uri.scheme;

// Stop timers if they have been started
Expand All @@ -825,17 +825,17 @@ export default class MainController implements vscode.Disposable {
closedDocumentUriScheme === LocalizedConstants.untitledScheme &&
this._lastSavedTimer.getDuration() < Constants.untitledSaveTimeThreshold) {
// Untitled file was saved and connection will be transfered
this._connectionMgr.transferFileConnection(closedDocumentUri, this._lastSavedUri);
await this._connectionMgr.transferFileConnection(closedDocumentUri, this._lastSavedUri);

// If there was an openTextDoc event just before this closeTextDoc event then we know it was a rename
} else if (this._lastOpenedUri &&
this._lastOpenedTimer.getDuration() < Constants.renamedOpenTimeThreshold) {
// File was renamed and connection will be transfered
this._connectionMgr.transferFileConnection(closedDocumentUri, this._lastOpenedUri);
await this._connectionMgr.transferFileConnection(closedDocumentUri, this._lastOpenedUri);

} else {
// Pass along the close event to the other handlers for a normal closed file
this._connectionMgr.onDidCloseTextDocument(doc);
await this._connectionMgr.onDidCloseTextDocument(doc);
this._outputContentProvider.onDidCloseTextDocument(doc);
}

Expand All @@ -859,14 +859,15 @@ export default class MainController implements vscode.Disposable {
this._connectionMgr.onDidOpenTextDocument(doc);

if (doc && doc.languageId === Constants.languageId) {
this._statusview.languageFlavorChanged(doc.uri.toString(), Constants.mssqlProviderName);
// set encoding to false
this._statusview.languageFlavorChanged(doc.uri.toString(true), Constants.mssqlProviderName);
}

// Setup properties incase of rename
this._lastOpenedTimer = new Utils.Timer();
this._lastOpenedTimer.start();
if (doc && doc.uri) {
this._lastOpenedUri = doc.uri.toString();
this._lastOpenedUri = doc.uri.toString(true);
}
}

Expand All @@ -881,7 +882,8 @@ export default class MainController implements vscode.Disposable {
return;
}

let savedDocumentUri: string = doc.uri.toString();
// Set encoding to false by giving true as argument
let savedDocumentUri: string = doc.uri.toString(true);

// Keep track of which file was last saved and when for detecting the case when we save an untitled document to disk
this._lastSavedTimer = new Utils.Timer();
Expand Down
13 changes: 11 additions & 2 deletions src/controllers/queryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,18 @@ export default class QueryRunner {
for (let rowId of allRowIds) {
let row = rowIdToRowMap.get(rowId);
const rowSelections = rowIdToSelectionMap.get(rowId);

// sort selections by column to go from left to right
rowSelections.sort((a, b) => {
return ((a.fromCell < b.fromCell) ? -1 : (a.fromCell > b.fromCell) ? 1 : 0);
});

// start copy paste from left-most column
const firstColumn = rowSelections[0].fromCell;

for (let i = 0; i < rowSelections.length; i++) {
let rowSelection = rowSelections[i];
for (let j = 0; j < rowSelection.fromCell; j++) {
for (let j = firstColumn; j < rowSelection.fromCell; j++) {
copyString += ' \t';
}
let cellObjects = row.slice(rowSelection.fromCell, (rowSelection.toCell + 1));
Expand Down Expand Up @@ -507,7 +516,7 @@ export default class QueryRunner {
* @param selection The selection range to select
*/
public async setEditorSelection(selection: ISelectionData): Promise<void> {
const docExists = this._vscodeWrapper.textDocuments.find(textDoc => textDoc.uri.toString() === this.uri);
const docExists = this._vscodeWrapper.textDocuments.find(textDoc => textDoc.uri.toString(true) === this.uri);
if (docExists) {
let column = vscode.ViewColumn.One;
const doc = await this._vscodeWrapper.openTextDocument(this._vscodeWrapper.parseUri(this.uri));
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/vscodeWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class VscodeWrapper {
public get activeTextEditorUri(): string {
if (typeof vscode.window.activeTextEditor !== 'undefined' &&
typeof vscode.window.activeTextEditor.document !== 'undefined') {
return vscode.window.activeTextEditor.document.uri.toString();
return vscode.window.activeTextEditor.document.uri.toString(true);
}
return undefined;
}
Expand Down
19 changes: 13 additions & 6 deletions src/controllers/webviewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ export class WebviewPanelController implements vscode.Disposable {
const config = this._vscodeWrapper.getConfiguration(Constants.extensionConfigSectionName, vscode.Uri.parse(uri));
const retainContextWhenHidden = config[Constants.configPersistQueryResultTabs];
const column = this.newResultPaneViewColumn(uri);
this._disposables.push(this._panel = vscode.window.createWebviewPanel(uri, title, column, {
retainContextWhenHidden,
enableScripts: true
}));
this._disposables.push(this._panel = vscode.window.createWebviewPanel(uri, title,
{
viewColumn: column,
preserveFocus: true
},
{
retainContextWhenHidden,
enableScripts: true
}
));
this._panel.onDidDispose(() => {
this.dispose();
});
Expand Down Expand Up @@ -108,8 +114,9 @@ export class WebviewPanelController implements vscode.Disposable {
this._isDisposed = true;
}

public revealToForeground(): void {
this._panel.reveal();
public revealToForeground(uri: string): void {
let column = this.newResultPaneViewColumn(uri);
this._panel.reveal(column, true);
}

/** Getters */
Expand Down
9 changes: 8 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export function activate(context: vscode.ExtensionContext): Promise<boolean> {
if (applyLocalization) {
LocalizedConstants.loadLocalizedConstants(vscode.env.language);
}

// Exposed for testing purposes
vscode.commands.registerCommand('mssql.getControllerForTests', () => controller);
return controller.activate();
}

Expand All @@ -39,6 +42,10 @@ export function deactivate(): void {
/**
* Exposed for testing purposes
*/
export function getController(): MainController {
export async function getController(): Promise<MainController> {
if (!controller) {
let savedController: MainController = await vscode.commands.executeCommand('mssql.getControllerForTests');
return savedController;
}
return controller;
}
7 changes: 7 additions & 0 deletions src/firewall/firewallService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export class FirewallService {
return this._account;
}

/**
* Public for testing purposes only
*/
public set token(value: any) {
this._token = value;
}

private convertToAzureAccount(azureSession: AzureSession): Account {
let tenant = {
displayName: Constants.tenantDisplayName,
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class HttpClient implements IHttpClient {
/*
* Interface to store the values needed to calculate download percentage
*/
interface IDownloadProgress {
export interface IDownloadProgress {
packageSize: number;
downloadedBytes: number;
downloadPercentage: number;
Expand Down
12 changes: 3 additions & 9 deletions src/languageservice/serviceclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,11 @@ export default class SqlToolsServiceClient {
}

private createResourceClient(resourcePath: string): LanguageClient {
// Options to control the language client
let clientOptions: LanguageClientOptions = {
documentSelector: ['sql'],
synchronize: {
configurationSection: 'mssql'
},
errorHandler: new LanguageClientErrorHandler(this._vscodeWrapper)
};
// add resource provider path here
let serverOptions = this.generateResourceServiceServerOptions(resourcePath);
let client = new LanguageClient(Constants.resourceServiceName, serverOptions, clientOptions);
// client options are undefined since we don't want to send language events to the
// server, since it's handled by the main client
let client = new LanguageClient(Constants.resourceServiceName, serverOptions, undefined);
return client;
}

Expand Down
Loading

0 comments on commit cbdee57

Please sign in to comment.