Skip to content

Commit

Permalink
Test - do not merge this commit
Browse files Browse the repository at this point in the history
  • Loading branch information
westbury committed Aug 20, 2019
1 parent cc213a3 commit ae65026
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions packages/workspace/src/browser/workspace-uri-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DefaultUriLabelProviderContribution, FOLDER_ICON, FILE_ICON } from '@th
import URI from '@theia/core/lib/common/uri';
import { injectable, inject, postConstruct } from 'inversify';
import { FileSystem, FileStat } from '@theia/filesystem/lib/common';
import { MaybePromise } from '@theia/core';
import { MaybePromise, Emitter, Event } from '@theia/core';
import { WorkspaceVariableContribution } from './workspace-variable-contribution';

@injectable()
Expand All @@ -32,7 +32,14 @@ export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProvid

@postConstruct()
protected async init(): Promise<void> {
// no-op, backward compatibility
const outer = this;

setInterval(() => {
outer.x++;
for (const uri of outer.testUris.values()) {
outer.onElementUpdatedEmitter.fire(uri);
}
}, 1000);
}

canHandle(element: object): number {
Expand Down Expand Up @@ -73,8 +80,20 @@ export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProvid
return icon;
}

protected readonly onElementUpdatedEmitter = new Emitter<URI>();
protected testUris: Map<string, URI> = new Map();
private x: number = 0;

getName(element: URI | FileStat): string {
return super.getName(this.getUri(element));
const uri = this.getUri(element);
if (uri.toString().includes('test')) {
if (!this.testUris.has(uri.toString())) {
this.testUris.set(uri.toString(), uri);
}
return super.getName(uri) + '-' + this.x.toString(10);
} else {
return super.getName(uri);
}
}

/**
Expand All @@ -85,4 +104,8 @@ export class WorkspaceUriLabelProviderContribution extends DefaultUriLabelProvid
const relativePath = this.workspaceVariable.getWorkspaceRelativePath(uri);
return relativePath || super.getLongName(uri);
}

get onDidChange(): Event<URI> {
return this.onElementUpdatedEmitter.event;
}
}

0 comments on commit ae65026

Please sign in to comment.