microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.73k stars 29.09k forks source link

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

Closed Neutrino-Sunset closed 4 years ago

Neutrino-Sunset commented 4 years ago

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 (58bb7b2331731bf72587010e943852e13e6fd3cf, 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 commented 4 years ago

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?

JW9506 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

joaomoreno commented 4 years ago

@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 commented 4 years ago

@isidorn This can easily be fixed by deleting the entire explorer.openAndPassFocus command: https://github.com/microsoft/vscode/blob/b1c54c1483e2dfcf3101f233b3f8f28436127fba/src/vs/workbench/contrib/files/browser/fileCommands.ts#L147-L163 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 commented 4 years ago

@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 commented 4 years ago

You are correct when removing the command this issue is fixed, however I introduced it explicitly to fix this issue https://github.com/microsoft/vscode/issues/104783

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

joaomoreno commented 4 years ago

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

https://github.com/microsoft/vscode/blob/78b0d0a446681dd4a98ced495be2ea81bc9b8708/src/vs/workbench/browser/actions/listCommands.ts#L536-L536

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

isidorn commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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

joaomoreno commented 4 years ago

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 commented 4 years ago

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

isidorn commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

isidorn commented 4 years ago

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