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

'list.select' keybinding not working in file Explorer pane #107377

Closed
Neutrino-Sunset opened this issue Sep 24, 2020 · 20 comments
Closed

'list.select' keybinding not working in file Explorer pane #107377

Neutrino-Sunset opened this issue Sep 24, 2020 · 20 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug file-explorer Explorer widget issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded

Comments

@Neutrino-Sunset
Copy link

Issue Type: Bug

When I select a file in the Explorer with the mouse, it opens that file but also 'selects' it, highlighting it with a prominent highlight.

Firstly I don't understand the purpose of this selection. It doesn't do anything. If I use the keyboard to move the keyboard focus to a different file, the 'selection' remains on the file I opened with the mouse, but if I now use a shortcut to perform some action e.g. rename, delete, this action occurs on the file with the keyboard focus not the apparently 'selected' file! So what the hell is the selection for? But I've already reported that and had that bug report closed as 'by design' on the basis that while it doesn't make any sense at all that's the way the vscode team want to do it anyway. Fine, whatever.

So this bug is to report a related but distinct issue. Which is that the keybinding for list.select doesn't work. On my system the keybinding for list.select is Enter which is its default value. If I click a file in the Explorer with the mouse it is opened and also selected. If I then use the keyboard to move the keyboard focus to another file and press Enter the file is opened, but the file selected using the mouse remains the one highlighted as being selected

That's got to be a bug right?

Here are some screenshots to show you what I'm talking about.

Focus0

Focus1

Open

Borked

