mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
git: fix content provider events
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
'use strict';
|
||||
|
||||
import { Uri, Command, EventEmitter, Event, scm, commands, SourceControl, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, Disposable, ProgressLocation, window, workspace, WorkspaceEdit } from 'vscode';
|
||||
import { Git, Repository as BaseRepository, Ref, Branch, Remote, Commit, GitErrorCodes, Stash } from './git';
|
||||
import { anyEvent, eventToPromise, filterEvent, EmptyDisposable, combinedDisposable, dispose, find } from './util';
|
||||
import { Repository as BaseRepository, Ref, Branch, Remote, Commit, GitErrorCodes, Stash } from './git';
|
||||
import { anyEvent, filterEvent, eventToPromise, dispose, find } from './util';
|
||||
import { memoize, throttle, debounce } from './decorators';
|
||||
import { toGitUri } from './uri';
|
||||
import * as path from 'path';
|
||||
@@ -24,9 +24,8 @@ function getIconUri(iconName: string, theme: string): Uri {
|
||||
}
|
||||
|
||||
export enum State {
|
||||
Uninitialized,
|
||||
Idle,
|
||||
NotAGitRepository
|
||||
Disposed
|
||||
}
|
||||
|
||||
export enum Status {
|
||||
@@ -324,7 +323,7 @@ export class Repository implements Disposable {
|
||||
private _operations = new OperationsImpl();
|
||||
get operations(): Operations { return this._operations; }
|
||||
|
||||
private _state = State.Uninitialized;
|
||||
private _state = State.Idle;
|
||||
get state(): State { return this._state; }
|
||||
set state(state: State) {
|
||||
this._state = state;
|
||||
@@ -357,6 +356,10 @@ export class Repository implements Disposable {
|
||||
const onWorkspaceChange = anyEvent(fsWatcher.onDidChange, fsWatcher.onDidCreate, fsWatcher.onDidDelete);
|
||||
onWorkspaceChange(this.onFSChange, this, this.disposables);
|
||||
|
||||
const onGitChange = filterEvent(onWorkspaceChange, uri => /\/\.git\//.test(uri.path));
|
||||
const onRelevantGitChange = filterEvent(onGitChange, uri => !/\/\.git\/index\.lock$/.test(uri.path));
|
||||
onRelevantGitChange(this._onDidChangeRepository.fire, this._onDidChangeRepository, this.disposables);
|
||||
|
||||
const id = `git${Repository.handle++}`;
|
||||
const label = `Git - ${path.basename(repository.root)}`;
|
||||
|
||||
@@ -618,7 +621,7 @@ export class Repository implements Disposable {
|
||||
return result;
|
||||
} catch (err) {
|
||||
if (err.gitErrorCode === GitErrorCodes.NotAGitRepository) {
|
||||
this.state = State.NotAGitRepository;
|
||||
this.state = State.Disposed;
|
||||
}
|
||||
|
||||
throw err;
|
||||
@@ -750,9 +753,8 @@ export class Repository implements Disposable {
|
||||
let stateContextKey = '';
|
||||
|
||||
switch (this.state) {
|
||||
case State.Uninitialized: stateContextKey = 'uninitialized'; break;
|
||||
case State.Idle: stateContextKey = 'idle'; break;
|
||||
case State.NotAGitRepository: stateContextKey = 'norepo'; break;
|
||||
case State.Disposed: stateContextKey = 'norepo'; break;
|
||||
}
|
||||
|
||||
commands.executeCommand('setContext', 'gitState', stateContextKey);
|
||||
|
||||
Reference in New Issue
Block a user