|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 |
| -import { DecorationOptions, l10n, Position, Range, TextEditor, TextEditorChange, TextEditorDecorationType, TextEditorChangeKind, ThemeColor, Uri, window, workspace, EventEmitter } from 'vscode'; |
| 6 | +import { DecorationOptions, l10n, Position, Range, TextEditor, TextEditorChange, TextEditorDecorationType, TextEditorChangeKind, ThemeColor, Uri, window, workspace, EventEmitter, ConfigurationChangeEvent } from 'vscode'; |
7 | 7 | import { Model } from './model';
|
8 |
| -import { dispose, fromNow, IDisposable, pathEquals, runAndSubscribeEvent } from './util'; |
| 8 | +import { dispose, fromNow, IDisposable, pathEquals } from './util'; |
9 | 9 | import { Repository } from './repository';
|
10 | 10 | import { throttle } from './decorators';
|
11 | 11 | import { BlameInformation } from './git';
|
@@ -274,21 +274,32 @@ class GitBlameEditorDecoration {
|
274 | 274 | });
|
275 | 275 | this._disposables.push(this._decorationType);
|
276 | 276 |
|
277 |
| - this._disposables.push(runAndSubscribeEvent(workspace.onDidChangeConfiguration, e => { |
278 |
| - if (!e || e?.affectsConfiguration('git.blame.editorDecoration.enabled')) { |
279 |
| - for (const textEditor of window.visibleTextEditors) { |
280 |
| - this._updateDecorations(textEditor); |
281 |
| - } |
| 277 | + workspace.onDidChangeConfiguration(this._onDidChangeConfiguration, this, this._disposables); |
| 278 | + this._controller.onDidChangeBlameInformation(e => this._updateDecorations(e), this, this._disposables); |
| 279 | + } |
| 280 | + |
| 281 | + private _onDidChangeConfiguration(e: ConfigurationChangeEvent): void { |
| 282 | + if (!e.affectsConfiguration('git.blame.editorDecoration.enabled')) { |
| 283 | + return; |
| 284 | + } |
| 285 | + |
| 286 | + const enabled = this._isEnabled(); |
| 287 | + for (const textEditor of window.visibleTextEditors) { |
| 288 | + if (enabled) { |
| 289 | + this._updateDecorations(textEditor); |
| 290 | + } else { |
| 291 | + textEditor.setDecorations(this._decorationType, []); |
282 | 292 | }
|
283 |
| - })); |
| 293 | + } |
| 294 | + } |
284 | 295 |
|
285 |
| - this._controller.onDidChangeBlameInformation(e => this._updateDecorations(e), this, this._disposables); |
| 296 | + private _isEnabled(): boolean { |
| 297 | + const config = workspace.getConfiguration('git'); |
| 298 | + return config.get<boolean>('blame.editorDecoration.enabled', false); |
286 | 299 | }
|
287 | 300 |
|
288 | 301 | private _updateDecorations(textEditor: TextEditor): void {
|
289 |
| - const enabled = workspace.getConfiguration('git').get<boolean>('blame.editorDecoration.enabled', false); |
290 |
| - if (!enabled) { |
291 |
| - textEditor.setDecorations(this._decorationType, []); |
| 302 | + if (!this._isEnabled()) { |
292 | 303 | return;
|
293 | 304 | }
|
294 | 305 |
|
|
0 commit comments