Skip to content

Commit f81dfd0

Browse files
committed
Stops pushing into subscription array
1 parent ad79ac1 commit f81dfd0

File tree

5 files changed

+36
-47
lines changed

5 files changed

+36
-47
lines changed

src/codeLensController.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ export class CodeLensController extends Disposable {
1919

2020
this._onConfigurationChanged();
2121

22-
const subscriptions: Disposable[] = [];
23-
24-
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
25-
subscriptions.push(git.onDidChangeGitCache(this._onGitCacheChanged, this));
26-
22+
const subscriptions: Disposable[] = [
23+
workspace.onDidChangeConfiguration(this._onConfigurationChanged, this),
24+
git.onDidChangeGitCache(this._onGitCacheChanged, this)
25+
];
2726
this._disposable = Disposable.from(...subscriptions);
2827
}
2928

src/currentLineController.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ export class CurrentLineController extends Disposable {
4444

4545
this._onConfigurationChanged();
4646

47-
const subscriptions: Disposable[] = [];
48-
49-
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
50-
subscriptions.push(git.onDidChangeGitCache(this._onGitCacheChanged, this));
51-
subscriptions.push(annotationController.onDidToggleAnnotations(this._onFileAnnotationsToggled, this));
52-
subscriptions.push(debug.onDidStartDebugSession(this._onDebugSessionStarted, this));
53-
47+
const subscriptions: Disposable[] = [
48+
workspace.onDidChangeConfiguration(this._onConfigurationChanged, this),
49+
git.onDidChangeGitCache(this._onGitCacheChanged, this),
50+
annotationController.onDidToggleAnnotations(this._onFileAnnotationsToggled, this),
51+
debug.onDidStartDebugSession(this._onDebugSessionStarted, this)
52+
];
5453
this._disposable = Disposable.from(...subscriptions);
5554
}
5655

@@ -106,12 +105,11 @@ export class CurrentLineController extends Disposable {
106105

107106
const trackCurrentLine = cfg.statusBar.enabled || cfg.blame.line.enabled || (this._blameLineAnnotationState && this._blameLineAnnotationState.enabled);
108107
if (trackCurrentLine && !this._trackCurrentLineDisposable) {
109-
const subscriptions: Disposable[] = [];
110-
111-
subscriptions.push(window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this));
112-
subscriptions.push(window.onDidChangeTextEditorSelection(this._onTextEditorSelectionChanged, this));
113-
subscriptions.push(this.gitContextTracker.onDidChangeBlameability(this._onBlameabilityChanged, this));
114-
108+
const subscriptions: Disposable[] = [
109+
window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this),
110+
window.onDidChangeTextEditorSelection(this._onTextEditorSelectionChanged, this),
111+
this.gitContextTracker.onDidChangeBlameability(this._onBlameabilityChanged, this)
112+
];
115113
this._trackCurrentLineDisposable = Disposable.from(...subscriptions);
116114
}
117115
else if (!trackCurrentLine && this._trackCurrentLineDisposable) {

src/git/gitContextTracker.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ export class GitContextTracker extends Disposable {
2626
constructor(private git: GitService) {
2727
super(() => this.dispose());
2828

29-
const subscriptions: Disposable[] = [];
30-
31-
subscriptions.push(window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this));
32-
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
33-
subscriptions.push(workspace.onDidSaveTextDocument(this._onTextDocumentSaved, this));
34-
subscriptions.push(this.git.onDidBlameFail(this._onBlameFailed, this));
35-
subscriptions.push(this.git.onDidChangeRepo(this._onRepoChanged, this));
36-
29+
const subscriptions: Disposable[] = [
30+
window.onDidChangeActiveTextEditor(this._onActiveTextEditorChanged, this),
31+
workspace.onDidChangeConfiguration(this._onConfigurationChanged, this),
32+
workspace.onDidSaveTextDocument(this._onTextDocumentSaved, this),
33+
this.git.onDidBlameFail(this._onBlameFailed, this),
34+
this.git.onDidChangeRepo(this._onRepoChanged, this)
35+
];
3736
this._disposable = Disposable.from(...subscriptions);
3837

3938
setCommandContext(CommandContext.IsRepository, !!this.git.repoPath);

src/gitService.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,10 @@ export class GitService extends Disposable {
116116

117117
this._onConfigurationChanged();
118118

119-
const subscriptions: Disposable[] = [];
120-
121-
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
122-
subscriptions.push(RemoteProviderFactory.onDidChange(this._onRemoteProviderChanged, this));
123-
119+
const subscriptions: Disposable[] = [
120+
workspace.onDidChangeConfiguration(this._onConfigurationChanged, this),
121+
RemoteProviderFactory.onDidChange(this._onRemoteProviderChanged, this)
122+
];
124123
this._disposable = Disposable.from(...subscriptions);
125124
}
126125

@@ -156,16 +155,15 @@ export class GitService extends Disposable {
156155

157156
this._repoWatcher = this._repoWatcher || workspace.createFileSystemWatcher('**/.git/{index,HEAD,refs/stash,refs/heads/**,refs/remotes/**}');
158157

159-
const disposables: Disposable[] = [];
160-
161-
disposables.push(workspace.onDidCloseTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentClosed)));
162-
disposables.push(workspace.onDidChangeTextDocument(this._onTextDocumentChanged, this));
163-
disposables.push(workspace.onDidSaveTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentSaved)));
164-
disposables.push(this._repoWatcher.onDidChange(this._onRepoChanged, this));
165-
disposables.push(this._repoWatcher.onDidCreate(this._onRepoChanged, this));
166-
disposables.push(this._repoWatcher.onDidDelete(this._onRepoChanged, this));
167-
168-
this._cacheDisposable = Disposable.from(...disposables);
158+
const subscriptions: Disposable[] = [
159+
workspace.onDidCloseTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentClosed)),
160+
workspace.onDidChangeTextDocument(this._onTextDocumentChanged, this),
161+
workspace.onDidSaveTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentSaved)),
162+
this._repoWatcher.onDidChange(this._onRepoChanged, this),
163+
this._repoWatcher.onDidCreate(this._onRepoChanged, this),
164+
this._repoWatcher.onDidDelete(this._onRepoChanged, this)
165+
];
166+
this._cacheDisposable = Disposable.from(...subscriptions);
169167
}
170168
else {
171169
this._cacheDisposable && this._cacheDisposable.dispose();

src/keyboard.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,7 @@ export class Keyboard extends Disposable {
9999
constructor() {
100100
super(() => this.dispose());
101101

102-
const subscriptions: Disposable[] = [];
103-
104-
for (const key of keys) {
105-
subscriptions.push(commands.registerCommand(`${ExtensionKey}.key.${key}`, () => this.execute(key), this));
106-
}
107-
102+
const subscriptions = keys.map(key => commands.registerCommand(`${ExtensionKey}.key.${key}`, () => this.execute(key), this));
108103
this._disposable = Disposable.from(...subscriptions);
109104

110105
_instance = this;

0 commit comments

Comments
 (0)