Add Command for navigating around visible editors/viewlets/repl#22005
Add Command for navigating around visible editors/viewlets/repl#22005bpasero merged 14 commits intomicrosoft:masterfrom
Conversation
|
@misoguy, |
|
@bpasero I've added an abstract class BaseNavigationAction and planning to implement up/down/left/right navigation based on this abstract class. It would be nice if you could take a brief look on this code. |
|
The code seems good even though I don't know much of the vscode codebase. I tested it and it works as expected. I was wondering, there is nothing extra to do to be able to bind those commands to custom keybindings right? |
bpasero
left a comment
There was a problem hiding this comment.
Seems to work very nicely, some feedback added.
| } | ||
|
|
||
| public next(jumpGroups: boolean): IEditorIdentifier { | ||
| public next(jumpGroups: boolean, cycleAtEnd = true): IEditorIdentifier { |
There was a problem hiding this comment.
Please add a test for this in editorStacksModel.test.ts
There was a problem hiding this comment.
I'll definitely add this test!
| if (isWindows || isLinux) { | ||
| workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleMenuBarAction, ToggleMenuBarAction.ID, ToggleMenuBarAction.LABEL), 'View: Toggle Menu Bar', viewCategory); | ||
| } | ||
| workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(NavigateUpAction, NavigateUpAction.ID, NavigateUpAction.LABEL, null), 'View: Navigate Up', viewCategory); |
There was a problem hiding this comment.
I wonder if the command name is verbose enough to understand the intent. Can we see how others (VIM?) name this command? Maybe "Navigate to next View to the Left" etc?
There was a problem hiding this comment.
I understand that the command name might not be verbose enough.
Do you mean that the View: Navigate Up should be renamed as Navigate to next View to the top or to change the class name itself? Something like class NavigateUp to class NavigateViewToTheTop?
There was a problem hiding this comment.
No I was just thinking of the label for users when they find this command in the command palette for example.
There was a problem hiding this comment.
Here are Vim's descriptions:
CTRL-W h move to the window on the left
CTRL-W j move to the window below
CTRL-W k move to the window above
CTRL-W l move to the window on the right
CTRL-W t move to the TOP window
CTRL-W b move to the BOTTOM window
We may want to replace window with View or View Part or similar.
There was a problem hiding this comment.
I'll change the label to
'View: Move to the View Part on the left'(right/below/above)
and leave the ID as workbench.action.navigateLeft (as currently implemented)
By the way, is move to the TOP window and move to the BOTTOM window required as well? Since it is currently not implemented...
There was a problem hiding this comment.
I would think we should handle those commands in a separate PR if we ever needed them.
| return this.navigateToLastActiveEditor(); | ||
| } | ||
|
|
||
| private navigateLeftFromEditor(jumpGroups: boolean, isSidebarPositionLeft: boolean): TPromise<boolean> { |
There was a problem hiding this comment.
Why would we ever not jump groups? I am in a state where I have 2 editors open in one group and navigating left and right jumps between those tabs. My understanding is that this is entirely not about navigating between tabs?
There was a problem hiding this comment.
We would not jump groups in 2 situations
- When the sidebar is on the left and the current active editor is the first editor in the first group, we would have to go to the sidebar
- When the sidebar is on the right, it's the opposite
There was a problem hiding this comment.
Sorry, I was not clear: I found a situation where invoking the action was jumping from tab A to tab B in the same single editor group. I suppose that might just be a bug?
There was a problem hiding this comment.
As we are just navigating between visible UI parts, we should just navigate between editor groups instead of activating tabs. Otherwise if users open a dozen of files, navigation commands are useless somehow.
If I understand correctly, IEditorGroupService.focusGroup is enough for editor navigation.
There was a problem hiding this comment.
@bpasero @rebornix So is it agreed that the navigation should only occur between the View Parts?(ex: sidebar, panel, and 1-3 editor groups)
This means that navigating left and right will not move to the left/right editor of the current group, but will move to the left/right group of the current editor group instead.
There was a problem hiding this comment.
@misoguy yes, navigation only between view parts. If there is only one group opened with many editors and no other view part, then basically you cannot navigate anywhere else at all. If more than one group is opened, you can start to navigate between groups.
There was a problem hiding this comment.
Understood, this means that the code has to be changed a little bit. I'll get on it when I get the time :)
| } | ||
| } | ||
|
|
||
| export class NavigateDownAction extends BaseNavigationAction { |
There was a problem hiding this comment.
Should we navigate down to the panel when focus is in the sidebar? Currently that is not happening.
There was a problem hiding this comment.
It's my understanding that we will not move down or up when the focus is in the sidebar.
However, if we should navigate down to the panel when focus is in the sidebar, it can be implemented.
Should it be implemented?
There was a problem hiding this comment.
Best to talk back to issue creator + VIM guys :)
There was a problem hiding this comment.
I'll suggest not to do that at this moment :)
|
@jtheoof Thanks for testing it out :) However, I didn't really understand what you meant by "I was wondering, there is nothing extra to do to be able to bind those commands to custom keybindings right?". Do you mean is it possible to bind it in a plugin? |
|
Made all changes as requested, and cleared up some unused codes. |
|
@misoguy No I meant if there was anything special to do to have custom keymaps. I do not see the new "commands" would work? (Forgive my noobs question, it's the first time I review a PR in code). |
|
@jtheoof The command you are looking for is |
|
LGTM, just two tiny comments. |
| if (isWindows || isLinux) { | ||
| workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleMenuBarAction, ToggleMenuBarAction.ID, ToggleMenuBarAction.LABEL), 'View: Toggle Menu Bar', viewCategory); | ||
| } | ||
| workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(NavigateUpAction, NavigateUpAction.ID, NavigateUpAction.LABEL, null), 'View: Move to the View Part above', viewCategory); |
There was a problem hiding this comment.
@misoguy please use capital casing here, e.g. View: Move to the View Part Above
| export class NavigateLeftAction extends BaseNavigationAction { | ||
|
|
||
| public static ID = 'workbench.action.navigateLeft'; | ||
| public static LABEL = nls.localize('navigateLeft', "Navigate Left"); |
There was a problem hiding this comment.
@misoguy please make sure that these labels are in sync with where you register them (e.g. this one should be View: Move to the View Part on the Left).
|
|
||
| export abstract class BaseNavigationAction extends Action { | ||
|
|
||
| protected NEXT = 'next'; |
There was a problem hiding this comment.
@misoguy a bit weird, why not use an enum outside of the action?
enum Direction {
Next,
Previous
}
|
@bpasero Changed as requested 👍 |
|
Awesome, thanks 👍 |
|
@bpasero yes the whitelist is here: https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts#L145 (messy I know #19770). cmd+up/down actually seem to be used in Terminal.app to jump to the previous/next command which we may want to implement in the future. The cmd+left/right printing escape sequences may actually be a bug here, opened xtermjs/xterm.js#597 |
| super(id, label, groupService, panelService, partService, viewletService); | ||
| } | ||
|
|
||
| protected navigateOnEditorFocus(isEditorGroupVertical, isSidebarPositionLeft): TPromise<boolean> { |
There was a problem hiding this comment.
If isEditorGroupVertical is false, navigate left will navigate to the sidebar, whether the sidebar is on the left or right. However, if isEditorGroupVertical is true and isSidebarPositionLeft is false, it won't navigate to the sidebar on the right. The behavior is not consistent.
| } | ||
|
|
||
| protected navigateOnEditorFocus(isEditorGroupVertical, isSidebarPositionLeft): TPromise<boolean> { | ||
| if (!isEditorGroupVertical) { |
|
@rebornix I cannot reproduce, I am in this setup and Cmd+Left (for navigating left) does not bring me to the sidebar: |

Fix #21669