Skip to content

Commit 6eb0792

Browse files
author
Benjamin Pasero
committed
editors - restore ability to navigate in reverse MRU order from picker
1 parent 5963a8e commit 6eb0792

6 files changed

Lines changed: 65 additions & 1 deletion

File tree

src/vs/base/parts/quickopen/browser/quickOpenWidget.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,13 @@ export class QuickOpenWidget extends Disposable implements IModelProvider, IThem
749749
this.tree.focusNth(1);
750750
}
751751
}
752+
753+
// Finally check for auto focus of last entry
754+
else if (autoFocus.autoFocusLastEntry) {
755+
if (entries.length > 1) {
756+
this.tree.focusLast();
757+
}
758+
}
752759
}
753760

754761
refresh(input?: IModel<any>, autoFocus?: IAutoFocus): void {

src/vs/base/parts/quickopen/common/quickOpen.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export interface IAutoFocus {
2626
*/
2727
autoFocusSecondEntry?: boolean;
2828

29+
/**
30+
* If set to true, will automatically select the last entry from the result list.
31+
*/
32+
autoFocusLastEntry?: boolean;
33+
2934
/**
3035
* If set to true, will automatically select any entry whose label starts with the search
3136
* value. Since some entries to the top might match the query but not on the prefix, this

src/vs/workbench/browser/parts/editor/editor.contribution.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
SplitEditorUpAction, SplitEditorDownAction, MoveEditorToLeftGroupAction, MoveEditorToRightGroupAction, MoveEditorToAboveGroupAction, MoveEditorToBelowGroupAction, CloseAllEditorGroupsAction,
3737
JoinAllGroupsAction, FocusLeftGroup, FocusAboveGroup, FocusRightGroup, FocusBelowGroup, EditorLayoutSingleAction, EditorLayoutTwoColumnsAction, EditorLayoutThreeColumnsAction, EditorLayoutTwoByTwoGridAction,
3838
EditorLayoutTwoRowsAction, EditorLayoutThreeRowsAction, EditorLayoutTwoColumnsBottomAction, EditorLayoutTwoRowsRightAction, NewEditorGroupLeftAction, NewEditorGroupRightAction,
39-
NewEditorGroupAboveAction, NewEditorGroupBelowAction, SplitEditorOrthogonalAction, CloseEditorInAllGroupsAction, NavigateToLastEditLocationAction, ToggleGroupSizesAction, ShowAllEditorsByMostRecentlyUsedAction, QuickOpenPreviousRecentlyUsedEditorAction, OpenPreviousRecentlyUsedEditorInGroupAction, OpenNextRecentlyUsedEditorInGroupAction
39+
NewEditorGroupAboveAction, NewEditorGroupBelowAction, SplitEditorOrthogonalAction, CloseEditorInAllGroupsAction, NavigateToLastEditLocationAction, ToggleGroupSizesAction, ShowAllEditorsByMostRecentlyUsedAction, QuickOpenPreviousRecentlyUsedEditorAction, OpenPreviousRecentlyUsedEditorInGroupAction, OpenNextRecentlyUsedEditorInGroupAction, QuickOpenNextRecentlyUsedEditorAction as QuickOpenLeastRecentlyUsedEditorAction, QuickOpenLeastRecentlyUsedEditorInGroupAction
4040
} from 'vs/workbench/browser/parts/editor/editorActions';
4141
import * as editorCommands from 'vs/workbench/browser/parts/editor/editorCommands';
4242
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -426,8 +426,13 @@ registry.registerWorkbenchAction(SyncActionDescriptor.create(EditorLayoutTwoRows
426426
registry.registerWorkbenchAction(SyncActionDescriptor.create(EditorLayoutTwoColumnsBottomAction, EditorLayoutTwoColumnsBottomAction.ID, EditorLayoutTwoColumnsBottomAction.LABEL), 'View: Two Columns Bottom Editor Layout', category);
427427

428428
// Register Quick Editor Actions including built in quick navigate support for some
429+
429430
registry.registerWorkbenchAction(SyncActionDescriptor.create(QuickOpenPreviousRecentlyUsedEditorAction, QuickOpenPreviousRecentlyUsedEditorAction.ID, QuickOpenPreviousRecentlyUsedEditorAction.LABEL), 'View: Quick Open Previous Recently Used Editor', category);
431+
registry.registerWorkbenchAction(SyncActionDescriptor.create(QuickOpenLeastRecentlyUsedEditorAction, QuickOpenLeastRecentlyUsedEditorAction.ID, QuickOpenLeastRecentlyUsedEditorAction.LABEL), 'View: Quick Open Least Recently Used Editor', category);
432+
430433
registry.registerWorkbenchAction(SyncActionDescriptor.create(QuickOpenPreviousRecentlyUsedEditorInGroupAction, QuickOpenPreviousRecentlyUsedEditorInGroupAction.ID, QuickOpenPreviousRecentlyUsedEditorInGroupAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.Tab, mac: { primary: KeyMod.WinCtrl | KeyCode.Tab } }), 'View: Quick Open Previous Recently Used Editor in Group', category);
434+
registry.registerWorkbenchAction(SyncActionDescriptor.create(QuickOpenLeastRecentlyUsedEditorInGroupAction, QuickOpenLeastRecentlyUsedEditorInGroupAction.ID, QuickOpenLeastRecentlyUsedEditorInGroupAction.LABEL, { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Tab, mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.Tab } }), 'View: Quick Open Least Recently Used Editor in Group', category);
435+
431436
registry.registerWorkbenchAction(SyncActionDescriptor.create(QuickOpenPreviousEditorFromHistoryAction, QuickOpenPreviousEditorFromHistoryAction.ID, QuickOpenPreviousEditorFromHistoryAction.LABEL), 'Quick Open Previous Editor from History');
432437

433438
const quickOpenNavigateNextInEditorPickerId = 'workbench.action.quickOpenNavigateNextInEditorPicker';

src/vs/workbench/browser/parts/editor/editorActions.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,21 @@ export class QuickOpenPreviousRecentlyUsedEditorAction extends BaseQuickOpenEdit
13371337
}
13381338
}
13391339

1340+
export class QuickOpenNextRecentlyUsedEditorAction extends BaseQuickOpenEditorAction {
1341+
1342+
static readonly ID = 'workbench.action.quickOpenLeastRecentlyUsedEditor';
1343+
static readonly LABEL = nls.localize('quickOpenLeastRecentlyUsedEditor', "Quick Open Least Recently Used Editor");
1344+
1345+
constructor(
1346+
id: string,
1347+
label: string,
1348+
@IQuickOpenService quickOpenService: IQuickOpenService,
1349+
@IKeybindingService keybindingService: IKeybindingService
1350+
) {
1351+
super(id, label, NAVIGATE_ALL_EDITORS_BY_MOST_RECENTLY_USED_PREFIX, quickOpenService, keybindingService);
1352+
}
1353+
}
1354+
13401355
export class QuickOpenPreviousRecentlyUsedEditorInGroupAction extends BaseQuickOpenEditorAction {
13411356

13421357
static readonly ID = 'workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup';
@@ -1352,6 +1367,21 @@ export class QuickOpenPreviousRecentlyUsedEditorInGroupAction extends BaseQuickO
13521367
}
13531368
}
13541369

1370+
export class QuickOpenLeastRecentlyUsedEditorInGroupAction extends BaseQuickOpenEditorAction {
1371+
1372+
static readonly ID = 'workbench.action.quickOpenLeastRecentlyUsedEditorInGroup';
1373+
static readonly LABEL = nls.localize('quickOpenLeastRecentlyUsedEditorInGroup', "Quick Open Least Recently Used Editor in Group");
1374+
1375+
constructor(
1376+
id: string,
1377+
label: string,
1378+
@IQuickOpenService quickOpenService: IQuickOpenService,
1379+
@IKeybindingService keybindingService: IKeybindingService
1380+
) {
1381+
super(id, label, NAVIGATE_IN_ACTIVE_GROUP_BY_MOST_RECENTLY_USED_PREFIX, quickOpenService, keybindingService);
1382+
}
1383+
}
1384+
13551385
export class QuickOpenPreviousEditorFromHistoryAction extends Action {
13561386

13571387
static readonly ID = 'workbench.action.openPreviousEditorFromHistory';

src/vs/workbench/browser/parts/editor/editorPicker.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,21 @@ export abstract class BaseEditorPicker extends QuickOpenHandler {
151151
};
152152
}
153153

154+
const isShiftNavigate = (context.quickNavigateConfiguration && context.quickNavigateConfiguration.keybindings.some(k => {
155+
const [firstPart, chordPart] = k.getParts();
156+
if (chordPart) {
157+
return false;
158+
}
159+
160+
return firstPart.shiftKey;
161+
}));
162+
163+
if (isShiftNavigate) {
164+
return {
165+
autoFocusLastEntry: true
166+
};
167+
}
168+
154169
const editors = this.count();
155170
return {
156171
autoFocusFirstEntry: editors === 1,

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ export const DEFAULT_COMMANDS_TO_SKIP_SHELL: string[] = [
148148
'workbench.action.openNextRecentlyUsedEditorInGroup',
149149
'workbench.action.openPreviousRecentlyUsedEditorInGroup',
150150
'workbench.action.quickOpenPreviousRecentlyUsedEditor',
151+
'workbench.action.quickOpenLeastRecentlyUsedEditor',
151152
'workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup',
153+
'workbench.action.quickOpenLeastRecentlyUsedEditorInGroup',
152154
'workbench.action.focusActiveEditorGroup',
153155
'workbench.action.focusFirstEditorGroup',
154156
'workbench.action.focusLastEditorGroup',

0 commit comments

Comments
 (0)