mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
git: fix content provider events
This commit is contained in:
@@ -51,8 +51,6 @@ export class GitContentProvider {
|
||||
}
|
||||
|
||||
private fireChangeEvents(): void {
|
||||
this.changedRepositoryRoots.clear();
|
||||
|
||||
Object.keys(this.cache).forEach(key => {
|
||||
const uri = this.cache[key].uri;
|
||||
const fsPath = uri.fsPath;
|
||||
@@ -64,6 +62,8 @@ export class GitContentProvider {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.changedRepositoryRoots.clear();
|
||||
}
|
||||
|
||||
async provideTextDocumentContent(uri: Uri): Promise<string> {
|
||||
|
||||
@@ -42,9 +42,10 @@ export class Model {
|
||||
|
||||
this.repositories.set(root, repository);
|
||||
|
||||
const onDidDisappearRepository = filterEvent(repository.onDidChangeState, state => state === State.NotAGitRepository);
|
||||
const onDidDisappearRepository = filterEvent(repository.onDidChangeState, state => state === State.Disposed);
|
||||
const disappearListener = onDidDisappearRepository(() => disposable.dispose());
|
||||
const changeListener = repository.onDidChangeRepository(uri => this._onDidChangeRepository.fire({ repository, uri }));
|
||||
|
||||
const disposable = toDisposable(once(() => {
|
||||
disappearListener.dispose();
|
||||
changeListener.dispose();
|
||||
@@ -106,30 +107,6 @@ export class Model {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// private async assertIdleState(): Promise<void> {
|
||||
// if (this.state === State.Idle) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const disposables: Disposable[] = [];
|
||||
// const repositoryRoot = await this.git.getRepositoryRoot(this.workspaceRoot.fsPath);
|
||||
// this.repository = this.git.open(repositoryRoot);
|
||||
|
||||
// const onGitChange = filterEvent(this.onWorkspaceChange, uri => /\/\.git\//.test(uri.path));
|
||||
// const onRelevantGitChange = filterEvent(onGitChange, uri => !/\/\.git\/index\.lock$/.test(uri.path));
|
||||
|
||||
// onRelevantGitChange(this.onFSChange, this, disposables);
|
||||
// onRelevantGitChange(this._onDidChangeRepository.fire, this._onDidChangeRepository, disposables);
|
||||
|
||||
// const onNonGitChange = filterEvent(this.onWorkspaceChange, uri => !/\/\.git\//.test(uri.path));
|
||||
// onNonGitChange(this.onFSChange, this, disposables);
|
||||
|
||||
// this.repositoryDisposable = combinedDisposable(disposables);
|
||||
// this.isRepositoryHuge = false;
|
||||
// this.didWarnAboutLimit = false;
|
||||
// this.state = State.Idle;
|
||||
// }
|
||||
|
||||
dispose(): void {
|
||||
for (let [, repository] of this.repositories) {
|
||||
repository.dispose();
|
||||
|
||||
@@ -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