33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import * as nls from 'vs/nls ' ;
6+ import { Disposable , IDisposable } from 'vs/base/common/lifecycle ' ;
77import { IDiffEditor } from 'vs/editor/browser/editorBrowser' ;
88import { 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' ;
1213import { 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' ;
1416import { 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' ;
1520import { 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' ;
1725
1826const enum WidgetState {
1927 Hidden ,
@@ -35,6 +43,44 @@ class DiffEditorHelperContribution extends Disposable implements IDiffEditorCont
3543 @INotificationService private readonly _notificationService : INotificationService ,
3644 ) {
3745 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+
3884 this . _helperWidget = null ;
3985 this . _helperWidgetListener = null ;
4086 this . _state = WidgetState . Hidden ;
0 commit comments