Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow toggle tab focus mode regardless of editor #172395

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,29 @@
import { alert } from 'vs/base/browser/ui/aria/aria';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { TabFocus } from 'vs/editor/browser/config/tabFocus';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EditorAction, registerEditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
import * as nls from 'vs/nls';
import { Action2, registerAction2 } from 'vs/platform/actions/common/actions';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';

export class ToggleTabFocusModeAction extends EditorAction {
export class ToggleTabFocusModeAction extends Action2 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it bad to use Action2 over EditorAction in /editor/contrib?


public static readonly ID = 'editor.action.toggleTabFocusMode';

constructor() {
super({
id: ToggleTabFocusModeAction.ID,
label: nls.localize({ key: 'toggle.tabMovesFocus', comment: ['Turn on/off use of tab key for moving focus around VS Code'] }, "Toggle Tab Key Moves Focus"),
alias: 'Toggle Tab Key Moves Focus',
title: nls.localize({ key: 'toggle.tabMovesFocus', comment: ['Turn on/off use of tab key for moving focus around VS Code'] }, "Toggle Tab Key Moves Focus"),
precondition: undefined,
kbOpts: {
kbExpr: null,
keybinding: {
primary: KeyMod.CtrlCmd | KeyCode.KeyM,
mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KeyM },
weight: KeybindingWeight.EditorContrib
}
});
}

public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
public run(accessor: ServicesAccessor): void {
const oldValue = TabFocus.getTabFocusMode();
const newValue = !oldValue;
TabFocus.setTabFocusMode(newValue);
Expand All @@ -42,4 +40,4 @@ export class ToggleTabFocusModeAction extends EditorAction {
}
}

registerEditorAction(ToggleTabFocusModeAction);
registerAction2(ToggleTabFocusModeAction);