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

Remove tree view show hover #213212

Merged
merged 1 commit into from
May 23, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 3 additions & 58 deletions src/vs/workbench/api/browser/viewsExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,21 @@ import { localize } from 'vs/nls';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { ExtensionIdentifier, ExtensionIdentifierSet, IExtensionDescription, IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { Registry } from 'vs/platform/registry/common/platform';
import { ThemeIcon } from 'vs/base/common/themables';
import { Extensions as ViewletExtensions, PaneCompositeRegistry } from 'vs/workbench/browser/panecomposite';
import { CustomTreeView, RawCustomTreeViewContextKey, TreeViewPane } from 'vs/workbench/browser/parts/views/treeView';
import { CustomTreeView, TreeViewPane } from 'vs/workbench/browser/parts/views/treeView';
import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { IWorkbenchContribution, WorkbenchPhase, registerWorkbenchContribution2 } from 'vs/workbench/common/contributions';
import { Extensions as ViewContainerExtensions, ICustomViewDescriptor, IViewContainersRegistry, IViewDescriptor, IViewsRegistry, ResolvableTreeItem, ViewContainer, ViewContainerLocation } from 'vs/workbench/common/views';
import { Extensions as ViewContainerExtensions, ICustomViewDescriptor, IViewContainersRegistry, IViewDescriptor, IViewsRegistry, ViewContainer, ViewContainerLocation } from 'vs/workbench/common/views';
import { VIEWLET_ID as DEBUG } from 'vs/workbench/contrib/debug/common/debug';
import { VIEWLET_ID as EXPLORER } from 'vs/workbench/contrib/files/common/files';
import { VIEWLET_ID as REMOTE } from 'vs/workbench/contrib/remote/browser/remoteExplorer';
import { VIEWLET_ID as SCM } from 'vs/workbench/contrib/scm/common/scm';
import { WebviewViewPane } from 'vs/workbench/contrib/webviewView/browser/webviewViewPane';
import { isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
import { ExtensionMessageCollector, ExtensionsRegistry, IExtensionPoint, IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { IListService, WorkbenchListFocusContextKey } from 'vs/platform/list/browser/listService';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { AsyncDataTree } from 'vs/base/browser/ui/tree/asyncDataTree';
import { ITreeViewsService } from 'vs/workbench/services/views/browser/treeViewsService';
import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import { ILogService } from 'vs/platform/log/common/log';
import { IExtensionFeatureTableRenderer, IRenderedData, ITableData, IRowData, IExtensionFeaturesRegistry, Extensions as ExtensionFeaturesRegistryExtensions } from 'vs/workbench/services/extensionManagement/common/extensionFeatures';
import { Disposable } from 'vs/base/common/lifecycle';
Expand Down Expand Up @@ -291,53 +283,6 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
this.viewsRegistry = Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry);
this.handleAndRegisterCustomViewContainers();
this.handleAndRegisterCustomViews();

// Abstract tree has it's own implementation of triggering custom hover
// TreeView uses it's own implementation due to setting focus inside the (markdown)
let showTreeHoverCancellation = new CancellationTokenSource();
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.showTreeHover',
handler: async (accessor: ServicesAccessor, ...args: any[]) => {
showTreeHoverCancellation.cancel();
showTreeHoverCancellation = new CancellationTokenSource();
const listService = accessor.get(IListService);
const treeViewsService = accessor.get(ITreeViewsService);
const hoverService = accessor.get(IHoverService);
const lastFocusedList = listService.lastFocusedList;
if (!(lastFocusedList instanceof AsyncDataTree)) {
return;
}
const focus = lastFocusedList.getFocus();
if (!focus || (focus.length === 0)) {
return;
}
const treeItem = focus[0];

if (treeItem instanceof ResolvableTreeItem) {
await treeItem.resolve(showTreeHoverCancellation.token);
}
if (!treeItem.tooltip) {
return;
}
const element = treeViewsService.getRenderedTreeElement(('handle' in treeItem) ? treeItem.handle : treeItem);
if (!element) {
return;
}
hoverService.showHover({
content: treeItem.tooltip,
target: element,
position: {
hoverPosition: HoverPosition.BELOW,
},
persistence: {
hideOnHover: false
}
}, true);
},
weight: KeybindingWeight.WorkbenchContrib + 1,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyI),
when: ContextKeyExpr.and(RawCustomTreeViewContextKey, WorkbenchListFocusContextKey)
});
}

