mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Merge pull request #186590 from microsoft/tyriar/177774
Move single terminal tab to hover service
This commit is contained in:
@@ -40,11 +40,13 @@ import { getColorClass, getUriClasses } from 'vs/workbench/contrib/terminal/brow
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { getTerminalActionBarArgs } from 'vs/workbench/contrib/terminal/browser/terminalMenus';
|
||||
import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
|
||||
import { getShellIntegrationTooltip, getShellProcessTooltip } from 'vs/workbench/contrib/terminal/browser/terminalTooltip';
|
||||
import { getInstanceHoverInfo } from 'vs/workbench/contrib/terminal/browser/terminalTooltip';
|
||||
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { defaultSelectBoxStyles } from 'vs/platform/theme/browser/defaultStyles';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IHoverDelegate, IHoverDelegateOptions } from 'vs/base/browser/ui/iconLabel/iconHoverDelegate';
|
||||
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
|
||||
|
||||
export class TerminalViewPane extends ViewPane {
|
||||
private _fontStyleElement: HTMLElement | undefined;
|
||||
@@ -351,7 +353,10 @@ class SingleTerminalTabActionViewItem extends MenuEntryActionViewItem {
|
||||
@ICommandService private readonly _commandService: ICommandService,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
) {
|
||||
super(action, { draggable: true }, keybindingService, notificationService, contextKeyService, themeService, contextMenuService);
|
||||
super(action, {
|
||||
draggable: true,
|
||||
hoverDelegate: _instantiationService.createInstance(SingleTabHoverDelegate)
|
||||
}, keybindingService, notificationService, contextKeyService, themeService, contextMenuService);
|
||||
|
||||
// Register listeners to update the tab
|
||||
this._register(Event.debounce<ITerminalInstance | undefined, Set<ITerminalInstance>>(Event.any(
|
||||
@@ -468,7 +473,6 @@ class SingleTerminalTabActionViewItem extends MenuEntryActionViewItem {
|
||||
this._altCommand = `alt-command`;
|
||||
label.classList.add(this._altCommand);
|
||||
}
|
||||
this._action.tooltip = getSingleTabTooltip(instance, this._terminalService.configHelper.config.tabs.separator);
|
||||
this.updateTooltip();
|
||||
}
|
||||
}
|
||||
@@ -498,16 +502,6 @@ function getSingleTabLabel(accessor: ServicesAccessor, instance: ITerminalInstan
|
||||
return `${label} $(${primaryStatus.icon.id})`;
|
||||
}
|
||||
|
||||
function getSingleTabTooltip(instance: ITerminalInstance | undefined, separator: string): string {
|
||||
if (!instance) {
|
||||
return '';
|
||||
}
|
||||
const parts: string[] = [];
|
||||
parts.push(getSingleTabTitle(instance, separator) + getShellProcessTooltip(instance, false) + getShellIntegrationTooltip(instance, false));
|
||||
parts.push(instance.statusList.primary?.tooltip || '');
|
||||
return parts.filter(e => e).join('\n\n');
|
||||
}
|
||||
|
||||
function getSingleTabTitle(instance: ITerminalInstance | undefined, separator: string): string {
|
||||
if (!instance) {
|
||||
return '';
|
||||
@@ -585,3 +579,39 @@ class TerminalThemeIconStyle extends Themable {
|
||||
this._styleElement.textContent = css;
|
||||
}
|
||||
}
|
||||
|
||||
class SingleTabHoverDelegate implements IHoverDelegate {
|
||||
private _lastHoverHideTime: number = 0;
|
||||
|
||||
readonly placement = 'element';
|
||||
|
||||
constructor(
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||
@IHoverService private readonly _hoverService: IHoverService,
|
||||
@ITerminalGroupService private readonly _terminalGroupService: ITerminalGroupService
|
||||
) {
|
||||
}
|
||||
|
||||
get delay(): number {
|
||||
return Date.now() - this._lastHoverHideTime < 200
|
||||
? 0 // show instantly when a hover was recently shown
|
||||
: this._configurationService.getValue<number>('workbench.hover.delay');
|
||||
}
|
||||
|
||||
showHover(options: IHoverDelegateOptions, focus?: boolean) {
|
||||
const instance = this._terminalGroupService.activeInstance;
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
const hoverInfo = getInstanceHoverInfo(instance);
|
||||
return this._hoverService.showHover({
|
||||
...options,
|
||||
content: hoverInfo.content,
|
||||
actions: hoverInfo.actions
|
||||
}, focus);
|
||||
}
|
||||
|
||||
onDidHideHover() {
|
||||
this._lastHoverHideTime = Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user