@@ -47,7 +47,7 @@ import { ThemeIcon } from '../../../../base/common/themables.js';
4747import { gotoNextLocation , gotoPreviousLocation } from '../../../../platform/theme/common/iconRegistry.js' ;
4848import { Codicon } from '../../../../base/common/codicons.js' ;
4949import { Color } from '../../../../base/common/color.js' ;
50- import { KeyCode , KeyMod } from '../../../../base/common/keyCodes.js' ;
50+ import { KeyChord , KeyCode , KeyMod } from '../../../../base/common/keyCodes.js' ;
5151import { getOuterEditor } from '../../../../editor/browser/widget/codeEditor/embeddedCodeEditorWidget.js' ;
5252import { quickDiffDecorationCount } from './quickDiffDecorator.js' ;
5353import { hasNativeContextMenu } from '../../../../platform/window/common/window.js' ;
@@ -464,6 +464,14 @@ class QuickDiffWidget extends PeekViewWidget {
464464 return this . diffEditor . hasTextFocus ( ) ;
465465 }
466466
467+ toggleFocus ( ) : void {
468+ if ( this . diffEditor . hasTextFocus ( ) ) {
469+ this . editor . focus ( ) ;
470+ } else {
471+ this . diffEditor . focus ( ) ;
472+ }
473+ }
474+
467475 override dispose ( ) {
468476 this . dropdown ?. dispose ( ) ;
469477 this . menu ?. dispose ( ) ;
@@ -547,6 +555,12 @@ export class QuickDiffEditorController extends Disposable implements IEditorCont
547555 this . widget ?. showChange ( this . widget . index , false ) ;
548556 }
549557
558+ toggleFocus ( ) : void {
559+ if ( this . widget ) {
560+ this . widget . toggleFocus ( ) ;
561+ }
562+ }
563+
550564 next ( lineNumber ?: number ) : void {
551565 if ( ! this . assertWidget ( ) ) {
552566 return ;
@@ -940,6 +954,26 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
940954 }
941955} ) ;
942956
957+ KeybindingsRegistry . registerCommandAndKeybindingRule ( {
958+ id : 'togglePeekWidgetFocus' ,
959+ weight : KeybindingWeight . EditorContrib ,
960+ primary : KeyChord ( KeyMod . CtrlCmd | KeyCode . KeyK , KeyCode . F2 ) ,
961+ when : isQuickDiffVisible ,
962+ handler : ( accessor : ServicesAccessor ) => {
963+ const outerEditor = getOuterEditorFromDiffEditor ( accessor ) ;
964+ if ( ! outerEditor ) {
965+ return ;
966+ }
967+
968+ const controller = QuickDiffEditorController . get ( outerEditor ) ;
969+ if ( ! controller ) {
970+ return ;
971+ }
972+
973+ controller . toggleFocus ( ) ;
974+ }
975+ } ) ;
976+
943977function setPositionAndSelection ( change : IChange , editor : ICodeEditor , accessibilityService : IAccessibilityService , codeEditorService : ICodeEditorService ) {
944978 const position = new Position ( change . modifiedStartLineNumber , 1 ) ;
945979 editor . setPosition ( position ) ;
0 commit comments