Defaults toggleWhitespace.enabled to true

Turns off whitespace toggling if already 'none'
This commit is contained in:
Eric Amodio
2017-06-09 16:31:35 -04:00
parent 9ae4cc36a1
commit badd999db1
3 changed files with 23 additions and 13 deletions

View File

@@ -698,7 +698,7 @@
}, },
"gitlens.advanced.toggleWhitespace.enabled": { "gitlens.advanced.toggleWhitespace.enabled": {
"type": "boolean", "type": "boolean",
"default": false, "default": true,
"description": "Specifies whether or not to toggle whitespace off then showing blame annotations (*may* be required by certain fonts/themes)" "description": "Specifies whether or not to toggle whitespace off then showing blame annotations (*may* be required by certain fonts/themes)"
} }
} }

View File

@@ -56,16 +56,27 @@ export class AnnotationController extends Disposable {
private _onConfigurationChanged() { private _onConfigurationChanged() {
let toggleWhitespace = workspace.getConfiguration(`${ExtensionKey}.advanced.toggleWhitespace`).get<boolean>('enabled'); let toggleWhitespace = workspace.getConfiguration(`${ExtensionKey}.advanced.toggleWhitespace`).get<boolean>('enabled');
if (!toggleWhitespace) {
// Until https://github.com/Microsoft/vscode/issues/11485 is fixed we need to toggle whitespace for non-monospace fonts and ligatures // Until https://github.com/Microsoft/vscode/issues/11485 is fixed we need to toggle whitespace for non-monospace fonts and ligatures
// TODO: detect monospace font // TODO: detect monospace vs non-monospace font
toggleWhitespace = workspace.getConfiguration('editor').get<boolean>('fontLigatures');
// if (!toggleWhitespace) {
// // Since we know ligatures will break the whitespace rendering -- turn it back on
// toggleWhitespace = workspace.getConfiguration('editor').get<boolean>('fontLigatures', false);
// }
// If the setting is on and we aren't showing any annotations, make sure it is necessary (i.e. only when rendering whitespace)
if (toggleWhitespace && this._annotationProviders.size === 0) {
toggleWhitespace = (workspace.getConfiguration('editor').get<string>('renderWhitespace') !== 'none');
} }
if (toggleWhitespace && !this._whitespaceController) { let changed = false;
if (toggleWhitespace && this._whitespaceController === undefined) {
changed = true;
this._whitespaceController = new WhitespaceController(); this._whitespaceController = new WhitespaceController();
} }
else if (!toggleWhitespace && this._whitespaceController) { else if (!toggleWhitespace && this._whitespaceController !== undefined) {
changed = true;
this._whitespaceController.dispose(); this._whitespaceController.dispose();
this._whitespaceController = undefined; this._whitespaceController = undefined;
} }
@@ -74,8 +85,6 @@ export class AnnotationController extends Disposable {
const cfgHighlight = cfg.blame.file.lineHighlight; const cfgHighlight = cfg.blame.file.lineHighlight;
const cfgTheme = cfg.theme.lineHighlight; const cfgTheme = cfg.theme.lineHighlight;
let changed = false;
if (!Objects.areEquivalent(cfgHighlight, this._config && this._config.blame.file.lineHighlight) || if (!Objects.areEquivalent(cfgHighlight, this._config && this._config.blame.file.lineHighlight) ||
!Objects.areEquivalent(cfgTheme, this._config && this._config.theme.lineHighlight)) { !Objects.areEquivalent(cfgTheme, this._config && this._config.theme.lineHighlight)) {
changed = true; changed = true;
@@ -129,7 +138,7 @@ export class AnnotationController extends Disposable {
for (const provider of this._annotationProviders.values()) { for (const provider of this._annotationProviders.values()) {
if (provider === undefined) continue; if (provider === undefined) continue;
provider.reset(); provider.reset(this._whitespaceController);
} }
} }
} }

View File

@@ -60,10 +60,11 @@ import { WhitespaceController } from './whitespaceController';
this.whitespaceController && await this.whitespaceController.restore(); this.whitespaceController && await this.whitespaceController.restore();
} }
async reset() { async reset(whitespaceController: WhitespaceController | undefined) {
await this.clear(); await this.clear();
this._config = workspace.getConfiguration().get<IConfig>(ExtensionKey)!; this._config = workspace.getConfiguration().get<IConfig>(ExtensionKey)!;
this.whitespaceController = whitespaceController;
await this.provideAnnotation(this.editor === undefined ? undefined : this.editor.selection.active.line); await this.provideAnnotation(this.editor === undefined ? undefined : this.editor.selection.active.line);
} }