Skip to content

Commit ad79ac1

Browse files
committed
Removes whitespace controller
1 parent 1d3845b commit ad79ac1

10 files changed

+35
-225
lines changed

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,11 +887,6 @@
887887
"type": "boolean",
888888
"default": true,
889889
"description": "Specifies whether or not to enable GitLens telemetry (even if enabled still abides by the overall `telemetry.enableTelemetry` setting"
890-
},
891-
"gitlens.advanced.toggleWhitespace.enabled": {
892-
"type": "boolean",
893-
"default": false,
894-
"description": "Specifies whether or not to toggle whitespace off then showing blame annotations (*may* be required by certain fonts/themes)"
895890
}
896891
}
897892
},

src/annotations/annotationController.ts

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { GutterBlameAnnotationProvider } from './gutterBlameAnnotationProvider';
1111
import { HoverBlameAnnotationProvider } from './hoverBlameAnnotationProvider';
1212
import { Logger } from '../logger';
1313
import { RecentChangesAnnotationProvider } from './recentChangesAnnotationProvider';
14-
import { WhitespaceController } from './whitespaceController';
1514
import * as path from 'path';
1615

1716
export enum FileAnnotationType {
@@ -41,7 +40,6 @@ export class AnnotationController extends Disposable {
4140
private _annotationProviders: Map<number, AnnotationProviderBase> = new Map();
4241
private _config: IConfig;
4342
private _disposable: Disposable;
44-
private _whitespaceController: WhitespaceController | undefined;
4543

4644
constructor(private context: ExtensionContext, private git: GitService, private gitContextTracker: GitContextTracker) {
4745
super(() => this.dispose());
@@ -62,37 +60,12 @@ export class AnnotationController extends Disposable {
6260
Decorations.blameHighlight && Decorations.blameHighlight.dispose();
6361

6462
this._annotationsDisposable && this._annotationsDisposable.dispose();
65-
this._whitespaceController && this._whitespaceController.dispose();
6663
this._disposable && this._disposable.dispose();
6764
}
6865

6966
private _onConfigurationChanged() {
70-
let toggleWhitespace = workspace.getConfiguration(`${ExtensionKey}.advanced.toggleWhitespace`).get<boolean>('enabled');
71-
// Until https://github.com/Microsoft/vscode/issues/11485 is fixed we need to toggle whitespace for non-monospace fonts and ligatures
72-
// TODO: detect monospace vs non-monospace font
73-
74-
// if (!toggleWhitespace) {
75-
// // Since we know ligatures will break the whitespace rendering -- turn it back on
76-
// toggleWhitespace = workspace.getConfiguration('editor').get<boolean>('fontLigatures', false);
77-
// }
78-
79-
// If the setting is on and we aren't showing any annotations, make sure it is necessary (i.e. only when rendering whitespace)
80-
if (toggleWhitespace && this._annotationProviders.size === 0) {
81-
toggleWhitespace = (workspace.getConfiguration('editor').get<string>('renderWhitespace') !== 'none');
82-
}
83-
8467
let changed = false;
8568

86-
if (toggleWhitespace && this._whitespaceController === undefined) {
87-
changed = true;
88-
this._whitespaceController = new WhitespaceController();
89-
}
90-
else if (!toggleWhitespace && this._whitespaceController !== undefined) {
91-
changed = true;
92-
this._whitespaceController.dispose();
93-
this._whitespaceController = undefined;
94-
}
95-
9669
const cfg = workspace.getConfiguration().get<IConfig>(ExtensionKey)!;
9770
const cfgBlameHighlight = cfg.blame.file.lineHighlight;
9871
const cfgChangesHighlight = cfg.recentChanges.file.lineHighlight;
@@ -187,7 +160,7 @@ export class AnnotationController extends Disposable {
187160
provider.reset(Decorations.recentChangesAnnotation, Decorations.recentChangesHighlight);
188161
}
189162
else {
190-
provider.reset(Decorations.blameAnnotation, Decorations.blameHighlight, this._whitespaceController);
163+
provider.reset(Decorations.blameAnnotation, Decorations.blameHighlight);
191164
}
192165
}
193166
}
@@ -286,11 +259,11 @@ export class AnnotationController extends Disposable {
286259
let provider: AnnotationProviderBase | undefined = undefined;
287260
switch (type) {
288261
case FileAnnotationType.Gutter:
289-
provider = new GutterBlameAnnotationProvider(this.context, editor, Decorations.blameAnnotation, Decorations.blameHighlight, this._whitespaceController, this.git, gitUri);
262+
provider = new GutterBlameAnnotationProvider(this.context, editor, Decorations.blameAnnotation, Decorations.blameHighlight, this.git, gitUri);
290263
break;
291264

292265
case FileAnnotationType.Hover:
293-
provider = new HoverBlameAnnotationProvider(this.context, editor, Decorations.blameAnnotation, Decorations.blameHighlight, this._whitespaceController, this.git, gitUri);
266+
provider = new HoverBlameAnnotationProvider(this.context, editor, Decorations.blameAnnotation, Decorations.blameHighlight, this.git, gitUri);
294267
break;
295268

296269
case FileAnnotationType.RecentChanges:

src/annotations/annotationProvider.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict';
2-
// import { Functions } from '../system';
32
import { Disposable, ExtensionContext, TextDocument, TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent, window, workspace } from 'vscode';
43
import { FileAnnotationType } from '../annotations/annotationController';
54
import { TextDocumentComparer } from '../comparers';
65
import { ExtensionKey, IConfig } from '../configuration';
7-
import { WhitespaceController } from './whitespaceController';
86

97
export abstract class AnnotationProviderBase extends Disposable {
108

@@ -14,7 +12,12 @@ import { WhitespaceController } from './whitespaceController';
1412
protected _config: IConfig;
1513
protected _disposable: Disposable;
1614

17-
constructor(context: ExtensionContext, public editor: TextEditor, protected decoration: TextEditorDecorationType | undefined, protected highlightDecoration: TextEditorDecorationType | undefined, protected whitespaceController: WhitespaceController | undefined) {
15+
constructor(
16+
context: ExtensionContext,
17+
public editor: TextEditor,
18+
protected decoration: TextEditorDecorationType | undefined,
19+
protected highlightDecoration: TextEditorDecorationType | undefined
20+
) {
1821
super(() => this.dispose());
1922

2023
this.document = this.editor.document;
@@ -53,18 +56,14 @@ import { WhitespaceController } from './whitespaceController';
5356
}
5457
catch (ex) { }
5558
}
56-
57-
// HACK: Until https://github.com/Microsoft/vscode/issues/11485 is fixed -- restore whitespace
58-
this.whitespaceController && await this.whitespaceController.restore();
5959
}
6060

61-
async reset(decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined, whitespaceController?: WhitespaceController) {
61+
async reset(decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined) {
6262
await this.clear();
6363

6464
this._config = workspace.getConfiguration().get<IConfig>(ExtensionKey)!;
6565
this.decoration = decoration;
6666
this.highlightDecoration = highlightDecoration;
67-
this.whitespaceController = whitespaceController;
6867

6968
await this.provideAnnotation(this.editor === undefined ? undefined : this.editor.selection.active.line);
7069
}

src/annotations/blameAnnotationProvider.ts

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ import { CancellationToken, Disposable, ExtensionContext, Hover, HoverProvider,
44
import { AnnotationProviderBase } from './annotationProvider';
55
import { Annotations, endOfLineIndex } from './annotations';
66
import { GitBlame, GitCommit, GitService, GitUri } from '../gitService';
7-
import { WhitespaceController } from './whitespaceController';
87

98
export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase implements HoverProvider {
109

1110
protected _blame: Promise<GitBlame | undefined>;
1211
protected _hoverProviderDisposable: Disposable;
1312

14-
constructor(context: ExtensionContext, editor: TextEditor, decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined, whitespaceController: WhitespaceController | undefined, protected git: GitService, protected uri: GitUri) {
15-
super(context, editor, decoration, highlightDecoration, whitespaceController);
13+
constructor(
14+
context: ExtensionContext,
15+
editor: TextEditor,
16+
decoration: TextEditorDecorationType | undefined,
17+
highlightDecoration: TextEditorDecorationType | undefined,
18+
protected git: GitService,
19+
protected uri: GitUri
20+
) {
21+
super(context, editor, decoration, highlightDecoration);
1622

1723
this._blame = this.git.getBlameForFile(this.uri);
1824
}
@@ -61,25 +67,9 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
6167
return blame !== undefined && blame.lines.length !== 0;
6268
}
6369

64-
protected async getBlame(requiresWhitespaceHack: boolean): Promise<GitBlame | undefined> {
65-
let whitespacePromise: Promise<void> | undefined;
66-
// HACK: Until https://github.com/Microsoft/vscode/issues/11485 is fixed -- override whitespace (turn off)
67-
if (requiresWhitespaceHack) {
68-
whitespacePromise = this.whitespaceController && this.whitespaceController.override();
69-
}
70-
71-
let blame: GitBlame | undefined;
72-
if (whitespacePromise !== undefined) {
73-
[blame] = await Promise.all([this._blame, whitespacePromise]);
74-
}
75-
else {
76-
blame = await this._blame;
77-
}
78-
79-
if (blame === undefined || blame.lines.length === 0) {
80-
this.whitespaceController && await this.whitespaceController.restore();
81-
return undefined;
82-
}
70+
protected async getBlame(): Promise<GitBlame | undefined> {
71+
const blame = await this._blame;
72+
if (blame === undefined || blame.lines.length === 0) return undefined;
8373

8474
return blame;
8575
}
@@ -95,7 +85,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
9585
const cfg = this._config.annotations.file.gutter;
9686
if (!cfg.hover.wholeLine && position.character !== 0) return undefined;
9787

98-
const blame = await this.getBlame(true);
88+
const blame = await this.getBlame();
9989
if (blame === undefined) return undefined;
10090

10191
const line = blame.lines[position.line];

src/annotations/gutterBlameAnnotationProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
1313
async provideAnnotation(shaOrLine?: string | number, type?: FileAnnotationType): Promise<boolean> {
1414
this.annotationType = FileAnnotationType.Gutter;
1515

16-
const blame = await this.getBlame(true);
16+
const blame = await this.getBlame();
1717
if (blame === undefined) return false;
1818

1919
const start = process.hrtime();

src/annotations/hoverBlameAnnotationProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class HoverBlameAnnotationProvider extends BlameAnnotationProviderBase {
1313

1414
const cfg = this._config.annotations.file.hover;
1515

16-
const blame = await this.getBlame(cfg.heatmap.enabled);
16+
const blame = await this.getBlame();
1717
if (blame === undefined) return false;
1818

1919
if (cfg.heatmap.enabled) {

src/annotations/recentChangesAnnotationProvider.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ import { Logger } from '../logger';
88

99
export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
1010

11-
constructor(context: ExtensionContext, editor: TextEditor, decoration: TextEditorDecorationType | undefined, highlightDecoration: TextEditorDecorationType | undefined, private git: GitService, private uri: GitUri) {
12-
super(context, editor, decoration, highlightDecoration, undefined);
11+
constructor(
12+
context: ExtensionContext,
13+
editor: TextEditor,
14+
decoration: TextEditorDecorationType | undefined,
15+
highlightDecoration: TextEditorDecorationType | undefined,
16+
private git: GitService,
17+
private uri: GitUri
18+
) {
19+
super(context, editor, decoration, highlightDecoration);
1320
}
1421

1522
async provideAnnotation(shaOrLine?: string | number): Promise<boolean> {

src/annotations/whitespaceController.ts

Lines changed: 0 additions & 150 deletions
This file was deleted.

src/configuration.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ export interface IAdvancedConfig {
9797
telemetry: {
9898
enabled: boolean;
9999
};
100-
toggleWhitespace: {
101-
enabled: boolean;
102-
};
103100
}
104101

105102
export interface ICodeLensLanguageLocation {

0 commit comments

Comments
 (0)