Make diff gutter decorators width configurable

This commit is contained in:
Alex 2018-02-09 20:00:49 +03:00
parent 7f5c6fff45
commit f8789d3aca
2 changed files with 34 additions and 0 deletions

View file

@ -1104,8 +1104,18 @@ export class DirtyDiffWorkbenchController implements ext.IWorkbenchContribution,
@IConfigurationService private configurationService: IConfigurationService
) {
const onDidChangeConfiguration = filterEvent(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.diffDecorations'));
const onDidChangeDiffWidthConfiguration = filterEvent(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.diffGutterWidth'));
onDidChangeConfiguration(this.onDidChangeConfiguration, this, this.disposables);
this.onDidChangeConfiguration();
const diffWidthStyle = document.createElement('style');
diffWidthStyle.className = 'diff-width-style';
diffWidthStyle.type = 'text/css';
document.head.appendChild(diffWidthStyle);
onDidChangeDiffWidthConfiguration(this.onDidChangeDiffWidthConfiguration, this);
this.onDidChangeDiffWidthConfiguration();
}
private onDidChangeConfiguration(): void {
@ -1118,6 +1128,24 @@ export class DirtyDiffWorkbenchController implements ext.IWorkbenchContribution,
}
}
private onDidChangeDiffWidthConfiguration(): void {
let width = this.configurationService.getValue<number>('scm.diffGutterWidth');
if (isNaN(width) || width <= 0 || width > 5) {
width = 3;
}
const diffWidthStyle = document.head.getElementsByClassName('diff-width-style')[0];
if (diffWidthStyle) {
diffWidthStyle.innerHTML = `
.monaco-editor .dirty-diff-modified,
.monaco-editor .dirty-diff-added {
border-left-width: ${width}px;
}`;
}
}
private enable(): void {
if (this.enabled) {
this.disable();

View file

@ -79,6 +79,12 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
enum: ['all', 'gutter', 'overview', 'none'],
default: 'all',
description: localize('diffDecorations', "Controls diff decorations in the editor.")
},
'scm.diffGutterWidth': {
type: 'number',
enum: [1, 2, 3, 4, 5],
default: 3,
description: localize('diffGutterWidth', "Controls the width(px) of diff decorations in gutter (added & modified).")
}
}
});