瀏覽代碼

Defaults toggleWhitespace.enabled to true

Turns off whitespace toggling if already 'none'
main
Eric Amodio 7 年之前
父節點
當前提交
badd999db1
共有 3 個檔案被更改,包括 23 行新增13 行删除
  1. +1
    -1
      package.json
  2. +20
    -11
      src/annotations/annotationController.ts
  3. +2
    -1
      src/annotations/annotationProvider.ts

+ 1
- 1
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)"
}
}

+ 20
- 11
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<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
// TODO: detect monospace font
toggleWhitespace = workspace.getConfiguration('editor').get<boolean>('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<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();
}
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);
}
}
}

+ 2
- 1
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<IConfig>(ExtensionKey)!;
this.whitespaceController = whitespaceController;
await this.provideAnnotation(this.editor === undefined ? undefined : this.editor.selection.active.line);
}

Loading…
取消
儲存