microsoft / vscode

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

Alt-Shift select does not handle arrow keys correctly #78595

Closed simonmckenzie closed 4 years ago

simonmckenzie commented 5 years ago

Issue Type: Bug

Hi,

When using Alt-Shift and the mouse to select rectangles of text, it works as expected, but if the arrow keys are used instead, the results are not as expected.

To reproduce (first case):

To reproduce (second case):

VS Code version: Code 1.36.1 (2213894ea0415ee8c85c5eea0d0ff81ecc191529, 2019-07-08T22:59:35.033Z) OS version: Windows_NT x64 10.0.18362

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (8 x 3408)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.87GB (5.07GB free)| |Process Argv|C:\src\SQL-MI.wiki\Creating-a-managed-instance.md| |Screen Reader|no| |VM|0%|
Extensions (26) Extension|Author (truncated)|Version ---|---|--- ng-template|Ang|0.801.1 xml|Dot|2.5.0 EditorConfig|Edi|0.13.0 vscode-npm-script|eg2|0.3.8 prettier-vscode|esb|1.9.0 Ionide-fsharp|Ion|4.0.6 angular-essentials|joh|0.6.3 Angular2|joh|8.1.1 vscode-peacock|joh|3.0.1 chat|kar|0.16.2 vscode-tickscript|mat|0.0.4 terraform|mau|1.3.12 mssql|ms-|1.6.0 azurecli|ms-|0.4.6 csharp|ms-|1.21.0 powershell|ms-|2019.5.0 vscode-typescript-tslint-plugin|ms-|1.2.2 vsliveshare|ms-|1.0.614 vsliveshare-audio|ms-|0.1.60 vsliveshare-pack|ms-|0.3.2 debugger-for-chrome|msj|4.11.7 angular2-inline|nat|0.0.17 angular-console|nrw|8.0.10 material-icon-theme|PKi|3.8.1 vba|spe|1.2.0 dot|Ste|0.0.1 (1 theme extensions excluded)
rebornix commented 4 years ago

Kapture 2019-10-21 at 14 38 48

I fail to reproduce this issue with current Insiders, it would be great if we can have more info about how to reproduce it.

simonmckenzie commented 4 years ago

Hi @rebornix,

You're right - it's working in v1.39.2. However, it's still not quite right - if you then press "down" after the hlighlight has been made, the row is copied (rather than a rectangle of text being selected):

Place the cursor, hold "shift", press "right", then "down", "down", "down"

I would also argue that when "right" is pressed when "alt-shift" is held, only one character should be selected, as it's a rectangular selection tool, which doesn't really have anything to do with word boundaries.

LarnuUK commented 4 years ago

I have this problem too I can't believe this issue has been open since August when it's such a basic feature. It's infuriating...

Behaviour I get is below (not I have at least been able to change the Alt+Shift+Down Arrow behaviour): 43F56C3F

Behaviour I expect (using SSMS): k2ZP8Z5qmq

alexdima commented 4 years ago

@simonmckenzie @LarnuUK

AFAICT there is no bug here. What I can guess is that you expect Shift+Alt+arrow keys to be bound to column selection commands by default, which is not the case with VS Code. Fortunately, all the keybindings of VS Code can be customized, including these ones. So if you would like shift+alt+arrow keys to do column selection, you can edit your keybindings.json file:

[
{ "key": "shift+alt+down",   "command": "cursorColumnSelectDown",
                             "when": "textInputFocus" },
{ "key": "shift+alt+left",   "command": "cursorColumnSelectLeft",
                             "when": "textInputFocus" },
{ "key": "shift+alt+right",  "command": "cursorColumnSelectRight",
                             "when": "textInputFocus" },
{ "key": "shift+alt+up",     "command": "cursorColumnSelectUp",
                             "when": "textInputFocus" }
]
simonmckenzie commented 4 years ago

Hi @alexandrudima,

While it's great to know that there's a workaround, doesn't it seem reasonable that the behaviour when using the arrow keys should match that when using the mouse? It seems very inconsistent when Alt+Shift gives different results when using keyboard vs. mouse. Perhaps the standard key mappings should be revised.

Also, while I wouldn't like to say there's a "standard" around rectangular selection, Visual Studio, SQL Management Studio, and notepad++ all do rectangular selection in the same way, via mouse or arrow keys.

Thanks,

Simon

alexdima commented 4 years ago

@simonmckenzie It is unfortunately not possible for us to change default key mappings anymore. It is not worth it to upset millions of people which are now happy and used to VS Code's defaults since years. It is much easier for those familiar with Visual Studio keybindings to simply install the Visual Studio keymap extension.

Have you installed that by the way? That extension changes a lot more keybindings to make VS Code more familiar if you are coming from Visual Studio.