Skip to content

Commit 69d27c5

Browse files
committed
rename suggestions: add hover to generate/cancel button
fixes microsoft/vscode-copilot#5261
1 parent 38e2814 commit 69d27c5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/vs/editor/contrib/rename/browser/renameWidget.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import * as dom from 'vs/base/browser/dom';
77
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
88
import * as aria from 'vs/base/browser/ui/aria/aria';
9+
import { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
10+
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
11+
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
912
import { renderIcon } from 'vs/base/browser/ui/iconLabel/iconLabels';
1013
import { IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
1114
import { List } from 'vs/base/browser/ui/list/listWidget';
@@ -28,6 +31,7 @@ import { Position } from 'vs/editor/common/core/position';
2831
import { IRange, Range } from 'vs/editor/common/core/range';
2932
import { ScrollType } from 'vs/editor/common/editorCommon';
3033
import { NewSymbolName, NewSymbolNameTag, NewSymbolNameTriggerKind, ProviderResult } from 'vs/editor/common/languages';
34+
import * as nls from 'vs/nls';
3135
import { localize } from 'vs/nls';
3236
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
3337
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
@@ -869,6 +873,9 @@ class InputWithButton implements IDisposable {
869873
private _domNode: HTMLDivElement | undefined;
870874
private _inputNode: HTMLInputElement | undefined;
871875
private _buttonNode: HTMLElement | undefined;
876+
private _buttonHover: IUpdatableHover | undefined;
877+
private _buttonGenHoverText: string | undefined;
878+
private _buttonCancelHoverText: string | undefined;
872879
private _sparkleIcon: HTMLElement | undefined;
873880
private _stopIcon: HTMLElement | undefined;
874881

@@ -903,6 +910,11 @@ class InputWithButton implements IDisposable {
903910
this._buttonNode.style.borderRadius = '5px';
904911
this._buttonNode.setAttribute('tabindex', '0');
905912

913+
this._buttonGenHoverText = nls.localize('generateRenameSuggestionsButton', "Generate new name suggestions");
914+
this._buttonCancelHoverText = nls.localize('cancelRenameSuggestionsButton', "Cancel");
915+
this._buttonHover = getBaseLayerHoverDelegate().setupUpdatableHover(getDefaultHoverDelegate('element'), this._buttonNode, this._buttonGenHoverText);
916+
this._disposables.add(this._buttonHover);
917+
906918
this._domNode.appendChild(this._buttonNode);
907919

908920
// notify if selection changes to cancel request to rename-suggestion providers
@@ -950,6 +962,8 @@ class InputWithButton implements IDisposable {
950962
this._sparkleIcon ??= renderIcon(Codicon.sparkle);
951963
dom.clearNode(this.button);
952964
this.button.appendChild(this._sparkleIcon);
965+
this.button.setAttribute('aria-label', 'Generating new name suggestions');
966+
this._buttonHover?.update(this._buttonGenHoverText);
953967
this.input.focus();
954968
}
955969

@@ -958,6 +972,8 @@ class InputWithButton implements IDisposable {
958972
this._stopIcon ??= renderIcon(Codicon.primitiveSquare);
959973
dom.clearNode(this.button);
960974
this.button.appendChild(this._stopIcon);
975+
this.button.setAttribute('aria-label', 'Cancel generating new name suggestions');
976+
this._buttonHover?.update(this._buttonCancelHoverText);
961977
this.input.focus();
962978
}
963979

0 commit comments

Comments
 (0)