Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix decoration padding problems #144261

Merged
merged 10 commits into from Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/vs/workbench/contrib/terminal/browser/media/terminal.css
Expand Up @@ -93,7 +93,8 @@
display: block;
}

.monaco-split-view2.vertical .split-view-view .xterm.shell-integration {
.monaco-workbench .pane-body.integrated-terminal .terminal-group .monaco-split-view2.horizontal .split-view-view:first-child .xterm,
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
.integrated-terminal.shell-integration .xterm {
padding-left: 20px !important;
}

Expand Down
12 changes: 12 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalView.ts
Expand Up @@ -110,6 +110,18 @@ export class TerminalViewPane extends ViewPane {
this._terminalTabbedView?.rerenderTabs();
}
}));
configurationService.onDidChangeConfiguration(e => {
if ((e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationsEnabled) && !configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationsEnabled)) ||
(e.affectsConfiguration(TerminalSettingId.ShellIntegrationEnabled) && !configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled))) {
this._parentDomElement?.classList.remove('shell-integration');
} else if (configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationsEnabled) && configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled)) {
this._parentDomElement?.classList.add('shell-integration');
}
});

if (configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationsEnabled) && configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled)) {
this._parentDomElement?.classList.add('shell-integration');
}
}

override renderBody(container: HTMLElement): void {
Expand Down
19 changes: 6 additions & 13 deletions src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts
Expand Up @@ -28,8 +28,7 @@ const enum DecorationSelector {
ErrorColor = 'error',
DefaultColor = 'default',
Codicon = 'codicon',
XtermDecoration = 'xterm-decoration',
ShellIntegration = 'shell-integration'
XtermDecoration = 'xterm-decoration'
}

const enum DecorationStyles {
Expand Down Expand Up @@ -89,15 +88,14 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
}
}

public clearDecorations(disposeOfListeners?: boolean): void {
if (disposeOfListeners) {
public clearDecorations(disableDecorations?: boolean): void {
if (disableDecorations) {
this._commandStartedListener?.dispose();
this._commandFinishedListener?.dispose();
}
this._placeholderDecoration?.dispose();
this._placeholderDecoration?.marker.dispose();
for (const value of this._decorations.values()) {
value.decoration.element?.parentElement?.parentElement?.parentElement?.classList.remove(DecorationSelector.ShellIntegration);
value.decoration.dispose();
value.decoration.marker.dispose();
dispose(value.disposables);
Expand Down Expand Up @@ -146,9 +144,6 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
return;
}
this._commandFinishedListener = capability.onCommandFinished(command => {
if (this._placeholderDecoration?.marker.id) {
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
this._decorations.delete(this._placeholderDecoration?.marker.id);
}
if (command.command.trim().toLowerCase() === 'clear' || command.command.trim().toLowerCase() === 'cls') {
this.clearDecorations();
return;
Expand All @@ -167,12 +162,12 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
if (!command.marker) {
throw new Error(`cannot add a decoration for a command ${JSON.stringify(command)} with no marker`);
}

const decoration = this._terminal.registerDecoration({ marker: command.marker });
if (!decoration) {
return undefined;
}
decoration.onRender(element => {
decoration.onDispose(() => this._decorations.delete(decoration.marker.id));
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
if (beforeCommandExecution && !this._placeholderDecoration) {
this._placeholderDecoration = decoration;
} else {
Expand All @@ -183,9 +178,8 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
exitCode: command.exitCode
});
}

if (!element.classList.contains(DecorationSelector.Codicon)) {
// first render
if (!element.classList.contains(DecorationSelector.Codicon) || command.marker?.line === 0) {
// first render or buffer was cleared
this._updateLayout(element);
this._updateClasses(element, command.exitCode);
}
Expand Down Expand Up @@ -218,7 +212,6 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
element.classList.remove(classes);
}
element.classList.add(DecorationSelector.CommandDecoration, DecorationSelector.Codicon, DecorationSelector.XtermDecoration);
element.parentElement?.parentElement?.parentElement?.classList.add(DecorationSelector.ShellIntegration);
if (exitCode === undefined) {
element.classList.add(DecorationSelector.DefaultColor);
element.classList.add(`codicon-${this._configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationIcon)}`);
Expand Down
Expand Up @@ -316,6 +316,8 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal {

clearBuffer(): void {
this.raw.clear();
// hack so that the next placeholder shows
this._decorationAddon?.registerCommandDecoration({ marker: this.raw.registerMarker(0), hasOutput: false, timestamp: Date.now(), getOutput: () => { return undefined; }, command: '' }, true);
}

private _setCursorBlink(blink: boolean): void {
Expand Down