From 475fb0e6cc7a51a37f842e971d7d41dc594f3010 Mon Sep 17 00:00:00 2001 From: Joao Date: Wed, 30 Aug 2017 12:48:47 +0200 Subject: [PATCH] fixes #11918 --- extensions/git/src/repository.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index e202a084512..a0ebb292a51 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -813,14 +813,25 @@ export class Repository implements Disposable { @throttle private async updateWhenIdleAndWait(): Promise { - await this.whenIdle(); + await this.whenIdleAndFocused(); await this.status(); await timeout(5000); } - private async whenIdle(): Promise { - while (!this.operations.isIdle()) { - await eventToPromise(this.onDidRunOperation); + private async whenIdleAndFocused(): Promise { + while (true) { + if (!this.operations.isIdle()) { + await eventToPromise(this.onDidRunOperation); + continue; + } + + if (!window.state.focused) { + const onDidFocusWindow = filterEvent(window.onDidChangeWindowState, e => e.focused); + await eventToPromise(onDidFocusWindow); + continue; + } + + return; } }