Bug Description:
If a change was staged by the Stage Change action contributed by vscode.git to the Dirty Diff Peek View, and the user attempts to stage another change in the same file using this action, the action stages the current change, but unstages the previously staged change.
This issue only happens in case the current workspace is a subfolder of a git repostiory. The action works correctly in a workspace that is the root folder of a git repository.
Also, it works correctly in VS Code regardless of whether the workspace is a subfolder or the root folder of a git repository.
Steps to Reproduce:
-
Open a workspace that is a subfolder of a git repository (e.g. vscode-extension-samples/helloworld-sample).
-
Open a file in the workspace, and make a few changes across the file.
-
Open the Dirty Diff Peek View for a change, and stage it with the Stage Change action in the Peek View's toolbar.
-
Open the Dirty Diff Peek View for another change, and try to stage it using the same action.
Observe that the action staged the current change, but unstaged the previous change.
Additional Information
The Stage Change action of vscode.git calls the CommandCenter._stageChanges method, which opens the original document to compute the content to be staged.
Debugging revealed that the original document was still open, but was not refreshed after step 3. Therefore, in step 4, the action computes the content to be staged based on the stale content of the original document, which causes the previous change to be unstaged in effect.
On further investigation, vscode.git uses workspace.createFileSystemWatcher to watch for file changes in the .git folder: DotGitWatcher.
In VS Code, it is a file change event from this watcher that causes the original document to be refreshed after step 3.
Theia supports the workspace.createFileSystemWatcher API, but currently only for watching files within the workspace. If the relative pattern's base is outside the workspace, like the .git folder is in case of this issue, the created watcher will not report any changes.
That's why the original document is not refreshed in Theia after step 3.
I have a fix and will submit it shortly.
- Operating System: all
- Theia Version: 1.70
Bug Description:
If a change was staged by the
Stage Changeaction contributed byvscode.gitto the Dirty Diff Peek View, and the user attempts to stage another change in the same file using this action, the action stages the current change, but unstages the previously staged change.This issue only happens in case the current workspace is a subfolder of a git repostiory. The action works correctly in a workspace that is the root folder of a git repository.
Also, it works correctly in VS Code regardless of whether the workspace is a subfolder or the root folder of a git repository.
Steps to Reproduce:
Open a workspace that is a subfolder of a git repository (e.g.
vscode-extension-samples/helloworld-sample).Open a file in the workspace, and make a few changes across the file.
Open the Dirty Diff Peek View for a change, and stage it with the
Stage Changeaction in the Peek View's toolbar.Open the Dirty Diff Peek View for another change, and try to stage it using the same action.
Observe that the action staged the current change, but unstaged the previous change.
Additional Information
The
Stage Changeaction ofvscode.gitcalls theCommandCenter._stageChangesmethod, which opens the original document to compute the content to be staged.Debugging revealed that the original document was still open, but was not refreshed after step 3. Therefore, in step 4, the action computes the content to be staged based on the stale content of the original document, which causes the previous change to be unstaged in effect.
On further investigation,
vscode.gitusesworkspace.createFileSystemWatcherto watch for file changes in the.gitfolder: DotGitWatcher.In VS Code, it is a file change event from this watcher that causes the original document to be refreshed after step 3.
Theia supports the
workspace.createFileSystemWatcherAPI, but currently only for watching files within the workspace. If the relative pattern's base is outside the workspace, like the.gitfolder is in case of this issue, the created watcher will not report any changes.That's why the original document is not refreshed in Theia after step 3.
I have a fix and will submit it shortly.