From fa9f119a7ea2ac26e70d48e550f5c1234f234753 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 3 Apr 2019 02:03:33 -0400 Subject: [PATCH] Closes #382 - re-allows line blame when debugging --- CHANGELOG.md | 4 ++ src/annotations/lineAnnotationController.ts | 61 ++++++----------------------- src/config.ts | 2 +- src/hovers/lineHoverController.ts | 32 ++------------- 4 files changed, 21 insertions(+), 78 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fec9cb..3386b1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Improves the behavior of the _Open Changes with Working File_ (`gitlens.diffWithWorking`) command when in the diff editor - Updates the invite link to the [VS Code Development Community Slack](https://vscode-slack.amod.io) +### Removed + +- Removes the automatic suspension of the current line blame annotations while debugging — closes [#382](https://github.com/eamodio/vscode-gitlens/issues/382) + ### Fixed - Fixes [#683](https://github.com/eamodio/vscode-gitlens/issues/683) - log.showSignature leads to stray files being displayed diff --git a/src/annotations/lineAnnotationController.ts b/src/annotations/lineAnnotationController.ts index bbfdcca..a2c9668 100644 --- a/src/annotations/lineAnnotationController.ts +++ b/src/annotations/lineAnnotationController.ts @@ -1,7 +1,6 @@ 'use strict'; import { ConfigurationChangeEvent, - debug, DecorationOptions, DecorationRangeBehavior, Disposable, @@ -27,15 +26,13 @@ const annotationDecoration: TextEditorDecorationType = window.createTextEditorDe export class LineAnnotationController implements Disposable { private _disposable: Disposable; - private _debugSessionEndDisposable: Disposable | undefined; private _editor: TextEditor | undefined; private _enabled: boolean = false; constructor() { this._disposable = Disposable.from( configuration.onDidChange(this.onConfigurationChanged, this), - Container.fileAnnotations.onDidToggleAnnotations(this.onFileAnnotationsToggled, this), - debug.onDidStartDebugSession(this.onDebugSessionStarted, this) + Container.fileAnnotations.onDidToggleAnnotations(this.onFileAnnotationsToggled, this) ); this.onConfigurationChanged(configuration.initializingChangeEvent); } @@ -43,8 +40,6 @@ export class LineAnnotationController implements Disposable { dispose() { this.clearAnnotations(this._editor); - this._debugSessionEndDisposable && this._debugSessionEndDisposable.dispose(); - Container.lineTracker.stop(this); this._disposable && this._disposable.dispose(); } @@ -66,40 +61,29 @@ export class LineAnnotationController implements Disposable { void this.refresh(window.activeTextEditor); } - private _suspended?: 'debugging' | 'user'; + private _suspended: boolean = false; get suspended() { - return !this._enabled || this._suspended !== undefined; + return !this._enabled || this._suspended; } @log() - resume(reason: 'debugging' | 'user' = 'user') { + resume() { this.setLineTracker(true); - switch (reason) { - case 'debugging': - if (this._suspended !== 'user') { - this._suspended = undefined; - return true; - } - break; - - case 'user': - if (this._suspended !== undefined) { - this._suspended = undefined; - return true; - } - break; + if (this._suspended) { + this._suspended = false; + return true; } return false; } @log() - suspend(reason: 'debugging' | 'user' = 'user') { + suspend() { this.setLineTracker(false); - if (this._suspended !== 'user') { - this._suspended = reason; + if (!this._suspended) { + this._suspended = true; return true; } @@ -116,27 +100,6 @@ export class LineAnnotationController implements Disposable { this.clear(e.editor); } - private onDebugSessionStarted() { - if (this._debugSessionEndDisposable === undefined) { - this._debugSessionEndDisposable = debug.onDidTerminateDebugSession(this.onDebugSessionEnded, this); - } - - if (this.suspend('debugging')) { - void this.refresh(window.activeTextEditor); - } - } - - private onDebugSessionEnded() { - if (this._debugSessionEndDisposable !== undefined) { - this._debugSessionEndDisposable.dispose(); - this._debugSessionEndDisposable = undefined; - } - - if (this.resume('debugging')) { - void this.refresh(window.activeTextEditor); - } - } - private onFileAnnotationsToggled() { void this.refresh(window.activeTextEditor); } @@ -152,11 +115,11 @@ export class LineAnnotationController implements Disposable { this._enabled = !(this._enabled && !this.suspended); if (this._enabled) { - if (this.resume('user')) { + if (this.resume()) { await this.refresh(editor); } } - else if (this.suspend('user')) { + else if (this.suspend()) { await this.refresh(editor); } } diff --git a/src/config.ts b/src/config.ts index d6cc0ae..366c7c4 100644 --- a/src/config.ts +++ b/src/config.ts @@ -20,10 +20,10 @@ export interface Config { toggleMode: AnnotationsToggleMode; }; currentLine: { - scrollable: boolean; dateFormat: string | null; enabled: boolean; format: string; + scrollable: boolean; }; codeLens: CodeLensConfig; debug: boolean; diff --git a/src/hovers/lineHoverController.ts b/src/hovers/lineHoverController.ts index 0500453..f2498e7 100644 --- a/src/hovers/lineHoverController.ts +++ b/src/hovers/lineHoverController.ts @@ -2,7 +2,6 @@ import { CancellationToken, ConfigurationChangeEvent, - debug, Disposable, Hover, languages, @@ -18,23 +17,17 @@ import { Container } from '../container'; import { LinesChangeEvent } from '../trackers/gitLineTracker'; export class LineHoverController implements Disposable { - private _debugSessionEndDisposable: Disposable | undefined; private _disposable: Disposable; private _hoverProviderDisposable: Disposable | undefined; constructor() { - this._disposable = Disposable.from( - configuration.onDidChange(this.onConfigurationChanged, this), - debug.onDidStartDebugSession(this.onDebugSessionStarted, this) - ); + this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this)); this.onConfigurationChanged(configuration.initializingChangeEvent); } dispose() { this.unregister(); - this._debugSessionEndDisposable && this._debugSessionEndDisposable.dispose(); - Container.lineTracker.stop(this); this._disposable && this._disposable.dispose(); } @@ -61,10 +54,6 @@ export class LineHoverController implements Disposable { } } - private get debugging() { - return this._debugSessionEndDisposable !== undefined; - } - private onActiveLinesChanged(e: LinesChangeEvent) { if (e.pending || e.reason !== 'editor') return; @@ -77,19 +66,6 @@ export class LineHoverController implements Disposable { this.register(e.editor); } - private onDebugSessionStarted() { - if (this._debugSessionEndDisposable === undefined) { - this._debugSessionEndDisposable = debug.onDidTerminateDebugSession(this.onDebugSessionEnded, this); - } - } - - private onDebugSessionEnded() { - if (this._debugSessionEndDisposable !== undefined) { - this._debugSessionEndDisposable.dispose(); - this._debugSessionEndDisposable = undefined; - } - } - async provideDetailsHover( document: TextDocument, position: Position, @@ -105,7 +81,7 @@ export class LineHoverController implements Disposable { const fileAnnotations = await Container.fileAnnotations.getAnnotationType(window.activeTextEditor); if (fileAnnotations !== undefined && Container.config.hovers.annotations.details) return undefined; - const wholeLine = this.debugging ? false : Container.config.hovers.currentLine.over === 'line'; + const wholeLine = Container.config.hovers.currentLine.over === 'line'; // If we aren't showing the hover over the whole line, make sure the annotation is on if (!wholeLine && Container.lineAnnotations.suspended) return undefined; @@ -161,7 +137,7 @@ export class LineHoverController implements Disposable { if (fileAnnotations !== undefined) return undefined; } - const wholeLine = this.debugging ? false : Container.config.hovers.currentLine.over === 'line'; + const wholeLine = Container.config.hovers.currentLine.over === 'line'; // If we aren't showing the hover over the whole line, make sure the annotation is on if (!wholeLine && Container.lineAnnotations.suspended) return undefined; @@ -182,7 +158,7 @@ export class LineHoverController implements Disposable { private register(editor: TextEditor | undefined) { this.unregister(); - if (editor === undefined /* || this.suspended */) return; + if (editor === undefined) return; const cfg = Container.config.hovers; if (!cfg.enabled || !cfg.currentLine.enabled || (!cfg.currentLine.details && !cfg.currentLine.changes)) return;