diff --git a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts index 54a71784d29..94711974ea8 100644 --- a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts @@ -42,6 +42,7 @@ import { IFileService } from 'vs/platform/files/common/files'; import { withNullAsUndefined, assertAllDefined, assertIsDefined } from 'vs/base/common/types'; import { ILabelService } from 'vs/platform/label/common/label'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; +import { basenameOrAuthority } from 'vs/base/common/resources'; interface IEditorInputLabel { name?: string; @@ -941,7 +942,15 @@ export class TabsTitleControl extends TitleControl { tabContainer.title = title; // Label - tabLabelWidget.setResource({ name, description, resource: toResource(editor, { supportSideBySide: SideBySideEditor.MASTER }) }, { title, extraClasses: ['tab-label'], italic: !this.group.isPinned(editor) }); + const resource = toResource(editor, { supportSideBySide: SideBySideEditor.MASTER }); + tabLabelWidget.setResource({ name, description, resource }, { title, extraClasses: ['tab-label'], italic: !this.group.isPinned(editor) }); + + // Tests helper + if (resource) { + tabContainer.setAttribute('data-resource-name', basenameOrAuthority(resource)); + } else { + tabContainer.removeAttribute('data-resource-name'); + } } private redrawEditorActiveAndDirty(isGroupActive: boolean, editor: IEditorInput, tabContainer: HTMLElement, tabLabelWidget: IResourceLabel): void { diff --git a/test/automation/src/editors.ts b/test/automation/src/editors.ts index ef088e464d2..dac1f1e40df 100644 --- a/test/automation/src/editors.ts +++ b/test/automation/src/editors.ts @@ -17,27 +17,27 @@ export class Editors { } } - async selectTab(tabName: string, untitled: boolean = false): Promise { - await this.code.waitAndClick(`.tabs-container div.tab[aria-label="${tabName}, tab"]`); - await this.waitForEditorFocus(tabName, untitled); + async selectTab(fileName: string): Promise { + await this.code.waitAndClick(`.tabs-container div.tab[data-resource-name$="${fileName}"]`); + await this.waitForEditorFocus(fileName); } - async waitForActiveEditor(filename: string): Promise { - const selector = `.editor-instance .monaco-editor[data-uri$="${filename}"] textarea`; + async waitForActiveEditor(fileName: string): Promise { + const selector = `.editor-instance .monaco-editor[data-uri$="${fileName}"] textarea`; return this.code.waitForActiveElement(selector); } - async waitForEditorFocus(fileName: string, untitled: boolean = false): Promise { + async waitForEditorFocus(fileName: string): Promise { await this.waitForActiveTab(fileName); await this.waitForActiveEditor(fileName); } async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise { - await this.code.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][aria-label="${fileName}, tab"]`); + await this.code.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][data-resource-name$="${fileName}"]`); } async waitForTab(fileName: string, isDirty: boolean = false): Promise { - await this.code.waitForElement(`.tabs-container div.tab${isDirty ? '.dirty' : ''}[aria-label="${fileName}, tab"]`); + await this.code.waitForElement(`.tabs-container div.tab${isDirty ? '.dirty' : ''}[data-resource-name$="${fileName}"]`); } async newUntitledFile(): Promise { @@ -47,6 +47,6 @@ export class Editors { await this.code.dispatchKeybinding('ctrl+n'); } - await this.waitForEditorFocus('Untitled-1', true); + await this.waitForEditorFocus('Untitled-1'); } } diff --git a/test/smoke/src/areas/workbench/data-loss.test.ts b/test/smoke/src/areas/workbench/data-loss.test.ts index cb049e59ad3..07ca7f83886 100644 --- a/test/smoke/src/areas/workbench/data-loss.test.ts +++ b/test/smoke/src/areas/workbench/data-loss.test.ts @@ -12,7 +12,7 @@ export function setup() { await app.workbench.editors.newUntitledFile(); const untitled = 'Untitled-1'; - const textToTypeInUntitled = untitled; + const textToTypeInUntitled = 'Hello from Untitled'; await app.workbench.editor.waitForTypeInEditor(untitled, textToTypeInUntitled); const readmeMd = 'readme.md'; @@ -25,8 +25,8 @@ export function setup() { await app.workbench.editors.waitForActiveTab(readmeMd, true); await app.workbench.editor.waitForEditorContents(readmeMd, c => c.indexOf(textToType) > -1); - await app.workbench.editors.waitForTab(untitled, true); - await app.workbench.editors.selectTab(untitled, true); + await app.workbench.editors.waitForTab(untitled); + await app.workbench.editors.selectTab(untitled); await app.workbench.editor.waitForEditorContents(untitled, c => c.indexOf(textToTypeInUntitled) > -1); }); }); diff --git a/test/smoke/src/areas/workbench/data-migration.test.ts b/test/smoke/src/areas/workbench/data-migration.test.ts index e455105ed4d..0a403bef78d 100644 --- a/test/smoke/src/areas/workbench/data-migration.test.ts +++ b/test/smoke/src/areas/workbench/data-migration.test.ts @@ -66,7 +66,7 @@ export function setup(stableCodePath: string, testDataPath: string) { await stableApp.workbench.editors.newUntitledFile(); const untitled = 'Untitled-1'; - const textToTypeInUntitled = untitled; + const textToTypeInUntitled = 'Hello from Untitled'; await stableApp.workbench.editor.waitForTypeInEditor(untitled, textToTypeInUntitled); const readmeMd = 'readme.md'; @@ -86,7 +86,7 @@ export function setup(stableCodePath: string, testDataPath: string) { await insidersApp.workbench.editor.waitForEditorContents(readmeMd, c => c.indexOf(textToType) > -1); await insidersApp.workbench.editors.waitForTab(untitled, true); - await insidersApp.workbench.editors.selectTab(untitled, true); + await insidersApp.workbench.editors.selectTab(untitled); await insidersApp.workbench.editor.waitForEditorContents(untitled, c => c.indexOf(textToTypeInUntitled) > -1); await insidersApp.stop();