mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-19 01:35:37 -05:00
Adds advanced setting for toggling whitespace
This is in-case it is still needed (it if off by default)
This commit is contained in:
@@ -245,6 +245,11 @@
|
||||
"verbose"
|
||||
],
|
||||
"description": "Specifies how much (if any) output will be sent to the GitLens output channel"
|
||||
},
|
||||
"gitlens.advanced.toggleWhitespace.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Specifies whether or not to toggle whitespace off then showing blame annotations (*may* be required by certain fonts/themes)"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Functions } from './system';
|
||||
import { Disposable, ExtensionContext, TextDocument, TextEditor, TextEditorViewColumnChangeEvent, window, workspace } from 'vscode';
|
||||
import { BlameAnnotationProvider } from './blameAnnotationProvider';
|
||||
import { TextDocumentComparer, TextEditorComparer } from './comparers';
|
||||
// import { IAdvancedConfig } from './configuration';
|
||||
import GitProvider from './gitProvider';
|
||||
import { Logger } from './logger';
|
||||
import WhitespaceController from './whitespaceController';
|
||||
@@ -11,12 +12,19 @@ export default class BlameAnnotationController extends Disposable {
|
||||
|
||||
private _annotationProviders: Map<number, BlameAnnotationProvider> = new Map();
|
||||
private _blameAnnotationsDisposable: Disposable;
|
||||
private _disposable: Disposable;
|
||||
private _whitespaceController: WhitespaceController | undefined;
|
||||
|
||||
constructor(private context: ExtensionContext, private git: GitProvider) {
|
||||
super(() => this.dispose());
|
||||
|
||||
this._whitespaceController = new WhitespaceController(context);
|
||||
this._onConfigure();
|
||||
|
||||
const subscriptions: Disposable[] = [];
|
||||
|
||||
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigure, this));
|
||||
|
||||
this._disposable = Disposable.from(...subscriptions);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
@@ -24,6 +32,17 @@ export default class BlameAnnotationController extends Disposable {
|
||||
|
||||
this._blameAnnotationsDisposable && this._blameAnnotationsDisposable.dispose();
|
||||
this._whitespaceController && this._whitespaceController.dispose();
|
||||
this._disposable && this._disposable.dispose();
|
||||
}
|
||||
|
||||
private _onConfigure() {
|
||||
const toggleWhitespace = workspace.getConfiguration('gitlens.advanced.toggleWhitespace').get<boolean>('enabled');
|
||||
if (toggleWhitespace && !this._whitespaceController) {
|
||||
this._whitespaceController = new WhitespaceController();
|
||||
}
|
||||
else if (!toggleWhitespace && this._whitespaceController) {
|
||||
this._whitespaceController.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
async clear(column: number) {
|
||||
|
||||
@@ -99,6 +99,9 @@ export interface IAdvancedConfig {
|
||||
output: {
|
||||
level: OutputLevel;
|
||||
};
|
||||
toggleWhitespace: {
|
||||
enabled: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IConfig {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import { Disposable, ExtensionContext, workspace } from 'vscode';
|
||||
import { Disposable, workspace } from 'vscode';
|
||||
import { Logger } from './logger';
|
||||
|
||||
enum SettingLocation {
|
||||
@@ -12,12 +12,13 @@ export default class WhitespaceController extends Disposable {
|
||||
|
||||
private _count: number = 0;
|
||||
private _disposable: Disposable;
|
||||
private _disposed: boolean = false;
|
||||
private _ignoreNextConfigChange: boolean = false;
|
||||
private _renderWhitespace: string;
|
||||
private _renderWhitespaceLocation: SettingLocation = SettingLocation.default;
|
||||
private _requiresOverride: boolean;
|
||||
|
||||
constructor(context: ExtensionContext) {
|
||||
constructor() {
|
||||
super(() => this.dispose());
|
||||
|
||||
const subscriptions: Disposable[] = [];
|
||||
@@ -30,12 +31,16 @@ export default class WhitespaceController extends Disposable {
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._disposed = true;
|
||||
if (this._count !== 0) {
|
||||
this._restoreWhitespace();
|
||||
this._count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private _onConfigurationChanged() {
|
||||
if (this._disposed) return;
|
||||
|
||||
if (this._ignoreNextConfigChange) {
|
||||
this._ignoreNextConfigChange = false;
|
||||
Logger.log(`Whitespace changed; ignored`);
|
||||
@@ -70,6 +75,8 @@ export default class WhitespaceController extends Disposable {
|
||||
}
|
||||
|
||||
override() {
|
||||
if (this._disposed) return;
|
||||
|
||||
Logger.log(`Request whitespace override; count=${this._count}`);
|
||||
if (this._count === 0 && this._requiresOverride) {
|
||||
this._ignoreNextConfigChange = true;
|
||||
@@ -86,6 +93,8 @@ export default class WhitespaceController extends Disposable {
|
||||
}
|
||||
|
||||
restore() {
|
||||
if (this._disposed) return;
|
||||
|
||||
Logger.log(`Request whitespace restore; count=${this._count}`);
|
||||
this._count--;
|
||||
if (this._count === 0 && this._requiresOverride) {
|
||||
|
||||
Reference in New Issue
Block a user