microsoft / vscode

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

Unexpected auto-scroll behavior when unfolding #209606

Open cdoublev opened 7 months ago

cdoublev commented 7 months ago

Type: Bug

The editor window is automatically scrolled down when I unfold code located near the top.

https://github.com/microsoft/vscode/assets/15889080/9dd42fea-0aea-46e9-8e44-6b3592d53584

I do not understand how this auto-scroll behavior is supposed to be helpful, so I assume this is a bug.

If this behavior is expected, how can it be configured/disabled?

VS Code version: Code 1.88.0 (5c3e652f63e798a5ac2f31ffd0d863669328dc4c, 2024-04-03T13:26:18.741Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-3612QM CPU @ 2.10GHz (8 x 2095)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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_graphite: disabled_off
video_decode: enabled
video_encode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|7.87GB (1.73GB free)| |Process Argv|--crash-reporter-id d4301f96-6ebc-470f-8272-93bac97e98eb| |Screen Reader|no| |VM|0%|
Extensions (1) Extension|Author (truncated)|Version ---|---|--- postcss|css|1.0.9
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:31000449 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 d34g3935:30971562 fegfb526:30981948 bg6jg535:30979843 ccp2r6:30993542 dsvsc020:30976470 pythonait:31006305 gee8j676:31009558 dsvsc021:30996838 g1icg217:30999571 ```
aeschli commented 7 months ago

folding uses revealPositionInCenterIfOutsideViewport to make sure the folded range is visible.

@cdoublev Does it only happen when the folding range is close to the top of the editor? Do you have sticky scroll enabled? If yes it could be this: https://github.com/microsoft/vscode/blob/94f7c1d971f71d70cdef7b7ed461f399162d08c3/src/vs/editor/browser/viewParts/lines/viewLines.ts#L715

cdoublev commented 7 months ago

Yes to both questions. It does not happens with editor.stickyScroll.enabled unset. Thanks!

Should you/I close this issue or do you think the way the distance (paddingTop) is computed should be improved?

aeschli commented 7 months ago

I let the editor team decide. It's a hacky/pragmatic solution, and maybe there's a better way.