mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-15 18:48:28 -05:00
@@ -27,6 +27,7 @@ Provides Git CodeLens information (most recent commit, # of authors), on-demand
|
|||||||
|Name | Description
|
|Name | Description
|
||||||
|-----|------------
|
|-----|------------
|
||||||
|`gitlens.blame.annotation.style`|Specifies the style of the blame annotations. `compact` - groups annotations to limit the repetition and also adds author and date when possible. `expanded` - shows an annotation on every line
|
|`gitlens.blame.annotation.style`|Specifies the style of the blame annotations. `compact` - groups annotations to limit the repetition and also adds author and date when possible. `expanded` - shows an annotation on every line
|
||||||
|
|`gitlens.blame.annotation.highlight`|Specifies whether and how to highlight blame annotations. `none` - no highlight. `gutter` - adds a gutter icon. `line` - adds a full-line highlight. `both` - adds both `gutter` and `line` highlights
|
||||||
|`gitlens.blame.annotation.sha`|Specifies whether the commit sha will be shown in the blame annotations. Applies only to the `expanded` & `trailing` annotation styles
|
|`gitlens.blame.annotation.sha`|Specifies whether the commit sha will be shown in the blame annotations. Applies only to the `expanded` & `trailing` annotation styles
|
||||||
|`gitlens.blame.annotation.author`|Specifies whether the committer will be shown in the blame annotations. Applies only to the `expanded` & `trailing` annotation styles
|
|`gitlens.blame.annotation.author`|Specifies whether the committer will be shown in the blame annotations. Applies only to the `expanded` & `trailing` annotation styles
|
||||||
|`gitlens.blame.annotation.date`|Specifies whether the commit date will be shown in the blame annotations. Applies only to the `expanded` & `trailing` annotation styles
|
|`gitlens.blame.annotation.date`|Specifies whether the commit date will be shown in the blame annotations. Applies only to the `expanded` & `trailing` annotation styles
|
||||||
|
|||||||
11
package.json
11
package.json
@@ -52,6 +52,17 @@
|
|||||||
],
|
],
|
||||||
"description": "Specifies the style of the blame annotations. `compact` - groups annotations to limit the repetition and also adds author and date when possible. `expanded` - shows an annotation before every line. `trailing` - shows an annotation after every line"
|
"description": "Specifies the style of the blame annotations. `compact` - groups annotations to limit the repetition and also adds author and date when possible. `expanded` - shows an annotation before every line. `trailing` - shows an annotation after every line"
|
||||||
},
|
},
|
||||||
|
"gitlens.blame.annotation.highlight": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "both",
|
||||||
|
"enum": [
|
||||||
|
"none",
|
||||||
|
"gutter",
|
||||||
|
"line",
|
||||||
|
"both"
|
||||||
|
],
|
||||||
|
"description": "Specifies whether and how to highlight blame annotations. `none` - no highlight. `gutter` - adds a gutter icon. `line` - adds a full-line highlight. `both` - adds both `gutter` and `line` highlights"
|
||||||
|
},
|
||||||
"gitlens.blame.annotation.sha": {
|
"gitlens.blame.annotation.sha": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ export default class BlameActiveLineController extends Disposable {
|
|||||||
|
|
||||||
this._updateBlameDebounced = Functions.debounce(this._updateBlame, 50);
|
this._updateBlameDebounced = Functions.debounce(this._updateBlame, 50);
|
||||||
|
|
||||||
this._onConfigure();
|
this._onConfigurationChanged();
|
||||||
|
|
||||||
const subscriptions: Disposable[] = [];
|
const subscriptions: Disposable[] = [];
|
||||||
|
|
||||||
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigure, this));
|
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
|
||||||
subscriptions.push(git.onDidRemoveCacheEntry(this._onRemoveCacheEntry, this));
|
subscriptions.push(git.onDidRemoveCacheEntry(this._onRemoveCacheEntry, this));
|
||||||
|
|
||||||
this._disposable = Disposable.from(...subscriptions);
|
this._disposable = Disposable.from(...subscriptions);
|
||||||
@@ -51,7 +51,7 @@ export default class BlameActiveLineController extends Disposable {
|
|||||||
this._disposable && this._disposable.dispose();
|
this._disposable && this._disposable.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onConfigure() {
|
private _onConfigurationChanged() {
|
||||||
const config = workspace.getConfiguration('').get<IConfig>('gitlens');
|
const config = workspace.getConfiguration('').get<IConfig>('gitlens');
|
||||||
|
|
||||||
let changed: boolean = false;
|
let changed: boolean = false;
|
||||||
|
|||||||
@@ -1,28 +1,40 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Functions } from './system';
|
import { Functions } from './system';
|
||||||
import { Disposable, ExtensionContext, TextDocument, TextEditor, TextEditorViewColumnChangeEvent, window, workspace } from 'vscode';
|
import { DecorationRenderOptions, Disposable, ExtensionContext, OverviewRulerLane, TextDocument, TextEditor, TextEditorDecorationType, TextEditorViewColumnChangeEvent, window, workspace } from 'vscode';
|
||||||
import { BlameAnnotationProvider } from './blameAnnotationProvider';
|
import { BlameAnnotationProvider } from './blameAnnotationProvider';
|
||||||
import { TextDocumentComparer, TextEditorComparer } from './comparers';
|
import { TextDocumentComparer, TextEditorComparer } from './comparers';
|
||||||
// import { IAdvancedConfig } from './configuration';
|
import { IBlameConfig } from './configuration';
|
||||||
import GitProvider from './gitProvider';
|
import GitProvider from './gitProvider';
|
||||||
import { Logger } from './logger';
|
import { Logger } from './logger';
|
||||||
import WhitespaceController from './whitespaceController';
|
import WhitespaceController from './whitespaceController';
|
||||||
|
|
||||||
|
export const blameDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
|
||||||
|
before: {
|
||||||
|
margin: '0 1.75em 0 0'
|
||||||
|
},
|
||||||
|
after: {
|
||||||
|
margin: '0 0 0 4em'
|
||||||
|
}
|
||||||
|
} as DecorationRenderOptions);
|
||||||
|
|
||||||
|
export let highlightDecoration: TextEditorDecorationType;
|
||||||
|
|
||||||
export default class BlameAnnotationController extends Disposable {
|
export default class BlameAnnotationController extends Disposable {
|
||||||
|
|
||||||
private _annotationProviders: Map<number, BlameAnnotationProvider> = new Map();
|
private _annotationProviders: Map<number, BlameAnnotationProvider> = new Map();
|
||||||
private _blameAnnotationsDisposable: Disposable;
|
private _blameAnnotationsDisposable: Disposable;
|
||||||
|
private _config: IBlameConfig;
|
||||||
private _disposable: Disposable;
|
private _disposable: Disposable;
|
||||||
private _whitespaceController: WhitespaceController | undefined;
|
private _whitespaceController: WhitespaceController | undefined;
|
||||||
|
|
||||||
constructor(private context: ExtensionContext, private git: GitProvider) {
|
constructor(private context: ExtensionContext, private git: GitProvider) {
|
||||||
super(() => this.dispose());
|
super(() => this.dispose());
|
||||||
|
|
||||||
this._onConfigure();
|
this._onConfigurationChanged();
|
||||||
|
|
||||||
const subscriptions: Disposable[] = [];
|
const subscriptions: Disposable[] = [];
|
||||||
|
|
||||||
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigure, this));
|
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
|
||||||
|
|
||||||
this._disposable = Disposable.from(...subscriptions);
|
this._disposable = Disposable.from(...subscriptions);
|
||||||
}
|
}
|
||||||
@@ -35,7 +47,7 @@ export default class BlameAnnotationController extends Disposable {
|
|||||||
this._disposable && this._disposable.dispose();
|
this._disposable && this._disposable.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onConfigure() {
|
private _onConfigurationChanged() {
|
||||||
let toggleWhitespace = workspace.getConfiguration('gitlens.advanced.toggleWhitespace').get<boolean>('enabled');
|
let toggleWhitespace = workspace.getConfiguration('gitlens.advanced.toggleWhitespace').get<boolean>('enabled');
|
||||||
if (!toggleWhitespace) {
|
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
|
||||||
@@ -50,6 +62,68 @@ export default class BlameAnnotationController extends Disposable {
|
|||||||
this._whitespaceController.dispose();
|
this._whitespaceController.dispose();
|
||||||
this._whitespaceController = undefined;
|
this._whitespaceController = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const config = workspace.getConfiguration('gitlens').get<IBlameConfig>('blame');
|
||||||
|
|
||||||
|
if (config.annotation.highlight !== (this._config && this._config.annotation.highlight)) {
|
||||||
|
highlightDecoration && highlightDecoration.dispose();
|
||||||
|
|
||||||
|
switch (config.annotation.highlight) {
|
||||||
|
case 'none':
|
||||||
|
highlightDecoration = undefined;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'gutter':
|
||||||
|
highlightDecoration = window.createTextEditorDecorationType({
|
||||||
|
dark: {
|
||||||
|
gutterIconPath: this.context.asAbsolutePath('images/blame-dark.svg'),
|
||||||
|
overviewRulerColor: 'rgba(255, 255, 255, 0.75)'
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
gutterIconPath: this.context.asAbsolutePath('images/blame-light.svg'),
|
||||||
|
overviewRulerColor: 'rgba(0, 0, 0, 0.75)'
|
||||||
|
},
|
||||||
|
gutterIconSize: 'contain',
|
||||||
|
overviewRulerLane: OverviewRulerLane.Right
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'line':
|
||||||
|
highlightDecoration = window.createTextEditorDecorationType({
|
||||||
|
dark: {
|
||||||
|
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
||||||
|
overviewRulerColor: 'rgba(255, 255, 255, 0.75)'
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.15)',
|
||||||
|
overviewRulerColor: 'rgba(0, 0, 0, 0.75)'
|
||||||
|
},
|
||||||
|
overviewRulerLane: OverviewRulerLane.Right,
|
||||||
|
isWholeLine: true
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'both':
|
||||||
|
highlightDecoration = window.createTextEditorDecorationType({
|
||||||
|
dark: {
|
||||||
|
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
||||||
|
gutterIconPath: this.context.asAbsolutePath('images/blame-dark.svg'),
|
||||||
|
overviewRulerColor: 'rgba(255, 255, 255, 0.75)'
|
||||||
|
},
|
||||||
|
light: {
|
||||||
|
backgroundColor: 'rgba(0, 0, 0, 0.15)',
|
||||||
|
gutterIconPath: this.context.asAbsolutePath('images/blame-light.svg'),
|
||||||
|
overviewRulerColor: 'rgba(0, 0, 0, 0.75)'
|
||||||
|
},
|
||||||
|
gutterIconSize: 'contain',
|
||||||
|
overviewRulerLane: OverviewRulerLane.Right,
|
||||||
|
isWholeLine: true
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this._config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
async clear(column: number) {
|
async clear(column: number) {
|
||||||
|
|||||||
@@ -1,23 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from './system';
|
import { Iterables } from './system';
|
||||||
import { DecorationInstanceRenderOptions, DecorationOptions, DecorationRenderOptions, Disposable, ExtensionContext, OverviewRulerLane, Range, TextDocument, TextEditor, TextEditorDecorationType, TextEditorSelectionChangeEvent, window, workspace } from 'vscode';
|
import { DecorationInstanceRenderOptions, DecorationOptions, Disposable, ExtensionContext, Range, TextDocument, TextEditor, TextEditorSelectionChangeEvent, window, workspace } from 'vscode';
|
||||||
import BlameAnnotationFormatter, { BlameAnnotationFormat, cssIndent, defaultShaLength, defaultAuthorLength } from './blameAnnotationFormatter';
|
import BlameAnnotationFormatter, { BlameAnnotationFormat, cssIndent, defaultShaLength, defaultAuthorLength } from './blameAnnotationFormatter';
|
||||||
|
import { blameDecoration, highlightDecoration } from './blameAnnotationController';
|
||||||
import { TextDocumentComparer } from './comparers';
|
import { TextDocumentComparer } from './comparers';
|
||||||
import { BlameAnnotationStyle, IBlameConfig } from './configuration';
|
import { BlameAnnotationStyle, IBlameConfig } from './configuration';
|
||||||
import GitProvider, { GitUri, IGitBlame } from './gitProvider';
|
import GitProvider, { GitUri, IGitBlame } from './gitProvider';
|
||||||
import WhitespaceController from './whitespaceController';
|
import WhitespaceController from './whitespaceController';
|
||||||
|
|
||||||
const blameDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
|
|
||||||
before: {
|
|
||||||
margin: '0 1.75em 0 0'
|
|
||||||
},
|
|
||||||
after: {
|
|
||||||
margin: '0 0 0 4em'
|
|
||||||
}
|
|
||||||
} as DecorationRenderOptions);
|
|
||||||
|
|
||||||
let highlightDecoration: TextEditorDecorationType;
|
|
||||||
|
|
||||||
export class BlameAnnotationProvider extends Disposable {
|
export class BlameAnnotationProvider extends Disposable {
|
||||||
|
|
||||||
public document: TextDocument;
|
public document: TextDocument;
|
||||||
@@ -30,24 +20,6 @@ export class BlameAnnotationProvider extends Disposable {
|
|||||||
constructor(context: ExtensionContext, private git: GitProvider, private whitespaceController: WhitespaceController | undefined, public editor: TextEditor) {
|
constructor(context: ExtensionContext, private git: GitProvider, private whitespaceController: WhitespaceController | undefined, public editor: TextEditor) {
|
||||||
super(() => this.dispose());
|
super(() => this.dispose());
|
||||||
|
|
||||||
if (!highlightDecoration) {
|
|
||||||
highlightDecoration = window.createTextEditorDecorationType({
|
|
||||||
dark: {
|
|
||||||
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
||||||
gutterIconPath: context.asAbsolutePath('images/blame-dark.svg'),
|
|
||||||
overviewRulerColor: 'rgba(255, 255, 255, 0.75)'
|
|
||||||
},
|
|
||||||
light: {
|
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.15)',
|
|
||||||
gutterIconPath: context.asAbsolutePath('images/blame-light.svg'),
|
|
||||||
overviewRulerColor: 'rgba(0, 0, 0, 0.75)'
|
|
||||||
},
|
|
||||||
gutterIconSize: 'contain',
|
|
||||||
overviewRulerLane: OverviewRulerLane.Right,
|
|
||||||
isWholeLine: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.document = this.editor.document;
|
this.document = this.editor.document;
|
||||||
this._uri = GitUri.fromUri(this.document.uri, this.git);
|
this._uri = GitUri.fromUri(this.document.uri, this.git);
|
||||||
|
|
||||||
@@ -65,7 +37,7 @@ export class BlameAnnotationProvider extends Disposable {
|
|||||||
async dispose() {
|
async dispose() {
|
||||||
if (this.editor) {
|
if (this.editor) {
|
||||||
this.editor.setDecorations(blameDecoration, []);
|
this.editor.setDecorations(blameDecoration, []);
|
||||||
this.editor.setDecorations(highlightDecoration, []);
|
highlightDecoration && this.editor.setDecorations(highlightDecoration, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: Until https://github.com/Microsoft/vscode/issues/11485 is fixed -- restore whitespace
|
// HACK: Until https://github.com/Microsoft/vscode/issues/11485 is fixed -- restore whitespace
|
||||||
@@ -123,6 +95,8 @@ export class BlameAnnotationProvider extends Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _setSelection(blame: IGitBlame, shaOrLine?: string | number) {
|
private _setSelection(blame: IGitBlame, shaOrLine?: string | number) {
|
||||||
|
if (!highlightDecoration) return;
|
||||||
|
|
||||||
const offset = this._uri.offset;
|
const offset = this._uri.offset;
|
||||||
|
|
||||||
let sha: string;
|
let sha: string;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export const BlameAnnotationStyle = {
|
|||||||
export interface IBlameConfig {
|
export interface IBlameConfig {
|
||||||
annotation: {
|
annotation: {
|
||||||
style: BlameAnnotationStyle;
|
style: BlameAnnotationStyle;
|
||||||
|
highlight: 'none' | 'gutter' | 'line' | 'both';
|
||||||
sha: boolean;
|
sha: boolean;
|
||||||
author: boolean;
|
author: boolean;
|
||||||
date: 'off' | 'relative' | 'absolute';
|
date: 'off' | 'relative' | 'absolute';
|
||||||
|
|||||||
@@ -70,11 +70,11 @@ export default class GitProvider extends Disposable {
|
|||||||
|
|
||||||
this._repoPath = context.workspaceState.get(WorkspaceState.RepoPath) as string;
|
this._repoPath = context.workspaceState.get(WorkspaceState.RepoPath) as string;
|
||||||
|
|
||||||
this._onConfigure();
|
this._onConfigurationChanged();
|
||||||
|
|
||||||
const subscriptions: Disposable[] = [];
|
const subscriptions: Disposable[] = [];
|
||||||
|
|
||||||
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigure, this));
|
subscriptions.push(workspace.onDidChangeConfiguration(this._onConfigurationChanged, this));
|
||||||
|
|
||||||
this._disposable = Disposable.from(...subscriptions);
|
this._disposable = Disposable.from(...subscriptions);
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ export default class GitProvider extends Disposable {
|
|||||||
return !!this._gitCache;
|
return !!this._gitCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onConfigure() {
|
private _onConfigurationChanged() {
|
||||||
const config = workspace.getConfiguration().get<IConfig>('gitlens');
|
const config = workspace.getConfiguration().get<IConfig>('gitlens');
|
||||||
|
|
||||||
const codeLensChanged = !Objects.areEquivalent(config.codeLens, this.config && this.config.codeLens);
|
const codeLensChanged = !Objects.areEquivalent(config.codeLens, this.config && this.config.codeLens);
|
||||||
|
|||||||
Reference in New Issue
Block a user