diff --git a/package.json b/package.json index 4395fce..cf539c2 100644 --- a/package.json +++ b/package.json @@ -698,7 +698,7 @@ }, "gitlens.advanced.toggleWhitespace.enabled": { "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)" } } diff --git a/src/annotations/annotationController.ts b/src/annotations/annotationController.ts index 00b3de5..2e15e7f 100644 --- a/src/annotations/annotationController.ts +++ b/src/annotations/annotationController.ts @@ -12,8 +12,8 @@ import { WhitespaceController } from './whitespaceController'; export const Decorations = { annotation: window.createTextEditorDecorationType({ - isWholeLine: true, - textDecoration: 'none' + isWholeLine: true, + textDecoration: 'none' } as DecorationRenderOptions), highlight: undefined as TextEditorDecorationType | undefined }; @@ -56,16 +56,27 @@ export class AnnotationController extends Disposable { private _onConfigurationChanged() { let toggleWhitespace = workspace.getConfiguration(`${ExtensionKey}.advanced.toggleWhitespace`).get('enabled'); - if (!toggleWhitespace) { - // 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 - toggleWhitespace = workspace.getConfiguration('editor').get('fontLigatures'); + // Until https://github.com/Microsoft/vscode/issues/11485 is fixed we need to toggle whitespace for non-monospace fonts and ligatures + // TODO: detect monospace vs non-monospace font + + // if (!toggleWhitespace) { + // // Since we know ligatures will break the whitespace rendering -- turn it back on + // toggleWhitespace = workspace.getConfiguration('editor').get('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('renderWhitespace') !== 'none'); } - if (toggleWhitespace && !this._whitespaceController) { + let changed = false; + + if (toggleWhitespace && this._whitespaceController === undefined) { + changed = true; this._whitespaceController = new WhitespaceController(); } - else if (!toggleWhitespace && this._whitespaceController) { + else if (!toggleWhitespace && this._whitespaceController !== undefined) { + changed = true; this._whitespaceController.dispose(); this._whitespaceController = undefined; } @@ -74,8 +85,6 @@ export class AnnotationController extends Disposable { const cfgHighlight = cfg.blame.file.lineHighlight; const cfgTheme = cfg.theme.lineHighlight; - let changed = false; - if (!Objects.areEquivalent(cfgHighlight, this._config && this._config.blame.file.lineHighlight) || !Objects.areEquivalent(cfgTheme, this._config && this._config.theme.lineHighlight)) { changed = true; @@ -129,7 +138,7 @@ export class AnnotationController extends Disposable { for (const provider of this._annotationProviders.values()) { if (provider === undefined) continue; - provider.reset(); + provider.reset(this._whitespaceController); } } } diff --git a/src/annotations/annotationProvider.ts b/src/annotations/annotationProvider.ts index e36168e..a4e013e 100644 --- a/src/annotations/annotationProvider.ts +++ b/src/annotations/annotationProvider.ts @@ -60,10 +60,11 @@ import { WhitespaceController } from './whitespaceController'; this.whitespaceController && await this.whitespaceController.restore(); } - async reset() { + async reset(whitespaceController: WhitespaceController | undefined) { await this.clear(); this._config = workspace.getConfiguration().get(ExtensionKey)!; + this.whitespaceController = whitespaceController; await this.provideAnnotation(this.editor === undefined ? undefined : this.editor.selection.active.line); }