Add scripted object name to query editor tab display (#4403)

* Add scripted object name to query editor tab display

* Update src/sql/parts/query/common/queryInput.ts

Co-Authored-By: shueybubbles <shueybubbles@hotmail.com>
This commit is contained in:
David Shiflet
2019-03-12 22:07:11 -04:00
committed by GitHub
parent dadfbd2ddb
commit 58e5125cde
4 changed files with 20 additions and 11 deletions

View File

@@ -144,6 +144,7 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
public showQueryResultsEditor(): void { this._showQueryResultsEditor.fire(); }
public updateSelection(selection: ISelectionData): void { this._updateSelection.fire(selection); }
public getTypeId(): string { return QueryInput.ID; }
// Description is shown beside the tab name in the combobox of open editors
public getDescription(): string { return this._description; }
public supportsSplitEditor(): boolean { return false; }
public getModeId(): string { return QueryInput.SCHEMA; }
@@ -168,26 +169,33 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
public getEncoding(): string { return this._sql.getEncoding(); }
public suggestFileName(): string { return this._sql.suggestFileName(); }
public getName(): string {
public getName(longForm?: boolean): string {
if (this._configurationService.getValue('sql.showConnectionInfoInTitle')) {
let profile = this._connectionManagementService.getConnectionProfile(this.uri);
let title = '';
if (this._description && this._description !== '') {
title = this._description + ' ';
}
if (profile) {
if (profile.userName) {
title = `${profile.serverName}.${profile.databaseName} (${profile.userName})`;
title += `${profile.serverName}.${profile.databaseName} (${profile.userName})`;
} else {
title = `${profile.serverName}.${profile.databaseName} (${profile.authenticationType})`;
title += `${profile.serverName}.${profile.databaseName} (${profile.authenticationType})`;
}
} else {
title = localize('disconnected', 'disconnected');
title += localize('disconnected', 'disconnected');
}
return this._sql.getName() + ` - ${trimTitle(title)}`;
return this._sql.getName() + (longForm ? (' - ' + title) : ` - ${trimTitle(title)}`);
} else {
return this._sql.getName();
}
}
// Called to get the tooltip of the tab
public getTitle() {
return this.getName(true);
}
public get hasAssociatedFilePath(): boolean { return this._sql.hasAssociatedFilePath; }
public setEncoding(encoding: string, mode: EncodingMode /* ignored, we only have Encode */): void {
@@ -309,4 +317,4 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
public get tabColor(): string {
return this._connectionManagementService.getTabColorForUri(this.uri);
}
}
}