private handleAndRegisterCustomViewContainers() {
Expand Down
25 changes: 19 additions & 6 deletions src/vs/workbench/browser/actions/listCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,16 +723,29 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
return;
}

// Check if the focused element has a hover, otherwise find the first child with a hover
const elementWithHover = focusedElement.matches('[custom-hover="true"]') ? focusedElement : focusedElement.querySelector('[custom-hover="true"]');
if (!elementWithHover) {
return;
const elementWithHover = getCustomHoverForElement(focusedElement as HTMLElement);
if (elementWithHover) {
accessor.get(IHoverService).triggerUpdatableHover(elementWithHover as HTMLElement);
}

accessor.get(IHoverService).triggerUpdatableHover(elementWithHover as HTMLElement);
},
});

function getCustomHoverForElement(element: HTMLElement): HTMLElement | undefined {
// Check if the element itself has a hover
if (element.matches('[custom-hover="true"]')) {
return element;
}

// Only consider children that are not action items or have a tabindex
// as these element are focusable and the user is able to trigger them already
const noneFocusableElementWithHover = element.querySelector('[custom-hover="true"]:not([tabindex]):not(.action-item)');
if (noneFocusableElementWithHover) {
return noneFocusableElementWithHover as HTMLElement;
}

return undefined;
}

KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.toggleExpand',
weight: KeybindingWeight.WorkbenchContrib,
Expand Down
5 changes: 0 additions & 5 deletions src/vs/workbench/browser/parts/views/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import { Extensions, ITreeItem, ITreeItemLabel, ITreeView, ITreeViewDataProvider
import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IHoverService, WorkbenchHoverDelegate } from 'vs/platform/hover/browser/hover';
import { ITreeViewsService } from 'vs/workbench/services/views/browser/treeViewsService';
import { CodeDataTransfers, LocalSelectionTransfer } from 'vs/platform/dnd/browser/dnd';
import { toExternalVSDataTransfer } from 'vs/editor/browser/dnd';
import { CheckboxStateHandler, TreeItemCheckbox } from 'vs/workbench/browser/parts/views/checkbox';
Expand Down Expand Up @@ -1168,7 +1167,6 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
@IThemeService private readonly themeService: IThemeService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@ILabelService private readonly labelService: ILabelService,
@ITreeViewsService private readonly treeViewsService: ITreeViewsService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IHoverService private readonly hoverService: IHoverService,
@IInstantiationService instantiationService: IInstantiationService,
Expand Down Expand Up @@ -1326,7 +1324,6 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
templateData.actionBar.actionRunner = this._actionRunner;
}
this.setAlignment(templateData.container, node);
this.treeViewsService.addRenderedTreeItemElement(node.handle, templateData.container);

// remember rendered element, an element can be rendered multiple times
const renderedItems = this._renderedElements.get(element.element.handle) ?? [];
Expand Down Expand Up @@ -1487,8 +1484,6 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
itemRenders.splice(renderedIndex, 1);
}

this.treeViewsService.removeRenderedTreeItemElement(resource.element.handle);

templateData.checkbox?.dispose();
templateData.checkbox = undefined;
}
Expand Down
12 changes: 0 additions & 12 deletions src/vs/workbench/services/views/browser/treeViewsService.ts

This file was deleted.

34 changes: 0 additions & 34 deletions src/vs/workbench/services/views/common/treeViewsService.ts

This file was deleted.

Loading