3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import * as nls from 'vs/nls ' ;
6
+ import { Disposable , IDisposable } from 'vs/base/common/lifecycle ' ;
7
7
import { IDiffEditor } from 'vs/editor/browser/editorBrowser' ;
8
8
import { registerDiffEditorContribution } from 'vs/editor/browser/editorExtensions' ;
9
- import { IDiffEditorContribution } from 'vs/editor/common/editorCommon' ;
10
- import { Disposable , IDisposable } from 'vs/base/common/lifecycle' ;
11
- import { FloatingClickWidget } from 'vs/workbench/browser/codeeditor' ;
9
+ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
10
+ import { DiffReviewNext , DiffReviewPrev } from 'vs/editor/browser/widget/diffEditor.contribution' ;
11
+ import { DiffEditorWidget2 } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2' ;
12
+ import { EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget' ;
12
13
import { IDiffComputationResult } from 'vs/editor/common/diff/smartLinesDiffComputer' ;
13
- import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
14
+ import { IDiffEditorContribution } from 'vs/editor/common/editorCommon' ;
15
+ import * as nls from 'vs/nls' ;
14
16
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
17
+ import { ContextKeyEqualsExpr , ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
18
+ import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
19
+ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
15
20
import { INotificationService , Severity } from 'vs/platform/notification/common/notification' ;
16
- import { EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget' ;
21
+ import { FloatingClickWidget } from 'vs/workbench/browser/codeeditor' ;
22
+ import { AccessibilityHelpAction } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution' ;
23
+ import { AccessibleViewType , IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView' ;
24
+ import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
17
25
18
26
const enum WidgetState {
19
27
Hidden ,
@@ -35,6 +43,44 @@ class DiffEditorHelperContribution extends Disposable implements IDiffEditorCont
35
43
@INotificationService private readonly _notificationService : INotificationService ,
36
44
) {
37
45
super ( ) ;
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
+ id : '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
+ ) ) ) ;
83
+
38
84
this . _helperWidget = null ;
39
85
this . _helperWidgetListener = null ;
40
86
this . _state = WidgetState . Hidden ;
0 commit comments