Skip to content

Commit

Permalink
Closes #382 - re-allows line blame when debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Apr 3, 2019
1 parent fdbb3c8 commit fa9f119
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 78 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 12 additions & 49 deletions src/annotations/lineAnnotationController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';
import {
ConfigurationChangeEvent,
debug,
DecorationOptions,
DecorationRangeBehavior,
Disposable,
Expand All @@ -27,24 +26,20 @@ 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);
}

dispose() {
this.clearAnnotations(this._editor);

this._debugSessionEndDisposable && this._debugSessionEndDisposable.dispose();

Container.lineTracker.stop(this);
this._disposable && this._disposable.dispose();
}
Expand All @@ -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;
}

Expand All @@ -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);
}
Expand All @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 4 additions & 28 deletions src/hovers/lineHoverController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import {
CancellationToken,
ConfigurationChangeEvent,
debug,
Disposable,
Hover,
languages,
Expand All @@ -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();
}
Expand All @@ -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;

Expand All @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit fa9f119

Please sign in to comment.