Browse Source

Stops pushing into subscription array

main
Eric Amodio 7 years ago
parent
commit
f81dfd03ca
5 changed files with 36 additions and 47 deletions
  1. +4
    -5
      src/codeLensController.ts
  2. +11
    -13
      src/currentLineController.ts
  3. +7
    -8
      src/git/gitContextTracker.ts
  4. +13
    -15
      src/gitService.ts
  5. +1
    -6
      src/keyboard.ts

+ 4
- 5
src/codeLensController.ts View File

@ -19,11 +19,10 @@ export class CodeLensController extends Disposable {
this._onConfigurationChanged();
const subscriptions: Disposable[] = [];
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
subscriptions.push(git.onDidChangeGitCache(this._onGitCacheChanged, this));
const subscriptions: Disposable[] = [
workspace.onDidChangeConfiguration(this._onConfigurationChanged, this),
git.onDidChangeGitCache(this._onGitCacheChanged, this)
];
this._disposable = Disposable.from(...subscriptions);
}

+ 11
- 13
src/currentLineController.ts View File

@ -44,13 +44,12 @@ export class CurrentLineController extends Disposable {
this._onConfigurationChanged();
const subscriptions: Disposable[] = [];
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
subscriptions.push(git.onDidChangeGitCache(this._onGitCacheChanged, this));
subscriptions.push(annotationController.onDidToggleAnnotations(this._onFileAnnotationsToggled, this));
subscriptions.push(debug.onDidStartDebugSession(this._onDebugSessionStarted, this));
const subscriptions: Disposable[] = [
workspace.onDidChangeConfiguration(this._onConfigurationChanged, this),
git.onDidChangeGitCache(this._onGitCacheChanged, this),
annotationController.onDidToggleAnnotations(this._onFileAnnotationsToggled, this),
debug.onDidStartDebugSession(this._onDebugSessionStarted, this)
];
this._disposable = Disposable.from(...subscriptions);
}
@ -106,12 +105,11 @@ export class CurrentLineController extends Disposable {
const trackCurrentLine = cfg.statusBar.enabled || cfg.blame.line.enabled || (this._blameLineAnnotationState && this._blameLineAnnotationState.enabled);
if (trackCurrentLine && !this._trackCurrentLineDisposable) {
const subscriptions: Disposable[] = [];
subscriptions.push(window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this));
subscriptions.push(window.onDidChangeTextEditorSelection(this._onTextEditorSelectionChanged, this));
subscriptions.push(this.gitContextTracker.onDidChangeBlameability(this._onBlameabilityChanged, this));
const subscriptions: Disposable[] = [
window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this),
window.onDidChangeTextEditorSelection(this._onTextEditorSelectionChanged, this),
this.gitContextTracker.onDidChangeBlameability(this._onBlameabilityChanged, this)
];
this._trackCurrentLineDisposable = Disposable.from(...subscriptions);
}
else if (!trackCurrentLine && this._trackCurrentLineDisposable) {

+ 7
- 8
src/git/gitContextTracker.ts View File

@ -26,14 +26,13 @@ export class GitContextTracker extends Disposable {
constructor(private git: GitService) {
super(() => this.dispose());
const subscriptions: Disposable[] = [];
subscriptions.push(window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this));
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
subscriptions.push(workspace.onDidSaveTextDocument(this._onTextDocumentSaved, this));
subscriptions.push(this.git.onDidBlameFail(this._onBlameFailed, this));
subscriptions.push(this.git.onDidChangeRepo(this._onRepoChanged, this));
const subscriptions: Disposable[] = [
window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this),
workspace.onDidChangeConfiguration(this._onConfigurationChanged, this),
workspace.onDidSaveTextDocument(this._onTextDocumentSaved, this),
this.git.onDidBlameFail(this._onBlameFailed, this),
this.git.onDidChangeRepo(this._onRepoChanged, this)
];
this._disposable = Disposable.from(...subscriptions);
setCommandContext(CommandContext.IsRepository, !!this.git.repoPath);

+ 13
- 15
src/gitService.ts View File

@ -116,11 +116,10 @@ export class GitService extends Disposable {
this._onConfigurationChanged();
const subscriptions: Disposable[] = [];
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
subscriptions.push(RemoteProviderFactory.onDidChange(this._onRemoteProviderChanged, this));
const subscriptions: Disposable[] = [
workspace.onDidChangeConfiguration(this._onConfigurationChanged, this),
RemoteProviderFactory.onDidChange(this._onRemoteProviderChanged, this)
];
this._disposable = Disposable.from(...subscriptions);
}
@ -156,16 +155,15 @@ export class GitService extends Disposable {
this._repoWatcher = this._repoWatcher || workspace.createFileSystemWatcher('**/.git/{index,HEAD,refs/stash,refs/heads/**,refs/remotes/**}');
const disposables: Disposable[] = [];
disposables.push(workspace.onDidCloseTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentClosed)));
disposables.push(workspace.onDidChangeTextDocument(this._onTextDocumentChanged, this));
disposables.push(workspace.onDidSaveTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentSaved)));
disposables.push(this._repoWatcher.onDidChange(this._onRepoChanged, this));
disposables.push(this._repoWatcher.onDidCreate(this._onRepoChanged, this));
disposables.push(this._repoWatcher.onDidDelete(this._onRepoChanged, this));
this._cacheDisposable = Disposable.from(...disposables);
const subscriptions: Disposable[] = [
workspace.onDidCloseTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentClosed)),
workspace.onDidChangeTextDocument(this._onTextDocumentChanged, this),
workspace.onDidSaveTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentSaved)),
this._repoWatcher.onDidChange(this._onRepoChanged, this),
this._repoWatcher.onDidCreate(this._onRepoChanged, this),
this._repoWatcher.onDidDelete(this._onRepoChanged, this)
];
this._cacheDisposable = Disposable.from(...subscriptions);
}
else {
this._cacheDisposable && this._cacheDisposable.dispose();

+ 1
- 6
src/keyboard.ts View File

@ -99,12 +99,7 @@ export class Keyboard extends Disposable {
constructor() {
super(() => this.dispose());
const subscriptions: Disposable[] = [];
for (const key of keys) {
subscriptions.push(commands.registerCommand(`${ExtensionKey}.key.${key}`, () => this.execute(key), this));
}
const subscriptions = keys.map(key => commands.registerCommand(`${ExtensionKey}.key.${key}`, () => this.execute(key), this));
this._disposable = Disposable.from(...subscriptions);
_instance = this;

Loading…
Cancel
Save