@@ -44,42 +44,7 @@ class DiffEditorHelperContribution extends Disposable implements IDiffEditorCont
44
44
) {
45
45
super ( ) ;
46
46
47
- this . _register ( AccessibilityHelpAction . addImplementation ( 105 , 'diff-editor' , async accessor => {
48
- const accessibleViewService = accessor . get ( IAccessibleViewService ) ;
49
- const editorService = accessor . get ( IEditorService ) ;
50
- const codeEditorService = accessor . get ( ICodeEditorService ) ;
51
- const keybindingService = accessor . get ( IKeybindingService ) ;
52
-
53
- const next = keybindingService . lookupKeybinding ( DiffReviewNext . id ) ?. getAriaLabel ( ) ;
54
- const previous = keybindingService . lookupKeybinding ( DiffReviewPrev . id ) ?. getAriaLabel ( ) ;
55
-
56
- if ( ! ( editorService . activeTextEditorControl instanceof DiffEditorWidget2 ) ) {
57
- return ;
58
- }
59
-
60
- const codeEditor = codeEditorService . getActiveCodeEditor ( ) || codeEditorService . getFocusedCodeEditor ( ) ;
61
- if ( ! codeEditor ) {
62
- return ;
63
- }
64
-
65
- const keys = [ 'audioCues.diffLineDeleted' , 'audioCues.diffLineInserted' , 'audioCues.diffLineModified' ] ;
66
-
67
- accessibleViewService . show ( {
68
- verbositySettingKey : 'diffEditor' ,
69
- provideContent : ( ) => [
70
- nls . localize ( 'msg1' , "You are in a diff editor." ) ,
71
- nls . localize ( 'msg2' , "Press {0} or {1} to view the next or previous diff in the diff review mode that is optimized for screen readers." , next , previous ) ,
72
- nls . localize ( 'msg3' , "To control which audio cues should be played, the following settings can be configured: {0}." , keys . join ( ', ' ) ) ,
73
- ] . join ( '\n' ) ,
74
- onClose : ( ) => {
75
- codeEditor . focus ( ) ;
76
- } ,
77
- options : { type : AccessibleViewType . HelpMenu , ariaLabel : nls . localize ( 'chat-help-label' , "Diff editor accessibility help" ) }
78
- } ) ;
79
- } , ContextKeyExpr . and (
80
- ContextKeyEqualsExpr . create ( 'diffEditorVersion' , 2 ) ,
81
- ContextKeyEqualsExpr . create ( 'isInDiffEditor' , true ) ,
82
- ) ) ) ;
47
+ this . _register ( createScreenReaderHelp ( ) ) ;
83
48
84
49
this . _helperWidget = null ;
85
50
this . _helperWidgetListener = null ;
@@ -151,4 +116,43 @@ class DiffEditorHelperContribution extends Disposable implements IDiffEditorCont
151
116
}
152
117
}
153
118
119
+ function createScreenReaderHelp ( ) : IDisposable {
120
+ return AccessibilityHelpAction . addImplementation ( 105 , 'diff-editor' , async ( accessor ) => {
121
+ const accessibleViewService = accessor . get ( IAccessibleViewService ) ;
122
+ const editorService = accessor . get ( IEditorService ) ;
123
+ const codeEditorService = accessor . get ( ICodeEditorService ) ;
124
+ const keybindingService = accessor . get ( IKeybindingService ) ;
125
+
126
+ const next = keybindingService . lookupKeybinding ( DiffReviewNext . id ) ?. getAriaLabel ( ) ;
127
+ const previous = keybindingService . lookupKeybinding ( DiffReviewPrev . id ) ?. getAriaLabel ( ) ;
128
+
129
+ if ( ! ( editorService . activeTextEditorControl instanceof DiffEditorWidget2 ) ) {
130
+ return ;
131
+ }
132
+
133
+ const codeEditor = codeEditorService . getActiveCodeEditor ( ) || codeEditorService . getFocusedCodeEditor ( ) ;
134
+ if ( ! codeEditor ) {
135
+ return ;
136
+ }
137
+
138
+ const keys = [ 'audioCues.diffLineDeleted' , 'audioCues.diffLineInserted' , 'audioCues.diffLineModified' ] ;
139
+
140
+ accessibleViewService . show ( {
141
+ verbositySettingKey : 'diffEditor' ,
142
+ provideContent : ( ) => [
143
+ nls . localize ( 'msg1' , "You are in a diff editor." ) ,
144
+ nls . localize ( 'msg2' , "Press {0} or {1} to view the next or previous diff in the diff review mode that is optimized for screen readers." , next , previous ) ,
145
+ nls . localize ( 'msg3' , "To control which audio cues should be played, the following settings can be configured: {0}." , keys . join ( ', ' ) ) ,
146
+ ] . join ( '\n' ) ,
147
+ onClose : ( ) => {
148
+ codeEditor . focus ( ) ;
149
+ } ,
150
+ options : { type : AccessibleViewType . HelpMenu , ariaLabel : nls . localize ( 'chat-help-label' , "Diff editor accessibility help" ) }
151
+ } ) ;
152
+ } , ContextKeyExpr . and (
153
+ ContextKeyEqualsExpr . create ( 'diffEditorVersion' , 2 ) ,
154
+ ContextKeyEqualsExpr . create ( 'isInDiffEditor' , true )
155
+ ) ) ;
156
+ }
157
+
154
158
registerDiffEditorContribution ( DiffEditorHelperContribution . ID , DiffEditorHelperContribution ) ;
0 commit comments