Browse Source

Removes unneeded arrays

main
Eric Amodio 7 years ago
parent
commit
bfdcaad496
6 changed files with 21 additions and 31 deletions
  1. +4
    -7
      src/annotations/annotationController.ts
  2. +2
    -3
      src/annotations/annotationProvider.ts
  3. +2
    -3
      src/codeLensController.ts
  4. +4
    -6
      src/currentLineController.ts
  5. +3
    -4
      src/git/gitContextTracker.ts
  6. +6
    -8
      src/gitService.ts

+ 4
- 7
src/annotations/annotationController.ts View File

@ -66,10 +66,9 @@ export class AnnotationController extends Disposable {
this.onConfigurationChanged(); this.onConfigurationChanged();
const subscriptions: Disposable[] = [
this._disposable = Disposable.from(
workspace.onDidChangeConfiguration(this.onConfigurationChanged, this) workspace.onDidChangeConfiguration(this.onConfigurationChanged, this)
];
this._disposable = Disposable.from(...subscriptions);
);
} }
dispose() { dispose() {
@ -389,16 +388,14 @@ export class AnnotationController extends Disposable {
if (!this._annotationsDisposable && this._annotationProviders.size === 0) { if (!this._annotationsDisposable && this._annotationProviders.size === 0) {
Logger.log(`Add listener registrations for annotations`); Logger.log(`Add listener registrations for annotations`);
const subscriptions: Disposable[] = [
this._annotationsDisposable = Disposable.from(
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveTextEditorChanged, 50), this), window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveTextEditorChanged, 50), this),
window.onDidChangeTextEditorViewColumn(this.onTextEditorViewColumnChanged, this), window.onDidChangeTextEditorViewColumn(this.onTextEditorViewColumnChanged, this),
window.onDidChangeVisibleTextEditors(this.onVisibleTextEditorsChanged, this), window.onDidChangeVisibleTextEditors(this.onVisibleTextEditorsChanged, this),
workspace.onDidChangeTextDocument(Functions.debounce(this.onTextDocumentChanged, 50), this), workspace.onDidChangeTextDocument(Functions.debounce(this.onTextDocumentChanged, 50), this),
workspace.onDidCloseTextDocument(this.onTextDocumentClosed, this), workspace.onDidCloseTextDocument(this.onTextDocumentClosed, this),
this.gitContextTracker.onDidChangeBlameability(this.onBlameabilityChanged, this) this.gitContextTracker.onDidChangeBlameability(this.onBlameabilityChanged, this)
];
this._annotationsDisposable = Disposable.from(...subscriptions);
);
} }
this._annotationProviders.set(provider.correlationKey, provider); this._annotationProviders.set(provider.correlationKey, provider);

+ 2
- 3
src/annotations/annotationProvider.ts View File

