From 69d27c5e4e16b69f80e58cdaae2059fddbfce6ec Mon Sep 17 00:00:00 2001 From: Ulugbek Abdullaev Date: Wed, 24 Apr 2024 13:41:37 +0500 Subject: [PATCH] rename suggestions: add hover to generate/cancel button fixes https://github.com/microsoft/vscode-copilot/issues/5261 --- .../contrib/rename/browser/renameWidget.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/vs/editor/contrib/rename/browser/renameWidget.ts b/src/vs/editor/contrib/rename/browser/renameWidget.ts index 14d09e73259..0f8a9ed3af7 100644 --- a/src/vs/editor/contrib/rename/browser/renameWidget.ts +++ b/src/vs/editor/contrib/rename/browser/renameWidget.ts @@ -6,6 +6,9 @@ import * as dom from 'vs/base/browser/dom'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import * as aria from 'vs/base/browser/ui/aria/aria'; +import { IUpdatableHover } from 'vs/base/browser/ui/hover/hover'; +import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2'; +import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory'; import { renderIcon } from 'vs/base/browser/ui/iconLabel/iconLabels'; import { IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list'; import { List } from 'vs/base/browser/ui/list/listWidget'; @@ -28,6 +31,7 @@ import { Position } from 'vs/editor/common/core/position'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ScrollType } from 'vs/editor/common/editorCommon'; import { NewSymbolName, NewSymbolNameTag, NewSymbolNameTriggerKind, ProviderResult } from 'vs/editor/common/languages'; +import * as nls from 'vs/nls'; import { localize } from 'vs/nls'; import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; @@ -869,6 +873,9 @@ class InputWithButton implements IDisposable { private _domNode: HTMLDivElement | undefined; private _inputNode: HTMLInputElement | undefined; private _buttonNode: HTMLElement | undefined; + private _buttonHover: IUpdatableHover | undefined; + private _buttonGenHoverText: string | undefined; + private _buttonCancelHoverText: string | undefined; private _sparkleIcon: HTMLElement | undefined; private _stopIcon: HTMLElement | undefined; @@ -903,6 +910,11 @@ class InputWithButton implements IDisposable { this._buttonNode.style.borderRadius = '5px'; this._buttonNode.setAttribute('tabindex', '0'); + this._buttonGenHoverText = nls.localize('generateRenameSuggestionsButton', "Generate new name suggestions"); + this._buttonCancelHoverText = nls.localize('cancelRenameSuggestionsButton', "Cancel"); + this._buttonHover = getBaseLayerHoverDelegate().setupUpdatableHover(getDefaultHoverDelegate('element'), this._buttonNode, this._buttonGenHoverText); + this._disposables.add(this._buttonHover); + this._domNode.appendChild(this._buttonNode); // notify if selection changes to cancel request to rename-suggestion providers @@ -950,6 +962,8 @@ class InputWithButton implements IDisposable { this._sparkleIcon ??= renderIcon(Codicon.sparkle); dom.clearNode(this.button); this.button.appendChild(this._sparkleIcon); + this.button.setAttribute('aria-label', 'Generating new name suggestions'); + this._buttonHover?.update(this._buttonGenHoverText); this.input.focus(); } @@ -958,6 +972,8 @@ class InputWithButton implements IDisposable { this._stopIcon ??= renderIcon(Codicon.primitiveSquare); dom.clearNode(this.button); this.button.appendChild(this._stopIcon); + this.button.setAttribute('aria-label', 'Cancel generating new name suggestions'); + this._buttonHover?.update(this._buttonCancelHoverText); this.input.focus(); }