microsoft / vscode

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

Stage/unstage file, then immediately click it, no diff shown #196325

Open roblourens opened 1 year ago

roblourens commented 1 year ago

It also does the same in reverse- if I unstage a file and immediately open it, it will open "indexed" with no changes even though the tree has updated

lszomoru commented 11 months ago

This occurs due to the fact that we optimistically move the resource to "Staged Changes" before the git add command completes in order to make the UI feel more snappy. You can disable the optimistic update of the Source Control view using the git.optimisticUpdate setting.

roblourens commented 11 months ago

Can the the diff view refresh once the index updates?

lszomoru commented 11 months ago

I don't think that changing the editor (tab, contents) is the ideal solution here.

roblourens commented 11 months ago

Why not? It would be refreshing to match reality, which is what I generally expect from an editor.

lszomoru commented 11 months ago

Let me give it a try and see what the actual user experience is.

gk-bbai commented 5 months ago

I can confirm that setting "git.optimisticUpdate": false seems to fix the issue.

It's a bit odd to me that this issue doesn't have more upvotes/visibility as the default behavior breaks being able to use the diff view very often (e.g., "Undo Last Commit" could break it).