Browse Source

Closes #382 - re-allows line blame when debugging

main
Eric Amodio 5 years ago
parent
commit
fa9f119a7e
4 changed files with 21 additions and 78 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +12
    -49
      src/annotations/lineAnnotationController.ts
  3. +1
    -1
      src/config.ts
  4. +4
    -28
      src/hovers/lineHoverController.ts

+ 4
- 0
CHANGELOG.md View File

@ -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 - 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) - 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 ### Fixed
- Fixes [#683](https://github.com/eamodio/vscode-gitlens/issues/683) - log.showSignature leads to stray files being displayed - Fixes [#683](https://github.com/eamodio/vscode-gitlens/issues/683) - log.showSignature leads to stray files being displayed

+ 12
- 49
src/annotations/lineAnnotationController.ts View File

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import { import {
ConfigurationChangeEvent, ConfigurationChangeEvent,
debug,
DecorationOptions, DecorationOptions,
DecorationRangeBehavior, DecorationRangeBehavior,
Disposable, Disposable,
@ -27,15 +26,13 @@ const annotationDecoration: TextEditorDecorationType = window.createTextEditorDe
export class LineAnnotationController implements Disposable { export class LineAnnotationController implements Disposable {
private _disposable: Disposable; private _disposable: Disposable;
private _debugSessionEndDisposable: Disposable | undefined;
private _editor: TextEditor | undefined; private _editor: TextEditor | undefined;
private _enabled: boolean = false; private _enabled: boolean = false;
constructor() { constructor() {
this._disposable = Disposable.from( this._disposable = Disposable.from(
configuration.onDidChange(this.onConfigurationChanged, this), 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); this.onConfigurationChanged(configuration.initializingChangeEvent);
} }
@ -43,8 +40,6 @@ export class LineAnnotationController implements Disposable {
dispose() { dispose() {
this.clearAnnotations(this._editor); this.clearAnnotations(this._editor);
this._debugSessionEndDisposable && this._debugSessionEndDisposable.dispose();
Container.lineTracker.stop(this); Container.lineTracker.stop(this);
this._disposable && this._disposable.dispose(); this._disposable && this._disposable.dispose();
} }
@ -66,40 +61,29 @@ export class LineAnnotationController implements Disposable {
void this.refresh(window.activeTextEditor); void this.refresh(window.activeTextEditor);
} }
private _suspended?: 'debugging' | 'user';
private _suspended: boolean = false;
get suspended() { get suspended() {
return !this._enabled || this._suspended !== undefined;
return !this._enabled || this._suspended;
} }
@log() @log()
resume(reason: 'debugging' | 'user' = 'user') {
resume() {
this.setLineTracker(true); 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; return false;
} }
@log() @log()
suspend(reason: 'debugging' | 'user' = 'user') {
suspend() {
this.setLineTracker(false); this.setLineTracker(false);
if (this._suspended !== 'user') {
this._suspended = reason;
if (!this._suspended) {
this._suspended = true;
return true; return true;
} }
@ -116,27 +100,6 @@ export class LineAnnotationController implements Disposable {
this.clear(e.editor); 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() { private onFileAnnotationsToggled() {
void this.refresh(window.activeTextEditor); void this.refresh(window.activeTextEditor);
} }
@ -152,11 +115,11 @@ export class LineAnnotationController implements Disposable {
this._enabled = !(this._enabled && !this.suspended); this._enabled = !(this._enabled && !this.suspended);
if (this._enabled) { if (this._enabled) {
if (this.resume('user')) {
if (this.resume()) {
await this.refresh(editor); await this.refresh(editor);
} }
} }
else if (this.suspend('user')) {
else if (this.suspend()) {
await this.refresh(editor); await this.refresh(editor);
} }
} }

+ 1
- 1
src/config.ts View File

@ -20,10 +20,10 @@ export interface Config {
toggleMode: AnnotationsToggleMode; toggleMode: AnnotationsToggleMode;
}; };
currentLine: { currentLine: {
scrollable: boolean;
dateFormat: string | null; dateFormat: string | null;
enabled: boolean; enabled: boolean;
format: string; format: string;
scrollable: boolean;
}; };
codeLens: CodeLensConfig; codeLens: CodeLensConfig;
debug: boolean; debug: boolean;

+ 4
- 28
src/hovers/lineHoverController.ts View File

@ -2,7 +2,6 @@
import { import {
CancellationToken, CancellationToken,
ConfigurationChangeEvent, ConfigurationChangeEvent,
debug,
Disposable, Disposable,
Hover, Hover,
languages, languages,
@ -18,23 +17,17 @@ import { Container } from '../container';
import { LinesChangeEvent } from '../trackers/gitLineTracker'; import { LinesChangeEvent } from '../trackers/gitLineTracker';
export class LineHoverController implements Disposable { export class LineHoverController implements Disposable {
private _debugSessionEndDisposable: Disposable | undefined;
private _disposable: Disposable; private _disposable: Disposable;
private _hoverProviderDisposable: Disposable | undefined; private _hoverProviderDisposable: Disposable | undefined;
constructor() { 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); this.onConfigurationChanged(configuration.initializingChangeEvent);
} }
dispose() { dispose() {
this.unregister(); this.unregister();
this._debugSessionEndDisposable && this._debugSessionEndDisposable.dispose();
Container.lineTracker.stop(this); Container.lineTracker.stop(this);
this._disposable && this._disposable.dispose(); 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) { private onActiveLinesChanged(e: LinesChangeEvent) {
if (e.pending || e.reason !== 'editor') return; if (e.pending || e.reason !== 'editor') return;
@ -77,19 +66,6 @@ export class LineHoverController implements Disposable {
this.register(e.editor); 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( async provideDetailsHover(
document: TextDocument, document: TextDocument,
position: Position, position: Position,
@ -105,7 +81,7 @@ export class LineHoverController implements Disposable {
const fileAnnotations = await Container.fileAnnotations.getAnnotationType(window.activeTextEditor); const fileAnnotations = await Container.fileAnnotations.getAnnotationType(window.activeTextEditor);
if (fileAnnotations !== undefined && Container.config.hovers.annotations.details) return undefined; 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 we aren't showing the hover over the whole line, make sure the annotation is on
if (!wholeLine && Container.lineAnnotations.suspended) return undefined; if (!wholeLine && Container.lineAnnotations.suspended) return undefined;
@ -161,7 +137,7 @@ export class LineHoverController implements Disposable {
if (fileAnnotations !== undefined) return undefined; 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 we aren't showing the hover over the whole line, make sure the annotation is on
if (!wholeLine && Container.lineAnnotations.suspended) return undefined; if (!wholeLine && Container.lineAnnotations.suspended) return undefined;
@ -182,7 +158,7 @@ export class LineHoverController implements Disposable {
private register(editor: TextEditor | undefined) { private register(editor: TextEditor | undefined) {
this.unregister(); this.unregister();
if (editor === undefined /* || this.suspended */) return;
if (editor === undefined) return;
const cfg = Container.config.hovers; const cfg = Container.config.hovers;
if (!cfg.enabled || !cfg.currentLine.enabled || (!cfg.currentLine.details && !cfg.currentLine.changes)) return; if (!cfg.enabled || !cfg.currentLine.enabled || (!cfg.currentLine.details && !cfg.currentLine.changes)) return;

Loading…
Cancel
Save