diff --git a/src/sql/parts/query/common/queryInput.ts b/src/sql/parts/query/common/queryInput.ts index 3614839e6c..bc6c239275 100644 --- a/src/sql/parts/query/common/queryInput.ts +++ b/src/sql/parts/query/common/queryInput.ts @@ -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); } -} \ No newline at end of file +} diff --git a/src/sql/workbench/common/taskUtilities.ts b/src/sql/workbench/common/taskUtilities.ts index 05de9747df..d42530eb4c 100644 --- a/src/sql/workbench/common/taskUtilities.ts +++ b/src/sql/workbench/common/taskUtilities.ts @@ -223,7 +223,8 @@ export function script(connectionProfile: IConnectionProfile, metadata: azdata.O let script: string = result.script; if (script) { - queryEditorService.newSqlEditor(script, connectionProfile.providerName).then((owner) => { + let description = (metadata.schema && metadata.schema !== '') ? `${metadata.schema}.${metadata.name}` : metadata.name; + queryEditorService.newSqlEditor(script, connectionProfile.providerName, undefined, description).then((owner) => { // Connect our editor to the input connection let options: IConnectionCompletionOptions = { params: { connectionType: ConnectionType.editor, runQueryOnCompletion: RunQueryOnConnectionMode.none, input: owner }, diff --git a/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts b/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts index 19625804e9..28332fff55 100644 --- a/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts +++ b/src/sql/workbench/services/queryEditor/browser/queryEditorService.ts @@ -74,7 +74,7 @@ export class QueryEditorService implements IQueryEditorService { /** * Creates new untitled document for SQL query and opens in new editor tab */ - public newSqlEditor(sqlContent?: string, connectionProviderName?: string, isDirty?: boolean): Promise { + public newSqlEditor(sqlContent?: string, connectionProviderName?: string, isDirty?: boolean, objectName?: string): Promise { return new Promise(async (resolve, reject) => { try { // Create file path and file URI @@ -92,7 +92,7 @@ export class QueryEditorService implements IQueryEditorService { } const queryResultsInput: QueryResultsInput = this._instantiationService.createInstance(QueryResultsInput, docUri.toString()); - let queryInput: QueryInput = this._instantiationService.createInstance(QueryInput, '', fileInput, queryResultsInput, connectionProviderName); + let queryInput: QueryInput = this._instantiationService.createInstance(QueryInput, objectName, fileInput, queryResultsInput, connectionProviderName); this._editorService.openEditor(queryInput, { pinned: true }) .then((editor) => { diff --git a/src/sql/workbench/services/queryEditor/common/queryEditorService.ts b/src/sql/workbench/services/queryEditor/common/queryEditorService.ts index a69621dfea..2ceccfb734 100644 --- a/src/sql/workbench/services/queryEditor/common/queryEditorService.ts +++ b/src/sql/workbench/services/queryEditor/common/queryEditorService.ts @@ -23,7 +23,7 @@ export interface IQueryEditorService { _serviceBrand: any; // Creates new untitled document for SQL queries and opens it in a new editor tab - newSqlEditor(sqlContent?: string, connectionProviderName?: string, isDirty?: boolean): Promise; + newSqlEditor(sqlContent?: string, connectionProviderName?: string, isDirty?: boolean, objectName?:string ): Promise; // Creates a new query plan document newQueryPlanEditor(xmlShowPlan: string): Promise;