microsoft / vscode

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

using stage/unstage button leads to unexpected collapse in tree view for source control #199441

Closed eleanorjboyd closed 11 months ago

eleanorjboyd commented 11 months ago

Testing #199172

while in tree view everything looks good until I have 3 files nested under a single folder with sub folders in between. When I stage and unstage these changes in different configurations sometimes it collapses the block of folder and sometimes it doesn't. Also when it unexpectedly collapses the folders, the root folder switches from being src/client/testing/testController to src then re-expands when I click on it. If I only click to collapse a block at the root folder it stays as src/client/testing/testController . So the two bugs I can see are the collapse when staging/unstaging for some folder arrangements and when block accidentally collapse they have the wrong root node name.

(I have a video but I can't upload it rn, will try again later)

lszomoru commented 11 months ago

/gifPlease

vscodenpa commented 11 months ago

Thanks for reporting this issue! Unfortunately, it's hard for us to understand what issue you're seeing. Please help us out by providing a screen recording showing exactly what isn't working as expected. While we can work with most standard formats, .gif files are preferred as they are displayed inline on GitHub. You may find https://gifcap.dev helpful as a browser-based gif recording tool.

If the issue depends on keyboard input, you can help us by enabling screencast mode for the recording (Developer: Toggle Screencast Mode in the command palette). Lastly, please attach this file via the GitHub web interface as emailed responses will strip files out from the issue.

Happy coding!

eleanorjboyd commented 11 months ago

https://github.com/microsoft/vscode/assets/26030610/0bc52a3f-1c8d-4537-9d94-5c1262dc5fa6

lszomoru commented 11 months ago

Re-uploading the complete video for reference.

https://github.com/microsoft/vscode/assets/3372902/b691bf2e-569a-4d71-a4c2-d9e2d8c9f2f0

joaomoreno commented 11 months ago

Simple repro:

git init
mkdir -p a/b
mkdir -p a/c
touch a/b/b.txt
touch a/c/c.txt

Then in the SCM view, make sure no resource is selected (since it would trigger the auto reveal feature) and stage one file at a time:

https://github.com/microsoft/vscode/assets/22350/1ee2525a-917b-4619-9565-725ffab9571f

abhijit-chikane commented 11 months ago

I am seeing this in explorer view in todays insider

Steps to reproduce

  1. Open the explorer view unscaffold the folders
  2. Click on the different application window and then again focus the vs code editor and see the explorer files all get's collapse

Version: 1.85.0-insider (user setup) Commit: c6b48c364dde70c12bf977f1da50acda0fd801e3 Date: 2023-11-30T05:35:40.559Z Electron: 25.9.6 ElectronBuildId: 25427645 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.22621

pdanpdan commented 11 months ago

Same as above.

VS Code version: Code - Insiders 1.85.0-insider (c6b48c364dde70c12bf977f1da50acda0fd801e3, 2023-11-30T05:35:27.138Z) OS version: Linux x64 6.5.6-76060506-generic Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz (8 x 3500)| |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
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|1, 2, 2| |Memory (System)|31.06GB (19.89GB free)| |Process Argv|--unity-launch --crash-reporter-id 609a073c-e838-44e0-83cd-756d613399cf| |Screen Reader|yes| |VM|0%| |DESKTOP_SESSION|pop-wayland| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|pop-wayland| |XDG_SESSION_TYPE|wayland|
Extensions (25) Extension|Author (truncated)|Version ---|---|--- Bookmarks|ale|13.4.2 project-manager|ale|12.7.0 unocss|ant|0.57.7 color-info|bie|0.7.2 vscode-fish|bma|1.0.37 postcss|css|1.0.9 transformer|dak|1.12.1 vscode-eslint|dba|2.4.2 xml|Dot|2.5.1 gitlens|eam|2023.11.3004 vscode-html-css|ecm|1.13.1 l13-diff|L13|1.3.4 i18n-ally|lok|2.12.0 rainbow-csv|mec|3.8.0 typescript-javascript-grammar|ms-|0.0.55 vscode-typescript-next|ms-|5.4.20231129 vscode-versionlens|pfl|1.9.2 material-icon-theme|PKi|4.32.0 vscode-sort-json|ric|1.20.0 vscode-gtm|s3r|0.2.0 sass-indented|syl|1.8.28 volar|Vue|1.8.24 markdown-all-in-one|yzh|3.5.1 cursorCharCode|zei|0.2.4 vitest-explorer|Zix|0.2.43 (1 theme extensions excluded)
A/B Experiments ``` vsliv695:30137379 vsins829:30139715 vsliv368cf:30146710 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256197 vslsvsres303:30308271 pythontb:30258533 pythonptprofiler:30281269 vshan820:30294714 vscod805:30301674 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 pythonvs932:30404738 py29gd2263:30784851 vsclangdf:30492506 c4g48928:30535728 dsvsc012:30540252 a9j8j154:30646983 showlangstatbar:30737417 fixshowwlkth:30771523 showindicator:30805243 pythongtdpath:30726887 i26e3531:30792625 welcomedialog:30812478 pythonnosmt12:30779711 pythonidxpt:30768918 pythonnoceb:30776497 asynctok:30898717 dsvsc013:30777762 dsvsc014:30777825 pythonmpswarning:30901777 dsvsc015:30821418 pythontestfixt:30866404 pythonregdiag2:30902439 pyreplss1:30879911 pythonmypyd1:30859725 pythoncet0:30859736 pythontbext0:30879054 accentitlementst:30870582 dsvsc016:30879898 dsvsc017:30880771 dsvsc018:30880772 aa_t_chat:30882232 ```
joyceerhl commented 11 months ago

I still see the collapsing, and in addition the collapsed node is no longer expandable. Also, after unstaging the staged folder, I can no longer restage it

https://github.com/microsoft/vscode/assets/30305945/d5a2ba0f-e001-4519-8bae-3bbfc4f28036

pdanpdan commented 11 months ago

After latest changes things are broken big way:

Console errors after rename ```js ERR TreeError [FileExplorer] Tree element not found: [object Object]: Error: TreeError [FileExplorer] Tree element not found: [object Object] at h.getCompressedNode (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:35513) at h.isCollapsed (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:34970) at d.isCollapsed (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:37902) at k.isCollapsed (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:669) at ce.isCollapsed (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:17313) at te (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2345:41234) at ne.Bc (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2345:53049) at o.value (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2345:47561) at u.y (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:1902) at u.fire (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:2119) at vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:85:53809 at vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:4701 at vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:4822 at Array.forEach () at y.bufferEvents (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:4811) at g.setCollapsible (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:22608) at g.s (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:21857) at g.q (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:20652) at m (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:20385) at g.q (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:20565) at g.splice (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:19877) at D.l (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:28179) at D.setChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:27723) at h.i (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:33934) at h.setChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:32919) at d.setChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:37123) at k.setChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:7687) at ce.I (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:21442) at ce.I (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:25242) at ce.B (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:18581) at async ce.z (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:15640) at async ce.updateChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:15385) at async vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:1570:161947 at async Promise.all (index 0) at async r.z (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:1570:161901) ERR TreeError [FileExplorer] Tree element not found: [object Object]: Error: TreeError [FileExplorer] Tree element not found: [object Object] at h.getCompressedNode (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:35513) at h.isCollapsed (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:34970) at d.isCollapsed (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:37902) at k.isCollapsed (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:669) at ce.isCollapsed (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:17313) at te (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2345:41234) at ne.Bc (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2345:53049) at o.value (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2345:47561) at u.y (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:1902) at u.fire (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:2119) at vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:85:53809 at vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:4701 at vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:4822 at Array.forEach () at y.bufferEvents (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:87:4811) at g.setCollapsible (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:22608) at g.s (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:21857) at g.q (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:20652) at m (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:20385) at g.q (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:20724) at g.splice (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:19877) at D.l (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:28179) at D.setChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:27723) at h.i (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:33934) at h.setChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:32919) at d.setChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:190:37123) at k.setChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:7687) at ce.I (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:21442) at ce.I (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:25242) at ce.B (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:18581) at async ce.z (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:15640) at async ce.updateChildren (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:614:15385) at async ne.setEditable (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2345:44373) at async r.setEditable (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:1570:159601) at async Object.onFinish (vscode-file://vscode-app/usr/share/code-insiders/resources/app/out/vs/workbench/workbench.desktop.main.js:2345:11796) ```

Version: 1.85.0-insider Commit: 621d89f2ef4b7715f681384739820cf08dfeeecd Date: 2023-12-01T01:38:16.445Z Browser: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Code-Insiders/1.85.0-insider Chrome/114.0.5735.289 Electron/25.9.6 Safari/537.36

joaomoreno commented 11 months ago

@pdanpdan We've confirmed it. We've already frozen the Insiders build to prevent more users from getting it. We're getting fixes in and expect to have a new Insiders build in a short while.

joaomoreno commented 11 months ago

Fixing such a tiny bug has suddenly uncovered a complicated mesh of things. I'll do my best to tell the story here:

The latest additions to the SCM view made it move from an object tree to an async data tree. The move uncovered a bug in how the async data tree handles collapse state in compressed trees. My first attempt to fix this was https://github.com/microsoft/vscode/pull/199591. My fix was incomplete and caused undesired behavior.

At the same time, @lszomoru looked into using the diffIdentityProvider tree feature to fix a performance regression, with https://github.com/microsoft/vscode/pull/199679. Part of @lszomoru's fix contains a fix in tree infrastructure in which an options bag just wasn't properly being passed around. Any compressible async data tree that attempted to use diffIdentityProvider simply wasn't getting it working at all because the provider wasn't passed around to all the layers. Before this, only another tree was both compressible and async and used diffIdentityProvider: the Explorer. Back in 2021, @isidorn adopted this with https://github.com/microsoft/vscode/commit/9b1d85bad8cd752c4657627424edfa58dd5ce4aa, but did not recognize that the option didn't work. Now that the diffIdentityProvider is leveraged by the Explorer view, bugs appear:

https://github.com/microsoft/vscode/assets/22350/4feb14e8-de46-4f62-8372-549e3b1aaa7a

But why do twisties disappear? I've traced it down to https://github.com/microsoft/vscode/commit/a8dd7f60a6204353e8d6969c8bc39f0476d46e2a, a change by @connor4312 down in the index tree model also from 2021. This change doesn't look good to me since it defines that nodes should not be collapsible if they have no children... empty Explorer folders are good counter examples: they are collapsible elements with zero children.


To fix today's Insiders, we've frozen the broken build and will release a new build with https://github.com/microsoft/vscode/pull/199756 which reverts to the initial state of not having diffIdentityProvider working in the Explorer. Note this is identical to simply removing diffIdentityProvider from the Explorer's updateChildren call. This second Insiders build will have a stable Explorer state and a functioning SCM state with the exception of this issue's bug.

We have three options to move forward:

  1. We keep this SCM bug in the upcoming November release. It's a minor bug, repros only when in tree mode and only in specific operations involving compressed tree nodes.
  2. We work around the bug by changing how SCM calls in to the tree widget. @lszomoru suspects there's a viable workaround, pending confirmation.
  3. We fix this issue with my second attempt. Highest risk, but preferred outcome.

Regardless, we should follow up on the rest:

connor4312 commented 11 months ago

Good findings, Joao! As mentioned in the comment on that issue, I think that commit is good to revert. Reverting it doesn't seem to have negative effects in trees that use the diffIdentityProvider, as far as I can tell. Unfortunately I don't recall why I initially had it added.

Please let me know if any further issues are observed with diffIdentityProvider. It should work for the explorer and would make rendering more efficient there as it does elsewhere. I'm happy to help with any difficulties encountered during the adoption.

The main footgun generally found during its adoption, which the explorer may encounter, is cases where a tree is implicitly expected to rerender elements which have the same identity when setChildren is called. The general way I deal with this is having emitters or observables on the items which are listened to by the renderer to update any visible templates.