@@ -11,20 +11,23 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
1111import { DisposableStore } from 'vs/base/common/lifecycle' ;
1212import { assertType } from 'vs/base/common/types' ;
1313import { URI } from 'vs/base/common/uri' ;
14- import { CodeEditorStateFlag , EditorStateCancellationTokenSource } from 'vs/editor/contrib/editorState/browser/editorState' ;
1514import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
16- import { EditorAction , EditorCommand , EditorContributionInstantiation , registerEditorAction , registerEditorCommand , registerEditorContribution , registerModelAndPositionCommand , ServicesAccessor } from 'vs/editor/browser/editorExtensions' ;
15+ import { EditorAction , EditorCommand , EditorContributionInstantiation , ServicesAccessor , registerEditorAction , registerEditorCommand , registerEditorContribution , registerModelAndPositionCommand } from 'vs/editor/browser/editorExtensions' ;
1716import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService' ;
1817import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
1918import { IPosition , Position } from 'vs/editor/common/core/position' ;
2019import { Range } from 'vs/editor/common/core/range' ;
2120import { IEditorContribution } from 'vs/editor/common/editorCommon' ;
2221import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
22+ import { LanguageFeatureRegistry } from 'vs/editor/common/languageFeatureRegistry' ;
23+ import { NewSymbolName , Rejection , RenameLocation , RenameProvider , WorkspaceEdit } from 'vs/editor/common/languages' ;
2324import { ITextModel } from 'vs/editor/common/model' ;
24- import { Rejection , RenameLocation , RenameProvider , WorkspaceEdit } from 'vs/editor/common/languages ' ;
25+ import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures ' ;
2526import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfiguration' ;
27+ import { CodeEditorStateFlag , EditorStateCancellationTokenSource } from 'vs/editor/contrib/editorState/browser/editorState' ;
2628import { MessageController } from 'vs/editor/contrib/message/browser/messageController' ;
2729import * as nls from 'vs/nls' ;
30+ import { Action2 , registerAction2 } from 'vs/platform/actions/common/actions' ;
2831import { ConfigurationScope , Extensions , IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry' ;
2932import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
3033import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
@@ -33,9 +36,7 @@ import { ILogService } from 'vs/platform/log/common/log';
3336import { INotificationService } from 'vs/platform/notification/common/notification' ;
3437import { IEditorProgressService } from 'vs/platform/progress/common/progress' ;
3538import { Registry } from 'vs/platform/registry/common/platform' ;
36- import { CONTEXT_RENAME_INPUT_VISIBLE , RenameInputField } from './renameInputField' ;
37- import { LanguageFeatureRegistry } from 'vs/editor/common/languageFeatureRegistry' ;
38- import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures' ;
39+ import { CONTEXT_RENAME_INPUT_FOCUSED , CONTEXT_RENAME_INPUT_VISIBLE , RenameInputField } from './renameInputField' ;
3940
4041class RenameSkeleton {
4142
@@ -213,7 +214,7 @@ class RenameController implements IEditorContribution {
213214 this . _languageFeaturesService . newSymbolNamesProvider
214215 . all ( model )
215216 . map ( provider => provider . provideNewSymbolNames ( model , loc . range , cts2 . token ) ) // TODO@ulugbekna : make sure this works regardless if the result is then-able
216- ) . then ( ( candidates ) => candidates . filter ( ( c ) : c is string [ ] => ! ! c ) . flat ( ) ) ;
217+ ) . then ( ( candidates ) => candidates . filter ( ( c ) : c is NewSymbolName [ ] => ! ! c ) . flat ( ) ) ;
217218
218219 const selection = this . editor . getSelection ( ) ;
219220 let selectionStart = 0 ;
@@ -288,6 +289,14 @@ class RenameController implements IEditorContribution {
288289 cancelRenameInput ( ) : void {
289290 this . _renameInputField . cancelInput ( true ) ;
290291 }
292+
293+ focusNextRenameSuggestion ( ) : void {
294+ this . _renameInputField . focusNextRenameSuggestion ( ) ;
295+ }
296+
297+ focusPreviousRenameSuggestion ( ) : void {
298+ this . _renameInputField . focusPreviousRenameSuggestion ( ) ;
299+ }
291300}
292301
293302// ---- action implementation
@@ -380,6 +389,76 @@ registerEditorCommand(new RenameCommand({
380389 }
381390} ) ) ;
382391
392+ registerAction2 ( class FocusNextRenameSuggestion extends Action2 {
393+ constructor ( ) {
394+ super ( {
395+ id : 'focusNextRenameSuggestion' ,
396+ title : {
397+ ...nls . localize2 ( 'focusNextRenameSuggestion' , "Focus Next Rename Suggestion" ) ,
398+ } ,
399+ precondition : CONTEXT_RENAME_INPUT_VISIBLE ,
400+ keybinding : [
401+ {
402+ when : CONTEXT_RENAME_INPUT_FOCUSED ,
403+ primary : KeyCode . Tab ,
404+ weight : KeybindingWeight . EditorContrib + 99 ,
405+ } ,
406+ {
407+ when : CONTEXT_RENAME_INPUT_FOCUSED . toNegated ( ) ,
408+ primary : KeyCode . Tab ,
409+ secondary : [ KeyCode . DownArrow ] ,
410+ weight : KeybindingWeight . EditorContrib + 99 ,
411+ }
412+ ]
413+ } ) ;
414+ }
415+
416+ override run ( accessor : ServicesAccessor ) : void {
417+ const currentEditor = accessor . get ( ICodeEditorService ) . getFocusedCodeEditor ( ) ;
418+ if ( ! currentEditor ) { return ; }
419+
420+ const controller = RenameController . get ( currentEditor ) ;
421+ if ( ! controller ) { return ; }
422+
423+ controller . focusNextRenameSuggestion ( ) ;
424+ }
425+ } ) ;
426+
427+ registerAction2 ( class FocusPreviousRenameSuggestion extends Action2 {
428+ constructor ( ) {
429+ super ( {
430+ id : 'focusPreviousRenameSuggestion' ,
431+ title : {
432+ ...nls . localize2 ( 'focusPreviousRenameSuggestion' , "Focus Previous Rename Suggestion" ) ,
433+ } ,
434+ precondition : CONTEXT_RENAME_INPUT_VISIBLE ,
435+ keybinding : [
436+ {
437+ when : CONTEXT_RENAME_INPUT_FOCUSED ,
438+ primary : KeyCode . Tab | KeyCode . Shift ,
439+ weight : KeybindingWeight . EditorContrib + 99 ,
440+ } ,
441+ {
442+ when : CONTEXT_RENAME_INPUT_FOCUSED . toNegated ( ) ,
443+ primary : KeyMod . Shift | KeyCode . Tab ,
444+ secondary : [ KeyCode . UpArrow ] ,
445+ weight : KeybindingWeight . EditorContrib + 99 ,
446+ }
447+ ]
448+ } ) ;
449+ }
450+
451+ override run ( accessor : ServicesAccessor ) : void {
452+ const currentEditor = accessor . get ( ICodeEditorService ) . getFocusedCodeEditor ( ) ;
453+ if ( ! currentEditor ) { return ; }
454+
455+ const controller = RenameController . get ( currentEditor ) ;
456+ if ( ! controller ) { return ; }
457+
458+ controller . focusPreviousRenameSuggestion ( ) ;
459+ }
460+ } ) ;
461+
383462// ---- api bridge command
384463
385464registerModelAndPositionCommand ( '_executeDocumentRenameProvider' , function ( accessor , model , position , ...args ) {
0 commit comments