VS Code version: Code 1.49.1 (58bb7b2, 2020-09-16T23:27:51.792Z)
OS version: Windows_NT x64 10.0.18362

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 x 2808)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.86GB (8.05GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (16)
Extension Author (truncated) Version
ng-template Ang 0.901.9
EditorConfig Edi 0.15.1
LogFileHighlighter emi 2.9.0
vscode-great-icons emm 2.1.56
vscode-jasmine-test-adapter hbe 1.7.0
vscode-test-explorer hbe 2.19.1
classic-asp ili 0.0.4
vscode-nuget-package-manager jmr 1.1.6
csharp ms- 1.22.0
debugger-for-chrome msj 4.12.10
nativescript Tel 0.11.0
subtle-brackets raf 3.0.0
rewrap stk 1.13.0
insert-special-symbol swi 1.3.0
indent-one-space use 0.2.6
html-css-class-completion Zig 1.19.0
@isidorn
Copy link
Contributor

isidorn commented Sep 25, 2020

This is tree widget behavior thus forwarding to @joaomoreno
@joaomoreno do we have some master issue for list tree selection and focus so I can just close as duplicate issues of these kind that come in?

@isidorn isidorn assigned joaomoreno and unassigned isidorn Sep 25, 2020
@JW9506
Copy link

JW9506 commented Sep 26, 2020

While trying to reproduce it, although I wasn't able to, I found another issue where when a file is selected, close the file in the editor(I used Ctrl + w), the explorer doesn't 'deselect' the file just closed, so any efforts trying to reopen the file by firing list.select would fail. Is this behavior expected?

Also note: I had to use list.toggleExpand to open the file after the sequence of actions made from above. But file tree was still focused(consequence of using list.toggleExpand), then I had to manually refocus the editor to start editing the file.

Another note: What seems to make sense to me is that when you close the file in the editor, VSCode should also deselect the closed file, which isn't the logic VSCode currently using.

Another note: My current workaround: use workbench.files.action.showActiveFileInExplorer to refocus into Explorer Tree from editorTextFocus to properly update/reflect the currently selected file. list.toggleSelection is also a great command.

@Neutrino-Sunset
Copy link
Author

I'm surprised you can't reproduce my issue, it's completely consistent across several machines for me, although settings sync could be synching a problematic configuration. Still I can't help wondering whether clarifying the reproduction steps might help.

  1. Click a file in the Explorer with the mouse: the file is opened and shows as selected in the Explorer.
  2. Press ctrl+shift+e to return focus to the Explorer.
  3. Use up/down arrow key to move keyboard focus to another file: previous file remains selected.
  4. Press enter to open the file with the keyboard focus: newly opened file is not selected.
  5. Press ctrl+shift+e to focus the Explorer again: the first file opened with the mouse remains selected.

@JW9506
Copy link

JW9506 commented Sep 26, 2020

I'm surprised you can't reproduce my issue, it's completely consistent across several machines for me, although settings sync could be synching a problematic configuration. Still I can't help wondering whether clarifying the reproduction steps might help.

  1. Click a file in the Explorer with the mouse: the file is opened and shows as selected in the Explorer.
  2. Press ctrl+shift+e to return focus to the Explorer.
  3. Use up/down arrow key to move keyboard focus to another file: previous file remains selected.
  4. Press enter to open the file with the keyboard focus: newly opened file is not selected.
  5. Press ctrl+shift+e to focus the Explorer again: the first file opened with the mouse remains selected.

In my case, in step 4, the new file is selected and shown in the editor with editorTextFocus, with the previous file selected state gone.

Note: Can you still reproduce it if you were to start code using code --disable-extensions -n (-n: new Code window), and then load a folder up by code -a [folder path]?

@Neutrino-Sunset
Copy link
Author

Yes. I see the same effect with all extensions disabled.

@joaomoreno
Copy link
Member

joaomoreno commented Sep 30, 2020

@isidorn This seems to be a bug on the Explorer, something broke here lately.

Steps:

  1. Click on a file
  2. Press ArrowDown, Enter

The second file should be selected, but the first remains selected.

recording (5)

@joaomoreno joaomoreno assigned isidorn and unassigned joaomoreno Sep 30, 2020
@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug tree-views Extension tree view issues file-explorer Explorer widget issues and removed tree-views Extension tree view issues labels Sep 30, 2020
@joaomoreno
Copy link
Member

joaomoreno commented Sep 30, 2020

@isidorn This can easily be fixed by deleting the entire explorer.openAndPassFocus command:

KeybindingsRegistry.registerCommandAndKeybindingRule({
weight: KeybindingWeight.WorkbenchContrib + 10,
when: ContextKeyExpr.and(ExplorerFocusCondition, ExplorerFolderContext.toNegated()),
primary: KeyCode.Enter,
mac: {
primary: KeyMod.CtrlCmd | KeyCode.DownArrow
},
id: 'explorer.openAndPassFocus', handler: async (accessor, _resource: URI | object) => {
const editorService = accessor.get(IEditorService);
const explorerService = accessor.get(IExplorerService);
const resources = explorerService.getContext(true);
if (resources.length) {
await editorService.openEditors(resources.map(r => ({ resource: r.resource, options: { preserveFocus: false } })));
}
}
});
It appears it's no longer needed, given the reworkings of list commands, the list.select command should work just fine in the explorer.

@isidorn
Copy link
Contributor

isidorn commented Sep 30, 2020

@joaomoreno I just checked stable and we also behave the same there.
So what I see is thta when you press Enter focus gets moved to the editor area. Thus the tree no longer has focus, and I thought that the tree only renders selection then.
If after your steps I do F1 > Focus on Folders View you can see that the focus is preserved on the correct element.

Ok now you commented again, let me see what removing that code does...

@isidorn
Copy link
Contributor

isidorn commented Sep 30, 2020

You are correct when removing the command this issue is fixed, however I introduced it explicitly to fix this issue #104783

Removing that command the issue #104783 reproduces again, so we can not remove it

@joaomoreno
Copy link
Member

Are you sure? The list.select handles that keyboard shortcut too:

secondary: [KeyMod.CtrlCmd | KeyCode.DownArrow]

Can you check what gets run instead of the list.select command on macOS?

@isidorn
Copy link
Contributor

isidorn commented Sep 30, 2020

@joaomoreno in that case the selection does not change. And the select event probably does not fire. Read the description of that issue carefully

"open a file with the mouse
press Cmd+ArrowDown"
So you are pressing cmd+arrowdown on an already selected file

@joaomoreno
Copy link
Member

So what I see is thta when you press Enter focus gets moved to the editor area. Thus the tree no longer has focus, and I thought that the tree only renders selection then.

The problem seems to be that the code that reveals in the tree the opened text editor file is not working in this case, since all your command does is open a file. Notice in the GIF how that reveal feature works just fine when I use the command palette to switch files. But it just seems not to work at all when going through your custom command.

@isidorn
Copy link
Contributor

isidorn commented Sep 30, 2020

Yeah. I agree, that seems to be the issue.

@joaomoreno
Copy link
Member

joaomoreno commented Sep 30, 2020

So you are pressing cmd+arrowdown on an already selected file

Oh. Yeah that's the thing. Yeah you need a custom command for that. Sorry about that.

@isidorn
Copy link
Contributor

isidorn commented Sep 30, 2020

Found the issue, pushing fix...
THanks for the help

@isidorn isidorn added this to the September 2020 milestone Sep 30, 2020
@isidorn
Copy link
Contributor

isidorn commented Sep 30, 2020

@Neutrino-Sunset list.select unfortunetly does not work in the explorer (you can read our discussion from above). You need to use the following command explorer.openAndPassFocus

@Neutrino-Sunset
Copy link
Author

The default configuration appears to be that both list.select and explorer.openAndPassFocus are already bound to Enter.

But I don't understand though. What do I need to do in order to be able to open a file in Explorer using the keyboard and have the correct file appear selected? Do I need to rebind explorer.openAndPassFocus to another key or something?

@isidorn
Copy link
Contributor

isidorn commented Sep 30, 2020

The bug was that it did not appear selected. I have pushed a fix for that.
You only need to rebing explorer.openAndPassFocus if you want to use a custom keybinding.

@Neutrino-Sunset
Copy link
Author

So I just need to wait for the fix to come through. Great, many thanks.

@isidorn
Copy link
Contributor

isidorn commented Oct 1, 2020

@Neutrino-Sunset it is already released in vscode insiders if you want to try it out you can.

@rebornix rebornix added the verified Verification succeeded label Oct 1, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug file-explorer Explorer widget issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants
@joaomoreno @rebornix @isidorn @Neutrino-Sunset @JW9506 and others