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

improve decorations #143130

Merged
merged 7 commits into from
Feb 15, 2022
Merged
Changes from 5 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
17 changes: 11 additions & 6 deletions src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ const enum DecorationSelector {
ErrorColor = 'error',
SkippedColor = 'skipped',
Codicon = 'codicon',
XtermScreen = 'xterm-screen'
}

const enum DecorationStyles { ButtonMargin = 4 }
const enum DecorationStyles {
CodiconDimension = 10
}

interface IDisposableDecoration { decoration: IDecoration; disposables: IDisposable[] }

Expand Down Expand Up @@ -121,8 +124,9 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
this._decorations.set(decoration.marker.id, { decoration, disposables });
}
if (decoration.element?.clientWidth! > 0) {
const marginWidth = ((decoration.element?.parentElement?.parentElement?.previousElementSibling?.clientWidth || 0) - (decoration.element?.parentElement?.parentElement?.clientWidth || 0)) * .5;
target.style.marginLeft = `${((marginWidth - (decoration.element!.clientWidth + DecorationStyles.ButtonMargin)) * .5) - marginWidth}px`;
// if this is the leftmost terminal, there is extra room
const marginWidth = document.querySelectorAll(`.${DecorationSelector.XtermScreen}`)[0] === decoration.element?.parentElement?.parentElement ? 15 : 10;
target.style.marginLeft = `${-marginWidth - 2}px`;
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
target.classList.add(DecorationSelector.CommandDecoration);
target.classList.add(DecorationSelector.Codicon);
if (command.exitCode === undefined) {
Expand All @@ -135,8 +139,9 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
} else {
target.classList.add(`codicon-${this._configurationService.getValue(TerminalSettingId.CommandIcon)}`);
}
target.style.width = `${marginWidth}px`;
target.style.height = `${marginWidth}px`;
// the left gutter of the terminal is a mininum of 10px, so use that for uniformity
target.style.width = `${DecorationStyles.CodiconDimension}px`;
target.style.height = `${DecorationStyles.CodiconDimension}px`;
}
});
return decoration;
Expand Down Expand Up @@ -199,5 +204,5 @@ registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) =
const commandDecorationSkippedColor = theme.getColor(TERMINAL_COMMAND_DECORATION_SKIPPED_BACKGROUND_COLOR);
collector.addRule(`.${DecorationSelector.CommandDecoration}.${DecorationSelector.SkippedColor} { color: ${commandDecorationSkippedColor ? commandDecorationSkippedColor.toString() : ''}; } `);
const toolbarHoverBackgroundColor = theme.getColor(toolbarHoverBackground);
collector.addRule(`.${DecorationSelector.CommandDecoration}:not(.${DecorationSelector.SkippedColor}):hover { background-color: ${toolbarHoverBackgroundColor ? toolbarHoverBackgroundColor.toString() : ''}; }`);
collector.addRule(`.${DecorationSelector.CommandDecoration}:not(.${DecorationSelector.SkippedColor}):hover { background-color: ${toolbarHoverBackgroundColor ? toolbarHoverBackgroundColor.toString() : ''}; border-radius: 5px; }`);
});