5
5
6
6
import { KeyCode , KeyMod } from 'vs/base/common/keyCodes' ;
7
7
import { ICodeEditor , IDiffEditor } from 'vs/editor/browser/editorBrowser' ;
8
- import { EditorAction , ServicesAccessor , registerEditorAction } from 'vs/editor/browser/editorExtensions' ;
8
+ import { EditorAction2 , ServicesAccessor } from 'vs/editor/browser/editorExtensions' ;
9
9
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
10
10
import { localize } from 'vs/nls' ;
11
+ import { ILocalizedString } from 'vs/platform/action/common/action' ;
12
+ import { registerAction2 } from 'vs/platform/actions/common/actions' ;
11
13
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
12
14
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
13
15
14
- export class DiffReviewNext extends EditorAction {
16
+
17
+ const accessibleDiffViewerCategory : ILocalizedString = {
18
+ value : localize ( 'accessibleDiffViewer' , 'Accessible Diff Viewer' ) ,
19
+ original : 'Accessible Diff Viewer' ,
20
+ } ;
21
+
22
+ export class DiffReviewNext extends EditorAction2 {
15
23
public static id = 'editor.action.diffReview.next' ;
16
24
17
25
constructor ( ) {
18
26
super ( {
19
27
id : DiffReviewNext . id ,
20
- label : localize ( 'editor.action.diffReview.next' , "Go to Next Difference" ) ,
21
- alias : 'Go to Next Difference' ,
28
+ title : { value : localize ( 'editor.action.diffReview.next' , "Go to Next Difference" ) , original : 'Go to Next Difference' } ,
29
+ category : accessibleDiffViewerCategory ,
22
30
precondition : ContextKeyExpr . has ( 'isInDiffEditor' ) ,
23
- kbOpts : {
24
- kbExpr : null ,
31
+ keybinding : {
25
32
primary : KeyCode . F7 ,
26
33
weight : KeybindingWeight . EditorContrib
27
- }
34
+ } ,
35
+ f1 : true ,
28
36
} ) ;
29
37
}
30
38
31
- public run ( accessor : ServicesAccessor , editor : ICodeEditor ) : void {
39
+ public override runEditorCommand ( accessor : ServicesAccessor , editor : ICodeEditor ) : void {
32
40
const diffEditor = findFocusedDiffEditor ( accessor ) ;
33
41
diffEditor ?. diffReviewNext ( ) ;
34
42
}
35
43
}
36
44
37
- export class DiffReviewPrev extends EditorAction {
45
+ export class DiffReviewPrev extends EditorAction2 {
38
46
public static id = 'editor.action.diffReview.prev' ;
39
47
40
48
constructor ( ) {
41
49
super ( {
42
50
id : DiffReviewPrev . id ,
43
- label : localize ( 'editor.action.diffReview.prev' , "Go to Previous Difference" ) ,
44
- alias : 'Go to Previous Difference' ,
51
+ title : { value : localize ( 'editor.action.diffReview.prev' , "Go to Previous Difference" ) , original : 'Go to Previous Difference' } ,
52
+ category : accessibleDiffViewerCategory ,
45
53
precondition : ContextKeyExpr . has ( 'isInDiffEditor' ) ,
46
- kbOpts : {
47
- kbExpr : null ,
54
+ keybinding : {
48
55
primary : KeyMod . Shift | KeyCode . F7 ,
49
56
weight : KeybindingWeight . EditorContrib
50
- }
57
+ } ,
58
+ f1 : true ,
51
59
} ) ;
52
60
}
53
61
54
- public run ( accessor : ServicesAccessor , editor : ICodeEditor ) : void {
62
+ public override runEditorCommand ( accessor : ServicesAccessor , editor : ICodeEditor ) : void {
55
63
const diffEditor = findFocusedDiffEditor ( accessor ) ;
56
64
diffEditor ?. diffReviewPrev ( ) ;
57
65
}
58
66
}
59
67
60
- function findFocusedDiffEditor ( accessor : ServicesAccessor ) : IDiffEditor | null {
68
+ export function findFocusedDiffEditor ( accessor : ServicesAccessor ) : IDiffEditor | null {
61
69
const codeEditorService = accessor . get ( ICodeEditorService ) ;
62
70
const diffEditors = codeEditorService . listDiffEditors ( ) ;
63
71
const activeCodeEditor = codeEditorService . getFocusedCodeEditor ( ) ?? codeEditorService . getActiveCodeEditor ( ) ;
@@ -74,5 +82,5 @@ function findFocusedDiffEditor(accessor: ServicesAccessor): IDiffEditor | null {
74
82
return null ;
75
83
}
76
84
77
- registerEditorAction ( DiffReviewNext ) ;
78
- registerEditorAction ( DiffReviewPrev ) ;
85
+ registerAction2 ( DiffReviewNext ) ;
86
+ registerAction2 ( DiffReviewPrev ) ;
0 commit comments