Skip to content

Commit f752545

Browse files
authored
Merge pull request microsoft#211260 from microsoft/ulugbekna/rename-ftw
Fix rename suggestions UI inconsistencies
2 parents 289d7b7 + 4be6ff5 commit f752545

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@
2828
outline: none;
2929
}
3030

31+
.monaco-editor .rename-box .rename-suggestions-button {
32+
display: flex;
33+
align-items: center;
34+
padding: 3px;
35+
background-color: transparent;
36+
border: none;
37+
border-radius: 5px;
38+
cursor: pointer;
39+
}
40+
41+
.monaco-editor .rename-box .rename-suggestions-button:hover {
42+
background-color: var(--vscode-toolbar-hoverBackground)
43+
}
44+
45+
.monaco-editor .rename-box .rename-candidate-list-container .monaco-list-row {
46+
border-radius: 2px;
47+
}
48+
3149
.monaco-editor .rename-box .rename-label {
3250
display: none;
3351
opacity: .8;

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

Lines changed: 23 additions & 6 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';
@@ -366,6 +370,9 @@ export class RenameWidget implements IRenameWidget, IContentWidget, IDisposable
366370
}
367371
}
368372

373+
/**
374+
* @param requestRenameCandidates is `undefined` when there are no rename suggestion providers
375+
*/
369376
getInput(
370377
where: IRange,
371378
currentName: string,
@@ -522,6 +529,7 @@ export class RenameWidget implements IRenameWidget, IContentWidget, IDisposable
522529
const candidates = this._requestRenameCandidatesOnce(triggerKind, this._renameCandidateProvidersCts.token);
523530

524531
if (candidates.length === 0) {
532+
this._inputWithButton.setSparkleButton();
525533
return;
526534
}
527535

@@ -659,6 +667,7 @@ class RenameCandidateListView {
659667
this._typicalHalfwidthCharacterWidth = opts.fontInfo.typicalHalfwidthCharacterWidth;
660668

661669
this._listContainer = document.createElement('div');
670+
this._listContainer.className = 'rename-box rename-candidate-list-container';
662671
parent.appendChild(this._listContainer);
663672

664673
this._listWidget = RenameCandidateListView._createListWidget(this._listContainer, this._candidateViewHeight, opts.fontInfo);
@@ -869,6 +878,9 @@ class InputWithButton implements IDisposable {
869878
private _domNode: HTMLDivElement | undefined;
870879
private _inputNode: HTMLInputElement | undefined;
871880
private _buttonNode: HTMLElement | undefined;
881+
private _buttonHover: IUpdatableHover | undefined;
882+
private _buttonGenHoverText: string | undefined;
883+
private _buttonCancelHoverText: string | undefined;
872884
private _sparkleIcon: HTMLElement | undefined;
873885
private _stopIcon: HTMLElement | undefined;
874886

@@ -895,14 +907,14 @@ class InputWithButton implements IDisposable {
895907
this._domNode.appendChild(this._inputNode);
896908

897909
this._buttonNode = document.createElement('div');
898-
this._buttonNode.style.display = 'flex';
899-
this._buttonNode.style.alignItems = 'center';
900-
this._buttonNode.style.padding = '3px';
901-
this._buttonNode.style.backgroundColor = 'transparent';
902-
this._buttonNode.style.border = 'none';
903-
this._buttonNode.style.borderRadius = '5px';
910+
this._buttonNode.className = 'rename-suggestions-button';
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

@@ -977,6 +993,7 @@ class RenameCandidateView {
977993
constructor(parent: HTMLElement, fontInfo: FontInfo) {
978994

979995
this._domNode = document.createElement('div');
996+
this._domNode.className = 'rename-box rename-candidate';
980997
this._domNode.style.display = `flex`;
981998
this._domNode.style.columnGap = `5px`;
982999
this._domNode.style.alignItems = `center`;

0 commit comments

Comments
 (0)