6
6
import * as dom from 'vs/base/browser/dom' ;
7
7
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent' ;
8
8
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' ;
9
12
import { renderIcon } from 'vs/base/browser/ui/iconLabel/iconLabels' ;
10
13
import { IListRenderer , IListVirtualDelegate } from 'vs/base/browser/ui/list/list' ;
11
14
import { List } from 'vs/base/browser/ui/list/listWidget' ;
@@ -28,6 +31,7 @@ import { Position } from 'vs/editor/common/core/position';
28
31
import { IRange , Range } from 'vs/editor/common/core/range' ;
29
32
import { ScrollType } from 'vs/editor/common/editorCommon' ;
30
33
import { NewSymbolName , NewSymbolNameTag , NewSymbolNameTriggerKind , ProviderResult } from 'vs/editor/common/languages' ;
34
+ import * as nls from 'vs/nls' ;
31
35
import { localize } from 'vs/nls' ;
32
36
import { IContextKey , IContextKeyService , RawContextKey } from 'vs/platform/contextkey/common/contextkey' ;
33
37
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
@@ -366,6 +370,9 @@ export class RenameWidget implements IRenameWidget, IContentWidget, IDisposable
366
370
}
367
371
}
368
372
373
+ /**
374
+ * @param requestRenameCandidates is `undefined` when there are no rename suggestion providers
375
+ */
369
376
getInput (
370
377
where : IRange ,
371
378
currentName : string ,
@@ -522,6 +529,7 @@ export class RenameWidget implements IRenameWidget, IContentWidget, IDisposable
522
529
const candidates = this . _requestRenameCandidatesOnce ( triggerKind , this . _renameCandidateProvidersCts . token ) ;
523
530
524
531
if ( candidates . length === 0 ) {
532
+ this . _inputWithButton . setSparkleButton ( ) ;
525
533
return ;
526
534
}
527
535
@@ -659,6 +667,7 @@ class RenameCandidateListView {
659
667
this . _typicalHalfwidthCharacterWidth = opts . fontInfo . typicalHalfwidthCharacterWidth ;
660
668
661
669
this . _listContainer = document . createElement ( 'div' ) ;
670
+ this . _listContainer . className = 'rename-box rename-candidate-list-container' ;
662
671
parent . appendChild ( this . _listContainer ) ;
663
672
664
673
this . _listWidget = RenameCandidateListView . _createListWidget ( this . _listContainer , this . _candidateViewHeight , opts . fontInfo ) ;
@@ -869,6 +878,9 @@ class InputWithButton implements IDisposable {
869
878
private _domNode : HTMLDivElement | undefined ;
870
879
private _inputNode : HTMLInputElement | undefined ;
871
880
private _buttonNode : HTMLElement | undefined ;
881
+ private _buttonHover : IUpdatableHover | undefined ;
882
+ private _buttonGenHoverText : string | undefined ;
883
+ private _buttonCancelHoverText : string | undefined ;
872
884
private _sparkleIcon : HTMLElement | undefined ;
873
885
private _stopIcon : HTMLElement | undefined ;
874
886
@@ -895,14 +907,14 @@ class InputWithButton implements IDisposable {
895
907
this . _domNode . appendChild ( this . _inputNode ) ;
896
908
897
909
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' ;
904
911
this . _buttonNode . setAttribute ( 'tabindex' , '0' ) ;
905
912
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
+
906
918
this . _domNode . appendChild ( this . _buttonNode ) ;
907
919
908
920
// notify if selection changes to cancel request to rename-suggestion providers
@@ -950,6 +962,8 @@ class InputWithButton implements IDisposable {
950
962
this . _sparkleIcon ??= renderIcon ( Codicon . sparkle ) ;
951
963
dom . clearNode ( this . button ) ;
952
964
this . button . appendChild ( this . _sparkleIcon ) ;
965
+ this . button . setAttribute ( 'aria-label' , 'Generating new name suggestions' ) ;
966
+ this . _buttonHover ?. update ( this . _buttonGenHoverText ) ;
953
967
this . input . focus ( ) ;
954
968
}
955
969
@@ -958,6 +972,8 @@ class InputWithButton implements IDisposable {
958
972
this . _stopIcon ??= renderIcon ( Codicon . primitiveSquare ) ;
959
973
dom . clearNode ( this . button ) ;
960
974
this . button . appendChild ( this . _stopIcon ) ;
975
+ this . button . setAttribute ( 'aria-label' , 'Cancel generating new name suggestions' ) ;
976
+ this . _buttonHover ?. update ( this . _buttonCancelHoverText ) ;
961
977
this . input . focus ( ) ;
962
978
}
963
979
@@ -977,6 +993,7 @@ class RenameCandidateView {
977
993
constructor ( parent : HTMLElement , fontInfo : FontInfo ) {
978
994
979
995
this . _domNode = document . createElement ( 'div' ) ;
996
+ this . _domNode . className = 'rename-box rename-candidate' ;
980
997
this . _domNode . style . display = `flex` ;
981
998
this . _domNode . style . columnGap = `5px` ;
982
999
this . _domNode . style . alignItems = `center` ;
0 commit comments