microsoft / vscode

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

Home / End (cursorHome / cursorEnd) broken with TS / JS #177428

Closed qgates closed 1 year ago

qgates commented 1 year ago

Type: Bug

Affects source code in language modes Javascript / Typescript. Other language modes not tested.

Since around 1.75.x v1.75.0, with lines that extend beyond the horizontal width of the window / pane (viewport), after a little time the End key no longer brings the cursor into view. When this occurs, I need to hit End multiple times to finally show the text at the cursor position...

Hitting End:

The above happens in reverse with the Home key, when cursor is at line end.

The above problem appears after about 15-20 seconds or after some up/down cursoring through a source file causing the viewport to change. Initially everything works fine, but after what seems like some internal process has finished the problem appears.

Cursoring up / down through the file and making edits can cure and also re-cause the problem.

Changing language mode to 'Plain Text' cures the problem completely. Switching back to Typescript or Javascript and the problem reappears.

Have run code --disable-extensions but the problem and behaviour described above remain.

VS Code version: Code 1.76.2 (ee2b180d582a7f601fa6ecfdad8d9fd269ab1884, 2023-03-14T17:55:54.936Z) OS version: Windows_NT x64 10.0.19045 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (16 x 3600)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|undefined| |Memory (System)|31.84GB (21.55GB free)| |Process Argv|--crash-reporter-id c5eaccc8-04a0-420f-9fcc-fc53a5d0dfc6| |Screen Reader|no| |VM|0%|
Extensions (11) Extension|Author (truncated)|Version ---|---|--- vscode-eslint|dba|2.4.0 vscode-deno|den|3.17.0 sqltools|mtx|0.27.1 sqltools-driver-mysql|mtx|0.5.1 sqltools-driver-pg|mtx|0.5.1 vscode-subword-navigation|ow|1.2.0 vscode-paste-and-indent|Rub|0.0.8 transpose|v4r|0.0.6 windicss-intellisense|voo|0.21.6 volar|Vue|1.2.0 markdown-all-in-one|yzh|3.5.0 (1 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 pythondataviewer:30285071 vscod805:30301674 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593cf:30376535 pythonvs932:30410667 cppdebug:30492333 vscaac:30438847 vsclangdc:30486549 c4g48928:30535728 dsvsc012:30540252 pynewext54:30681850 azure-dev_surveyone:30548225 vsccc:30610678 pyindex848:30662994 nodejswelcome1:30587005 3biah626:30602489 pyind779:30671433 f6dab269:30613381 pythonsymbol12:30671437 vsccsb:30677849 pythonb192:30669360 functionswalk:30687959 pythonms35cf:30686773 ```
pionxzh commented 1 year ago

I've encountered the same problem, and my initial assumption was that there might be a new default feature causing the cursorEnd to jump to the end of the view. However, after spending 10 minutes searching through the settings and release notes, I came across this issue.

Even without any extension, this problem will eventually appear after approximately 1 minute.

VS Code version: Code 1.76.1 (https://github.com/microsoft/vscode/commit/5e805b79fcb6ba4c2d23712967df89a089da575b, 2023-03-08T16:32:00.131Z) OS version: Windows_NT x64 10.0.22621 Modes: Sandboxed: No

qgates commented 1 year ago

Sorry btw for the lousy bug report, it's quite difficult to describe the problem but very frustrating. If necessary I'll put a vid together to show the problem, but I can confirm it's been happening since at least 1.75. I'll also try some older versions to see where the problem started.

@pionxzh Glad I'm not the only one seeing this issue. Do you see it in Windows, Linux or Mac, and are you running multi-screen?

I'm curious about whether it might be related to my dual screen setup and whether vscode may be miscalculating horizontal viewport scrolling as a result; my horizontal resolution 3840 px.

Can confirm the same issue running vscode portable, no extensions.

pionxzh commented 1 year ago

@qgates I have added some basic information above. I do have a dual screen setup, and this problem can be reproduced on both.

qgates commented 1 year ago

@pionxzh Thanks. It takes about 20 seconds here before the problem starts to occur but that may be down to machine or network speed. I think you are seeing the same issue.

qgates commented 1 year ago

More information. The problem only occurs with smooth scrolling enabled, ie.

"editor.smoothScrolling": true,

Changing this setting to false cures the problem for me. Can you confirm @pionxzh?

I downloaded every version from 1.76.2 backwards and ran each portable, vanilla with no extensions, editing the same source file. I can confirm the problem begins with version 1.75.0, and does not occur with version 1.74.3 and earlier.

pionxzh commented 1 year ago

More information. The problem only occurs with smooth scrolling enabled, ie.

"editor.smoothScrolling": true,

I can confirm that this problem no longer exists after disabling editor.smoothScrolling.

Btw, it's weird that only Typescript and Javascript language trigger this πŸ€” Will LSP affect how editor handles the jumping of cursor??

qgates commented 1 year ago

Weird, I work in TS/JS 98% of the time and didn't think to try other languages. But I can't replicate the error with .py or .php files either, so it appears you are right.

Narrowing things down to TS/JS, and the bug appearing at 1.75.0, should hopefully help the devs towards a fix. At the moment I'm having to work with smoothScrolling disabled, which UX is somewhat jarring πŸ™„

alexdima commented 1 year ago

@pionxzh @qgates I have heard similar reports recently about smoothScrolling, but I was not able to reproduce. I think that in combination with another setting or in combination with another extension, this problem is triggered. Could you please try to do a "manual bisect" on your settings (comment/uncomment other settings except smoothScrolling) to narrow down which one might be causing this?

marcselman commented 1 year ago

I'm experiencing the same issue. If I can help in any way, let me know.

qgates commented 1 year ago

@pionxzh @qgates I have heard similar reports recently about smoothScrolling, but I was not able to reproduce. I think that in combination with another setting or in combination with another extension, this problem is triggered. Could you please try to do a "manual bisect" on your settings (comment/uncomment other settings except smoothScrolling) to narrow down which one might be causing this?

@alexdima if you read the thread above, you'll see that I am having the issue with a vanilla, portable install of vscode, version 1.75.0 or later. Ie. Completely default config options, no extensions, out of the box install. I do this by downloading the vscode zip, extracting to a folder, then adding the data dir in the vscode folder per these instructions. The problem is easily reproducible (for me at least) on Win10, but only seems to occur with JS/TS files as pointed out by @pionxzh above. PHP/Python and other file types do not seem to have the issue.

I see little point in following your instructions as I'm using an entirely out of the box vscode install for testing. No extensions, default configuration, portable install. As a result please confirm whether you would still like me to follow your instructions?

Also in case you missed it the problem starts at version 1.75.0 and does not affect version 1.74.3 and lower, and only appears to occur with JS/TS files.

qgates commented 1 year ago

I'm experiencing the same issue. If I can help in any way, let me know.

Can you confirm language(s) you see the problem, vscode version and platform please thx

marcselman commented 1 year ago

@qgates I'm using version 1.76.2 on Windows 11. I only develop javascript on VSCode currently.

qgates commented 1 year ago

Here's a little screencap. At the start, I hit END 6 times before the cursor is fully scrolled into view at the line end. Afterwards, I hit HOME a total of 6 times so the cursor is fully in view at the start of the line. Observe horizontal scrollbar appearing for each keypress.

vscode-homeend-bug

qgates commented 1 year ago

More info...

The problem also does not appear if the file is fully scrolled to the top left (Line 1 Col 1), so you see I've scrolled down to line 2 being visible at the top and the problem starts to occur.

Do you see similar @marcselman @pionxzh? Are you able to reproduce @alexdima?

pionxzh commented 1 year ago

I experienced something that might be related to this. On MacOS, I can reproduce the same problem with dragging selection. The dragging will hit an invisible wall which is similar to the behavior of pressing END like this issue.

I will try recording my screen tomorrow

marcselman commented 1 year ago

@qgates You are right!

pionxzh commented 1 year ago

The problem also does not appear if the file is fully scrolled to the top left (Line 1 Col 1), so you see I've scrolled down to line 2 being visible at the top and the problem starts to occur.

I'm seeing the same.

pionxzh commented 1 year ago

I experienced something that might be related to this. On MacOS, I can reproduce the same problem with dragging selection. The dragging will hit an invisible wall which is similar to the behavior of pressing END like this issue.

I will try recording my screen tomorrow

  1. Bug with keyboard END key This also shows the behavior at top-left like what @qgates mentioned.

https://user-images.githubusercontent.com/9910706/227197727-ca6910a3-e31a-4a80-952c-2f25fd6c9dc9.mp4


  1. Bug with mouse dragging to the edge of screen

https://user-images.githubusercontent.com/9910706/227197765-3d8f42c1-95f3-45fd-a026-dbc17ac4da60.mp4

qgates commented 1 year ago

Great thanks all πŸ™‚ Hope that provides sufficient info @alexdima, not much more I can find on this but let us know if you need more info / testing etc.

@pionxzh OT, that theme Base16 Tomorrow Night? Also what font and screen recorder are you using? πŸ˜„

pionxzh commented 1 year ago

@qgates Theme: https://marketplace.visualstudio.com/items?itemName=zhuangtongfa.Material-theme Font: Consolas, Hack,'Courier New', monospace Screen Recorder: https://github.com/ShareX/ShareX

alexdima commented 1 year ago

πŸŽ‰ We were able to get reproducible steps and track down the root problem in https://github.com/microsoft/vscode/issues/179368#issuecomment-1499293621 . Let's continue tracking in #179368, a PR with a fix is under way.