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

Polish explorer tooltip rendering #174085

Merged
merged 9 commits into from
Feb 14, 2023
5 changes: 3 additions & 2 deletions src/vs/base/browser/ui/iconLabel/iconLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IMatch } from 'vs/base/common/filters';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { equals } from 'vs/base/common/objects';
import { Range } from 'vs/base/common/range';
import { withNullAsUndefined } from 'vs/base/common/types';

export interface IIconLabelCreationOptions {
readonly supportHighlights?: boolean;
Expand All @@ -21,7 +22,7 @@ export interface IIconLabelCreationOptions {
}

export interface IIconLabelValueOptions {
title?: string | ITooltipMarkdownString;
title?: string | ITooltipMarkdownString | null;
descriptionTitle?: string;
hideIcon?: boolean;
extraClasses?: readonly string[];
Expand Down Expand Up @@ -140,7 +141,7 @@ export class IconLabel extends Disposable {

this.domNode.className = labelClasses.join(' ');
this.labelContainer.className = containerClasses.join(' ');
this.setupHover(options?.descriptionTitle ? this.labelContainer : this.element, options?.title);
this.setupHover(options?.descriptionTitle ? this.labelContainer : this.element, withNullAsUndefined(options?.title));

this.nameNode.setLabel(label, options);

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,9 @@ class ResourceLabelWidget extends IconLabel {
this.computedPathLabel = this.labelService.getUriLabel(resource);
}

if (!iconLabelOptions.title || (typeof iconLabelOptions.title === 'string')) {
if (iconLabelOptions.title === undefined || (typeof iconLabelOptions.title === 'string')) {
iconLabelOptions.title = this.computedPathLabel;
} else if (!iconLabelOptions.title.markdownNotSupportedFallback) {
} else if (iconLabelOptions.title && !iconLabelOptions.title.markdownNotSupportedFallback) {
iconLabelOptions.title.markdownNotSupportedFallback = this.computedPathLabel;
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/files/browser/files.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ configurationRegistry.registerConfiguration({
'description': nls.localize('expandSingleFolderWorkspaces', "Controls whether the Explorer should expand multi-root workspaces containing only one folder during initialization"),
'default': true
},
'explorer.renderTooltip': {
'type': 'boolean',
'description': nls.localize('explorer.renderTooltip', "Controls whether the Explorer should render the tooltip containing the full path on hover."),
'default': true
},
'explorer.sortOrder': {
'type': 'string',
'enum': [SortOrder.Default, SortOrder.Mixed, SortOrder.FilesFirst, SortOrder.Type, SortOrder.Modified, SortOrder.FoldersNestsFiles],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
this.configListener = this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('explorer')) {
this.config = this.configurationService.getValue();
if (e.affectsConfiguration('explorer.renderTooltip')) {
this.explorerService.refresh();
}
}
if (e.affectsConfiguration('workbench.tree.indent')) {
updateOffsetStyles();
Expand Down Expand Up @@ -417,6 +420,8 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
const realignNestedChildren = stat.nestedParent && themeIsUnhappyWithNesting;

templateData.label.setResource({ resource: stat.resource, name: label }, {
// We use null to indicate an explicit lack of tooltip vs undefined leaves it up to computation later in the rendering
title: this.config.explorer.renderTooltip ? undefined : null,
fileKind: stat.isRoot ? FileKind.ROOT_FOLDER : stat.isDirectory ? FileKind.FOLDER : FileKind.FILE,
extraClasses: realignNestedChildren ? [...extraClasses, 'align-nest-icon-with-parent-icon'] : extraClasses,
fileDecorations: this.config.explorer.decorations,
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/files/common/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface IFilesConfiguration extends PlatformIFilesConfiguration, IWorkb
enableUndo: boolean;
confirmUndo: UndoConfirmLevel;
expandSingleFolderWorkspaces: boolean;
renderTooltip: boolean;
sortOrder: SortOrder;
sortOrderLexicographicOptions: LexicographicOptions;
decorations: {
Expand Down