rename suggestions: add hover to generate/cancel button

fixes https://github.com/microsoft/vscode-copilot/issues/5261
This commit is contained in:
Ulugbek Abdullaev 2024-04-24 13:41:37 +05:00
parent 38e2814f92
commit 69d27c5e4e
No known key found for this signature in database
GPG key ID: 4F1AB80F62B8E4A4

View file

@ -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();
}