Skip to content

Commit cca3808

Browse files
authored
Refresh open file on pull (#1090)
* Refresh open file on pull Currently doing a pull does not update the contents of open files like switches branches does. Fixes #1086 * Fix failing test by adding null check and awaits
1 parent ea724f2 commit cca3808

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/model.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,8 @@ export class GitExtension implements IGitExtension {
824824
*/
825825
async pull(auth?: Git.IAuth): Promise<Git.IResultWithMessage> {
826826
const path = await this._getPathRepository();
827-
const data = this._taskHandler.execute<Git.IResultWithMessage>(
827+
const previousHead = this._currentBranch?.top_commit;
828+
const data = await this._taskHandler.execute<Git.IResultWithMessage>(
828829
'git:pull',
829830
async () => {
830831
return await requestAPI<Git.IResultWithMessage>(
@@ -840,7 +841,9 @@ export class GitExtension implements IGitExtension {
840841
);
841842
}
842843
);
843-
this.refreshBranch(); // Will emit headChanged if required
844+
const changes = await this._changedFiles(previousHead, 'HEAD');
845+
changes?.files?.forEach(file => this._revertFile(file));
846+
await this.refreshBranch(); // Will emit headChanged if required
844847
return data;
845848
}
846849

0 commit comments

Comments
 (0)