Skip to content

Commit

Permalink
Fix statuses getting stuck, integrate decoration title
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Apr 22, 2021
1 parent 5fc245f commit 690c76c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 33 deletions.
6 changes: 6 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ export interface ITerminalInstance {
* terminal instances within a window.
*/
readonly instanceId: number;
/**
* A unique URI for this terminal instance with the following encoding:
* path: Title
* fragment: Instance ID
*/
readonly resource: URI;

readonly cols: number;
readonly rows: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class TerminalDecorationsProvider implements IDecorationsProvider {
constructor(
@ITerminalService private readonly _terminalService: ITerminalService
) {
this._terminalService.onInstancePrimaryStatusChanged(e => this._onDidChange.fire([e.resource]));
}

get onDidChange(): Event<URI[]> {
Expand Down
12 changes: 9 additions & 3 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import { ITerminalStatusList, TerminalStatus, TerminalStatusList } from 'vs/work
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { isMacintosh, isWindows, OperatingSystem, OS } from 'vs/base/common/platform';
import { URI } from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';

// How long in milliseconds should an average frame take to render for a notification to appear
// which suggests the fallback DOM-based renderer
Expand Down Expand Up @@ -138,6 +140,13 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
public readonly statusList: ITerminalStatusList = new TerminalStatusList();
public disableLayout: boolean;
public get instanceId(): number { return this._instanceId; }
public get resource(): URI {
return URI.from({
scheme: Schemas.vscodeTerminal,
path: this.title,
fragment: this.instanceId.toString(),
});
}
public get cols(): number {
if (this._dimensionsOverride && this._dimensionsOverride.cols) {
if (this._dimensionsOverride.forceExactSize) {
Expand Down Expand Up @@ -1049,13 +1058,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
icon: Codicon.debugDisconnect,
tooltip: nls.localize('disconnectStatus', "Lost connection to process")
});
this._onTitleChanged.fire(this);
});
this._processManager.onPtyReconnect(() => {
this._safeSetOption('disableStdin', false);
this.statusList.remove(TerminalStatus.Disconnected);
// TODO: Remove title change + (disconnected) from title
this._onTitleChanged.fire(this);
});
}

Expand Down
9 changes: 2 additions & 7 deletions src/vs/workbench/contrib/terminal/browser/terminalTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ITerminalInstance, Direction, ITerminalTab, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ViewContainerLocation, IViewDescriptorService } from 'vs/workbench/common/views';
import { IShellLaunchConfig, ITerminalTabLayoutInfoById } from 'vs/platform/terminal/common/terminal';
import { localize } from 'vs/nls';

const SPLIT_PANE_MIN_SIZE = 120;

Expand Down Expand Up @@ -411,20 +410,16 @@ export class TerminalTab extends Disposable implements ITerminalTab {
// this is required when the tab is used as part of a tree.
return '';
}
let title = this._titleWithConnectionStatus(this.terminalInstances[0]);
let title = this.terminalInstances[0].title;
for (let i = 1; i < this.terminalInstances.length; i++) {
const instance = this.terminalInstances[i];
if (instance.title) {
title += `, ${this._titleWithConnectionStatus(instance)}`;
title += `, ${instance.title}}`;
}
}
return title;
}

private _titleWithConnectionStatus(instance: ITerminalInstance): string {
return instance.isDisconnected ? localize('ptyDisconnected', "{0} (disconnected)", instance.title) : instance.title;
}

public setVisible(visible: boolean): void {
this._isVisible = visible;
if (this._tabElement) {
Expand Down
37 changes: 14 additions & 23 deletions src/vs/workbench/contrib/terminal/browser/terminalTabsWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ import { Codicon } from 'vs/base/common/codicons';
import { Action } from 'vs/base/common/actions';
import { MarkdownString } from 'vs/base/common/htmlContent';
import { TerminalDecorationsProvider } from 'vs/workbench/contrib/terminal/browser/terminalDecorationsProvider';
import { DEFAULT_LABELS_CONTAINER, IResourceLabel, IResourceLabelOptions, IResourceLabelProps, ResourceLabels } from 'vs/workbench/browser/labels';
import { DEFAULT_LABELS_CONTAINER, IResourceLabel, ResourceLabels } from 'vs/workbench/browser/labels';
import { IDecorationsService } from 'vs/workbench/services/decorations/browser/decorations';
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
import { URI } from 'vs/base/common/uri';
import Severity from 'vs/base/common/severity';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';

const $ = DOM.$;
export const MIN_TABS_WIDGET_WIDTH = 46;
Expand Down Expand Up @@ -175,7 +173,6 @@ class TerminalTabsRenderer implements ITreeRenderer<ITerminalInstance, never, IT
}

renderElement(node: ITreeNode<ITerminalInstance>, index: number, template: ITerminalTabEntryTemplate): void {

let instance = node.element;

const tab = this._terminalService.getTabForInstance(instance);
Expand Down Expand Up @@ -221,13 +218,6 @@ class TerminalTabsRenderer implements ITreeRenderer<ITerminalInstance, never, IT
label = `${prefix}$(${instance.icon.id}) ${instance.title.replace(/^Task - /, '')}`;
}

template.label.setLabel(label, undefined, {
title: {
markdown: new MarkdownString(title),
markdownNotSupportedFallback: undefined
}
});

if (!template.elementDispoables) {
template.elementDispoables = new DisposableStore();
}
Expand All @@ -239,18 +229,19 @@ class TerminalTabsRenderer implements ITreeRenderer<ITerminalInstance, never, IT
}
}));

if (instance.statusList.statuses.length && hasText) {
const labelProps: IResourceLabelProps = {
resource: URI.from({
scheme: Schemas.vscodeTerminal,
path: instance.title,
fragment: instance.instanceId.toString(),
}),
name: label
};
const options: IResourceLabelOptions = { fileDecorations: { colors: true, badges: true } };
template.label.setResource(labelProps, options);
}
template.label.setResource({
resource: instance.resource,
name: label
}, {
fileDecorations: {
colors: true,
badges: hasText
},
title: {
markdown: new MarkdownString(title),
markdownNotSupportedFallback: undefined
}
});
}

disposeElement(element: ITreeNode<ITerminalInstance, any>, index: number, templateData: ITerminalTabEntryTemplate): void {
Expand Down

0 comments on commit 690c76c

Please sign in to comment.