@ -33,10 +33,9 @@ export abstract class AnnotationProviderBase extends Disposable {
this._config = workspace.getConfiguration().get<IConfig>(ExtensionKey)!; this._config = workspace.getConfiguration().get<IConfig>(ExtensionKey)!;
const subscriptions: Disposable[] = [
this._disposable = Disposable.from(
window.onDidChangeTextEditorSelection(this.onTextEditorSelectionChanged, this) window.onDidChangeTextEditorSelection(this.onTextEditorSelectionChanged, this)
];
this._disposable = Disposable.from(...subscriptions);
);
} }
async dispose() { async dispose() {

+ 2
- 3
src/codeLensController.ts View File

@ -23,11 +23,10 @@ export class CodeLensController extends Disposable {
this.onConfigurationChanged(); this.onConfigurationChanged();
const subscriptions: Disposable[] = [
this._disposable = Disposable.from(
workspace.onDidChangeConfiguration(this.onConfigurationChanged, this), workspace.onDidChangeConfiguration(this.onConfigurationChanged, this),
this.gitContextTracker.onDidChangeBlameability(this.onBlameabilityChanged, this) this.gitContextTracker.onDidChangeBlameability(this.onBlameabilityChanged, this)
];
this._disposable = Disposable.from(...subscriptions);
);
} }
dispose() { dispose() {

+ 4
- 6
src/currentLineController.ts View File

@ -51,12 +51,11 @@ export class CurrentLineController extends Disposable {
this.onConfigurationChanged(); this.onConfigurationChanged();
const subscriptions: Disposable[] = [
this._disposable = Disposable.from(
workspace.onDidChangeConfiguration(this.onConfigurationChanged, this), workspace.onDidChangeConfiguration(this.onConfigurationChanged, this),
annotationController.onDidToggleAnnotations(this.onFileAnnotationsToggled, this), annotationController.onDidToggleAnnotations(this.onFileAnnotationsToggled, this),
debug.onDidStartDebugSession(this.onDebugSessionStarted, this) debug.onDidStartDebugSession(this.onDebugSessionStarted, this)
];
this._disposable = Disposable.from(...subscriptions);
);
} }
dispose() { dispose() {
@ -116,12 +115,11 @@ export class CurrentLineController extends Disposable {
const trackCurrentLine = cfg.statusBar.enabled || cfg.blame.line.enabled || (this._blameLineAnnotationState !== undefined && this._blameLineAnnotationState.enabled); const trackCurrentLine = cfg.statusBar.enabled || cfg.blame.line.enabled || (this._blameLineAnnotationState !== undefined && this._blameLineAnnotationState.enabled);
if (trackCurrentLine && !this._trackCurrentLineDisposable) { if (trackCurrentLine && !this._trackCurrentLineDisposable) {
const subscriptions: Disposable[] = [
this._trackCurrentLineDisposable = Disposable.from(
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveTextEditorChanged, 50), this), window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveTextEditorChanged, 50), this),
window.onDidChangeTextEditorSelection(this.onTextEditorSelectionChanged, this), window.onDidChangeTextEditorSelection(this.onTextEditorSelectionChanged, this),
this.gitContextTracker.onDidChangeBlameability(this.onBlameabilityChanged, this) this.gitContextTracker.onDidChangeBlameability(this.onBlameabilityChanged, this)
];
this._trackCurrentLineDisposable = Disposable.from(...subscriptions);
);
} }
else if (!trackCurrentLine && this._trackCurrentLineDisposable) { else if (!trackCurrentLine && this._trackCurrentLineDisposable) {
this._trackCurrentLineDisposable.dispose(); this._trackCurrentLineDisposable.dispose();

+ 3
- 4
src/git/gitContextTracker.ts View File

@ -53,14 +53,13 @@ export class GitContextTracker extends Disposable {
setCommandContext(CommandContext.Enabled, gitEnabled); setCommandContext(CommandContext.Enabled, gitEnabled);
if (gitEnabled) { if (gitEnabled) {
const subscriptions: Disposable[] = [
this._disposable = Disposable.from(
window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveTextEditorChanged, 50), this), window.onDidChangeActiveTextEditor(Functions.debounce(this.onActiveTextEditorChanged, 50), this),
workspace.onDidChangeConfiguration(this.onConfigurationChanged, this), workspace.onDidChangeConfiguration(this.onConfigurationChanged, this),
workspace.onDidChangeTextDocument(Functions.debounce(this.onTextDocumentChanged, 50), this), workspace.onDidChangeTextDocument(Functions.debounce(this.onTextDocumentChanged, 50), this),
this.git.onDidBlameFail(this.onBlameFailed, this), this.git.onDidBlameFail(this.onBlameFailed, this),
this.git.onDidChangeRepo(this.onRepoChanged, this)
];
this._disposable = Disposable.from(...subscriptions);
this.git.onDidChange(this.onGitChanged, this)
);
this.updateContext(BlameabilityChangeReason.EditorChanged, window.activeTextEditor, true); this.updateContext(BlameabilityChangeReason.EditorChanged, window.activeTextEditor, true);
} }

+ 6
- 8
src/gitService.ts View File

@ -117,13 +117,12 @@ export class GitService extends Disposable {
this.onConfigurationChanged(); this.onConfigurationChanged();
this._repositoriesPromise = this.onWorkspaceFoldersChanged(); this._repositoriesPromise = this.onWorkspaceFoldersChanged();
const subscriptions: Disposable[] = [
this._disposable = Disposable.from(
window.onDidChangeWindowState(this.onWindowStateChanged, this), window.onDidChangeWindowState(this.onWindowStateChanged, this),
workspace.onDidChangeConfiguration(this.onConfigurationChanged, this), workspace.onDidChangeConfiguration(this.onConfigurationChanged, this),
workspace.onDidChangeWorkspaceFolders(this.onWorkspaceFoldersChanged, this), workspace.onDidChangeWorkspaceFolders(this.onWorkspaceFoldersChanged, this),
RemoteProviderFactory.onDidChange(this.onRemoteProviderChanged, this)
];
this._disposable = Disposable.from(...subscriptions);
RemoteProviderFactory.onDidChange(this.onRemoteProvidersChanged, this)
);
} }
dispose() { dispose() {
@ -162,11 +161,10 @@ export class GitService extends Disposable {
if (cfg.advanced.caching.enabled) { if (cfg.advanced.caching.enabled) {
this._cacheDisposable && this._cacheDisposable.dispose(); this._cacheDisposable && this._cacheDisposable.dispose();
const subscriptions: Disposable[] = [
this._cacheDisposable = Disposable.from(
workspace.onDidChangeTextDocument(Functions.debounce(this.onTextDocumentChanged, 50), this), workspace.onDidChangeTextDocument(Functions.debounce(this.onTextDocumentChanged, 50), this),
workspace.onDidCloseTextDocument(this.onTextDocumentClosed, this) workspace.onDidCloseTextDocument(this.onTextDocumentClosed, this)
];
this._cacheDisposable = Disposable.from(...subscriptions);
);
} }
else { else {
this._cacheDisposable && this._cacheDisposable.dispose(); this._cacheDisposable && this._cacheDisposable.dispose();
@ -190,7 +188,7 @@ export class GitService extends Disposable {
} }
} }
private onRemoteProviderChanged() {
private onRemoteProvidersChanged() {
this._remotesCache.clear(); this._remotesCache.clear();
this.fireRepoChange(RepoChangedReasons.Remotes); this.fireRepoChange(RepoChangedReasons.Remotes);
} }

Loading…
Cancel
Save