microsoft / vscode

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

Source Control unsaved changes warning behaves unexpectedly #190315

Closed hrueger closed 1 year ago

hrueger commented 1 year ago

Type: Bug

Hi, I'm not sure if you can really call this a bug, but it certainly behaves different than one would think. Maybe it's worth an improvement.

Basically, I'm lazy and usually don't stage changes before I commit them using the source control panel in the sidebar. I've set the setting Git: Enable Smart Commit to on. It commits all changes if there are no staged changes.

When there is an unsaved file, I get a warning like this:

The following file has unsaved changes which won't be included in the commit if you proceed: [...]
Would you like to save it before committing?

grafik

when I now press Save All & Commit, instead of adding this file to the commit, it only commits this one. This is probably due to that file being saved, staged and then commited. As there's now a staged file, the other ones are not committed.

Does that make sense?

Thanks in advance Hannes

VS Code version: Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794, 2023-08-09T22:22:42.175Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz (12 x 3696)| |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: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.96GB (4.79GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (60) Extension|Author (truncated)|Version ---|---|--- vscode-sql-formatter|adp|1.4.4 ng-template|Ang|16.1.8 vscode-intelephense-client|bme|1.9.5 dart-code|Dar|3.70.0 flutter|Dar|3.70.0 mustache|daw|1.1.1 vscode-eslint|dba|2.4.2 FreeMarker|dco|0.0.9 devicescript-vscode|dev|2.14.14 gitlens|eam|14.2.1 prettier-vscode|esb|10.1.0 php-intellisense|fel|2.3.14 auto-close-tag|for|0.5.14 auto-rename-tag|for|0.1.10 copilot|Git|1.101.317 copilot-labs|Git|0.14.884 vscode-github-actions|git|0.26.1 vscode-pull-request-github|Git|0.70.0 hcl|has|0.3.2 Angular2|joh|16.0.1 vscode-json5|mrm|1.0.0 vscode-docker|ms-|1.26.0 vscode-language-pack-de|MS-|1.81.2023080209 vscode-dotnet-runtime|ms-|1.6.0 playwright|ms-|1.0.15 isort|ms-|2023.10.1 python|ms-|2023.14.0 vscode-pylance|ms-|2023.8.20 remote-containers|ms-|0.304.0 remote-ssh|ms-|0.102.0 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.81.0 vscode-remote-extensionpack|ms-|0.24.0 cpptools|ms-|1.16.3 hexeditor|ms-|1.9.12 remote-explorer|ms-|0.4.1 remote-server|ms-|1.4.0 vsliveshare|ms-|1.0.5877 vscode-streamdeck|nic|4.1.6 pico-w-go|pau|3.2.1 vscode-versionlens|pfl|1.5.0 platformio-ide|pla|3.3.1 prisma|Pri|5.1.0 sqlite-viewer|qwt|0.3.13 vscode-xml|red|0.26.1 vscode-sort-json|ric|1.20.0 markdown-preview-enhanced|shd|0.6.8 svg-preview|Sim|2.8.3 vscode-stripe|str|2.0.14 svelte-vscode|sve|107.10.0 even-better-toml|tam|0.19.2 simple-php-formatter|tob|0.0.1 sort-lines|Tyr|1.10.2 vscode-counter|uct|3.2.1 adb-interface-vscode|vin|0.22.4 keyoti-changeallendoflinesequence|vs-|0.0.3 vscode-icons|vsc|12.5.0 html-css-class-completion|Zig|1.20.0 linkerscript|Zix|1.0.3 vscode-proto3|zxh|0.5.5
Gobinath-B commented 1 year ago

Does that make sense?

@hrueger did you try the option above the Git: Smart Commit Changes

Git: Smart Commit Changes
Control which changes are automatically staged by Smart Commit.

This option is in all it will automatically stage all the changes.[default option] if the option is in tracked it will automatically stage the tracked changes only.

image

hrueger commented 1 year ago

Hi @Gobinath-B that setting is set to default (all).

Gobinath-B commented 1 year ago

Hello @hrueger Can you please try the alternative option that is tracked and let me know whether you still face this issue.

hrueger commented 1 year ago

Hi @Gobinath-B, sure, tracked shows the same problem (assuming none of the files I'm working with is untracked).

Gobinath-B commented 1 year ago

@hrueger , now i could reproduce this issue

The following file has unsaved changes which won't be included in the commit if you proceed: [...] Would you like to save it before committing?

Can you please explain this issue you mentioned step by step

when I now press Save All & Commit, instead of adding this file to the commit, it only commits this one. This is probably due to that file being saved, staged and then commited. As there's now a staged file, the other ones are not committed.

hrueger commented 1 year ago

@Gobinath-B sure.

  1. Enable Git: Enable Smart Commit in settings
  2. Change a file and save it
  3. Change another file, but don't save it
  4. Input a commit message and press commit. Now, you're being asked if the unsaved file should be saved and included in the commit
  5. If you press yes, you would expect it to be included in the commit together with the other (saved) files. However, it now only commits the previously unsaved file and not the other ones.

Edit: The second part of that message you cited was my guess why that happens. As confirming the prompt saves and stages the file, there are now staged changes, that is probably why Smart Commit does not kick in and the other files are not committed.

Gobinath-B commented 1 year ago

@hrueger thanks man.

Now i can reproduce the whole issue and totally understand the problem

hrueger commented 1 year ago

You're welcome 👍 Thanks for taking a look at that.

Gobinath-B commented 1 year ago

hello @lszomoru ,

I am super interesting to fix this bug.

Gobinath-B commented 1 year ago

@lszomoru I resolved this issue and raised a pull request. Kindly review the PR.

Gobinath-B commented 1 year ago

hello @bpasero sir, I think @lszomoru sir is not available, I fixed this issue and raised PR 4 days ago. Can you please review my Pull Request code or assign a reviewer.

Gobinath-B commented 1 year ago

@VSCodeTriageBot label this issue as a bug

Gobinath-B commented 1 year ago

@lszomoru I fixed this issue and raised a pull request #190326 .Please review the code and merge it with main .

lszomoru commented 1 year ago

Closing this as duplicate of https://github.com/microsoft/vscode/issues/190657.