Browse Source

Adds real theming support

main
Eric Amodio 7 years ago
parent
commit
fdc2e89c18
9 changed files with 165 additions and 330 deletions
  1. +13
    -1
      CHANGELOG.md
  2. +18
    -23
      README.md
  3. +71
    -90
      package.json
  4. +16
    -33
      src/annotations/annotationController.ts
  5. +38
    -77
      src/annotations/annotations.ts
  6. +3
    -11
      src/annotations/gutterBlameAnnotationProvider.ts
  7. +1
    -1
      src/annotations/hoverBlameAnnotationProvider.ts
  8. +3
    -91
      src/configuration.ts
  9. +2
    -3
      src/currentLineController.ts

+ 13
- 1
CHANGELOG.md View File

@ -6,11 +6,23 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds theming support - vscode themes can now specify GitLens colors as well as directly by using [`workbench.colorCustomization`](https://code.visualstudio.com/docs/getstarted/themes#_customize-a-color-theme))
- Adds `gitlens.gutterBackgroundColor` themable color
- Adds `gitlens.gutterForegroundColor` themable color
- Adds `gitlens.gutterUncommittedForegroundColor` themable color
- Adds `gitlens.trailingLineBackgroundColor` themable color
- Adds `gitlens.trailingLineForegroundColor` themable color
- Adds `gitlens.lineHighlightBackgroundColor` themable color
- Adds `gitlens.lineHighlightOverviewRulerColor` themable color
- Adds `gitlens.advanced.messages` setting to specify which messages should be suppressed
### Changed
- Renames `gitlens.theme.annotations.file.gutter.separateLines` setting to `gitlens.annotations.file.gutter.separateLines`
- Changes from using `globalState` to use `gitlens.advanced.messages` setting for message suppression - provides more control and avoids strange intermittent with `globalState`
### Removed
- Removes `gitlens.theme.*` settings - now using built-in theme support
## [6.1.2] - 2017-11-21
### Fixed
- Fixes [#207](https://github.com/eamodio/vscode-gitlens/issues/207) - Applying and deleting stashes suddenly stopped working
@ -478,7 +490,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [4.0.0] - 2017-06-09
### Added
- Adds all-new, beautiful, highly customizable and themeable, file blame annotations
- Adds all-new, beautiful, highly customizable and themable, file blame annotations
- Can now fully customize the [layout and content](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens#file-blame-annotation-settings), as well as the [theme](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens#theme-settings)
- Adds all-new configurability and themeability to the current line blame annotations
- Can now fully customize the [layout and content](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens#line-blame-annotation-settings), as well as the [theme](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens#theme-settings)

+ 18
- 23
README.md View File

@ -33,7 +33,7 @@ While GitLens is highly customizable and provides many [configuration settings](
### Git Blame Annotations
- Adds an unobtrusive, highly [customizable](#line-blame-annotation-settings) and [themeable](#theme-settings), **Git blame annotation** to the end of the current line ([optional](#line-blame-annotation-settings), on by default)
- Adds an unobtrusive, highly [customizable](#line-blame-annotation-settings) and [themable](#themable-colors), **Git blame annotation** to the end of the current line ([optional](#line-blame-annotation-settings), on by default)
![Line Blame Annotation](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-line-blame-annotation.png)
![Line Blame Annotations (hover)](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-line-blame-annotations.png)
@ -52,7 +52,7 @@ While GitLens is highly customizable and provides many [configuration settings](
- Clicking on `Changes` will run the `Compare File Revisions` command (`gitlens.diffWith`)
- Clicking the current and previous commit ids will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
- Adds on-demand, beautiful, highly [customizable](#file-blame-annotation-settings) and [themeable](#theme-settings), **Git blame annotations** of the whole file
- Adds on-demand, beautiful, highly [customizable](#file-blame-annotation-settings) and [themable](#themable-colors), **Git blame annotations** of the whole file
![File Blame Annotation](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-file-blame-annotation.png)
@ -94,7 +94,7 @@ While GitLens is highly customizable and provides many [configuration settings](
### Git Recent Changes Annotations
- Adds on-demand, [customizable](#file-recent-changes-annotation-settings) and [themeable](#theme-settings), **recent changes annotations** of the whole file
- Adds on-demand, [customizable](#file-recent-changes-annotation-settings) and [themable](#themable-colors), **recent changes annotations** of the whole file
- Highlights all of lines changed in the most recent commit
- Adds a `details` hover annotation to each line, which provides more commit details ([optional](#file-recent-changes-annotation-settings), on by default)
- Clicking the commit id will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
@ -321,6 +321,20 @@ While GitLens is highly customizable and provides many [configuration settings](
Add [`"gitlens.insiders": true`](#general-extension-settings) to your settings to join the insiders channel and get early access to upcoming features. Be aware that because this provides early access expect there to be issues.
## Themable Colors
GitLens defines a set of themable colors which can be provided by vscode themes or directly by the user using [`workbench.colorCustomization`](https://code.visualstudio.com/docs/getstarted/themes#_customize-a-color-theme).
|Name | Description
|-----|------------
|`gitlens.gutterBackgroundColor`|Specifies the background color of the gutter blame annotations
|`gitlens.gutterForegroundColor`|Specifies the foreground color of the gutter blame annotations
|`gitlens.gutterUncommittedForegroundColor`|Specifies the foreground color of an uncommitted line in the gutter blame annotations
|`gitlens.trailingLineBackgroundColor`|Specifies the background color of the trailing blame annotation
|`gitlens.trailingLineForegroundColor`|Specifies the foreground color of the trailing blame annotation
|`gitlens.lineHighlightBackgroundColor`|Specifies the background color of the associated line highlights in blame annotations
|`gitlens.lineHighlightOverviewRulerColor`|Specifies the overview ruler color of the associated line highlights in blame annotations
## Extension Settings
GitLens is highly customizable and provides many configuration settings to allow the personalization of almost all features
@ -354,6 +368,7 @@ GitLens is highly customizable and provides many configuration settings to allow
|`gitlens.annotations.file.gutter.hover.details`|Specifies whether or not to provide a commit details hover annotation over the gutter blame annotations
|`gitlens.annotations.file.gutter.hover.changes`|Specifies whether or not to provide a changes (diff) hover annotation over the gutter blame annotations
|`gitlens.annotations.file.gutter.hover.wholeLine`|Specifies whether or not to trigger hover annotations over the whole line
|`gitlens.annotations.file.gutter.separateLines`|Specifies whether or not gutter blame annotations will have line separators
|`gitlens.annotations.file.hover.details`|Specifies whether or not to provide a commit details hover annotation over each line
|`gitlens.annotations.file.hover.changes`|Specifies whether or not to provide a changes (diff) hover annotation over each line
|`gitlens.annotations.file.hover.heatmap.enabled`|Specifies whether or not to provide heatmap indicators on the left edge of each line
@ -435,26 +450,6 @@ GitLens is highly customizable and provides many configuration settings to allow
|`gitlens.strings.codeLens.unsavedChanges.recentChangeOnly`|Specifies the string to be shown in place of the `recent change` code lens when there are unsaved changes
|`gitlens.strings.codeLens.unsavedChanges.authorsOnly`|Specifies the string to be shown in place of the `authors` code lens when there are unsaved changes
### Theme Settings
|Name | Description
|-----|------------
|`gitlens.theme.annotations.file.gutter.separateLines`|Specifies whether or not gutter blame annotations will have line separators
|`gitlens.theme.annotations.file.gutter.dark.backgroundColor`|Specifies the dark theme background color of the gutter blame annotations
|`gitlens.theme.annotations.file.gutter.light.backgroundColor`|Specifies the light theme background color of the gutter blame annotations
|`gitlens.theme.annotations.file.gutter.dark.foregroundColor`|Specifies the dark theme foreground color of the gutter blame annotations
|`gitlens.theme.annotations.file.gutter.light.foregroundColor`|Specifies the light theme foreground color of the gutter blame annotations
|`gitlens.theme.annotations.file.gutter.dark.uncommittedForegroundColor`|Specifies the dark theme foreground color of an uncommitted line in the gutter blame annotations
|`gitlens.theme.annotations.file.gutter.light.uncommittedForegroundColor`|Specifies the light theme foreground color of an uncommitted line in the gutter blame annotations
|`gitlens.theme.annotations.line.trailing.dark.backgroundColor`|Specifies the dark theme background color of the trailing blame annotation
|`gitlens.theme.annotations.line.trailing.light.backgroundColor`|Specifies the light theme background color of the trailing blame annotation
|`gitlens.theme.annotations.line.trailing.dark.foregroundColor`|Specifies the dark theme foreground color of the trailing blame annotation
|`gitlens.theme.annotations.line.trailing.light.foregroundColor`|Specifies the light theme foreground color of the trailing blame annotation
|`gitlens.theme.lineHighlight.dark.backgroundColor`|Specifies the dark theme background color of the associated line highlights in blame annotations. Must be a valid css color
|`gitlens.theme.lineHighlight.light.backgroundColor`|Specifies the light theme background color of the associated line highlights in blame annotations. Must be a valid css color
|`gitlens.theme.lineHighlight.dark.overviewRulerColor`|Specifies the dark theme overview ruler color of the associated line highlights in blame annotations
|`gitlens.theme.lineHighlight.light.overviewRulerColor`|Specifies the light theme overview ruler color of the associated line highlights in blame annotations
### Advanced Settings
|Name | Description

+ 71
- 90
package.json View File

@ -128,6 +128,12 @@
"description": "Specifies whether or not to trigger hover annotations over the whole line",
"scope": "window"
},
"gitlens.annotations.file.gutter.separateLines": {
"type": "boolean",
"default": true,
"description": "Specifies whether or not gutter blame annotations will be separated by a small gap",
"scope": "window"
},
"gitlens.annotations.file.hover.details": {
"type": "boolean",
"default": true,
@ -701,96 +707,6 @@
"description": "Specifies the string to be shown in place of the `authors` code lens when there are unsaved changes",
"scope": "window"
},
"gitlens.theme.annotations.file.gutter.separateLines": {
"type": "boolean",
"default": true,
"description": "Specifies whether or not gutter blame annotations will be separated by a small gap",
"scope": "window"
},
"gitlens.theme.annotations.file.gutter.dark.backgroundColor": {
"type": "string",
"default": "rgba(255, 255, 255, 0.075)",
"description": "Specifies the dark theme background color of the gutter blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.annotations.file.gutter.light.backgroundColor": {
"type": "string",
"default": "rgba(0, 0, 0, 0.05)",
"description": "Specifies the light theme background color of the gutter blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.annotations.file.gutter.dark.foregroundColor": {
"type": "string",
"default": "rgb(190, 190, 190)",
"description": "Specifies the dark theme foreground color of the gutter blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.annotations.file.gutter.light.foregroundColor": {
"type": "string",
"default": "rgb(116, 116, 116)",
"description": "Specifies the light theme foreground color of the gutter blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.annotations.file.gutter.dark.uncommittedForegroundColor": {
"type": "string",
"default": "rgba(0, 188, 242, 0.6)",
"description": "Specifies the dark theme foreground color of an uncommitted line in the gutter blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.annotations.file.gutter.light.uncommittedForegroundColor": {
"type": "string",
"default": "rgba(0, 188, 242, 0.6)",
"description": "Specifies the light theme foreground color of an uncommitted line in the gutter blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.annotations.line.trailing.dark.backgroundColor": {
"type": "string",
"default": null,
"description": "Specifies the dark theme background color of the trailing blame annotation. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.annotations.line.trailing.light.backgroundColor": {
"type": "string",
"default": null,
"description": "Specifies the light theme background color of the trailing blame annotation. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.annotations.line.trailing.dark.foregroundColor": {
"type": "string",
"default": "rgba(153, 153, 153, 0.35)",
"description": "Specifies the dark theme foreground color of the trailing blame annotation. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.annotations.line.trailing.light.foregroundColor": {
"type": "string",
"default": "rgba(153, 153, 153, 0.35)",
"description": "Specifies the light theme foreground color of the trailing blame annotation. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.lineHighlight.dark.backgroundColor": {
"type": "string",
"default": "rgba(0, 188, 242, 0.2)",
"description": "Specifies the dark theme background color of the associated line highlights in blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.lineHighlight.light.backgroundColor": {
"type": "string",
"default": "rgba(0, 188, 242, 0.2)",
"description": "Specifies the light theme background color of the associated line highlights in blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.lineHighlight.dark.overviewRulerColor": {
"type": "string",
"default": "rgba(0, 188, 242, 0.6)",
"description": "Specifies the dark theme overview ruler color of the associated line highlights in blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.theme.lineHighlight.light.overviewRulerColor": {
"type": "string",
"default": "rgba(0, 188, 242, 0.6)",
"description": "Specifies the light theme overview ruler color of the associated line highlights in blame annotations. Must be a valid css color",
"scope": "window"
},
"gitlens.advanced.caching.enabled": {
"type": "boolean",
"default": true,
@ -1043,6 +959,71 @@
}
}
},
"colors": [
{
"id": "gitlens.gutterBackgroundColor",
"description": "Specifies the background color of the gutter blame annotations",
"defaults": {
"dark": "#FFFFFF13",
"light": "#0000000C",
"highContrast": "#FFFFFF13"
}
},
{
"id": "gitlens.gutterForegroundColor",
"description": "Specifies the foreground color of the gutter blame annotations",
"defaults": {
"dark": "#BEBEBE",
"light": "#747474",
"highContrast": "#BEBEBE"
}
},
{
"id": "gitlens.gutterUncommittedForegroundColor",
"description": "Specifies the foreground color of an uncommitted line in the gutter blame annotations",
"defaults": {
"dark": "#00BCF299",
"light": "#00BCF299",
"highContrast": "#00BCF2FF"
}
},
{
"id": "gitlens.trailingLineBackgroundColor",
"description": "Specifies the background color of the trailing blame annotation",
"defaults": {
"dark": "#00000000",
"light": "#00000000",
"highContrast": "#00000000"
}
},
{
"id": "gitlens.trailingLineForegroundColor",
"description": "Specifies the foreground color of the trailing blame annotation",
"defaults": {
"dark": "#99999959",
"light": "#99999959",
"highContrast": "#99999999"
}
},
{
"id": "gitlens.lineHighlightBackgroundColor",
"description": "Specifies the background color of the associated line highlights in blame annotations",
"defaults": {
"dark": "#00BCF233",
"light": "#00BCF233",
"highContrast": "#00BCF233"
}
},
{
"id": "gitlens.lineHighlightOverviewRulerColor",
"description": "Specifies the overview ruler color of the associated line highlights in blame annotations",
"defaults": {
"dark": "#00BCF299",
"light": "#00BCF299",
"highContrast": "#00BCF299"
}
}
],
"commands": [
{
"command": "gitlens.diffDirectory",

+ 16
- 33
src/annotations/annotationController.ts View File

@ -1,6 +1,6 @@
'use strict';
import { Functions, Iterables } from '../system';
import { ConfigurationChangeEvent, DecorationRangeBehavior, DecorationRenderOptions, Disposable, Event, EventEmitter, ExtensionContext, OverviewRulerLane, Progress, ProgressLocation, TextDocument, TextDocumentChangeEvent, TextEditor, TextEditorDecorationType, TextEditorViewColumnChangeEvent, window, workspace } from 'vscode';
import { ConfigurationChangeEvent, DecorationRangeBehavior, DecorationRenderOptions, Disposable, Event, EventEmitter, ExtensionContext, OverviewRulerLane, Progress, ProgressLocation, TextDocument, TextDocumentChangeEvent, TextEditor, TextEditorDecorationType, TextEditorViewColumnChangeEvent, ThemeColor, window, workspace } from 'vscode';
import { AnnotationProviderBase, TextEditorCorrelationKey } from './annotationProvider';
import { TextDocumentComparer } from '../comparers';
import { configuration, IConfig, LineHighlightLocations } from '../configuration';
@ -85,40 +85,32 @@ export class AnnotationController extends Disposable {
let cfg: IConfig | undefined;
if (initializing ||
configuration.changed(e, configuration.name('blame')('file')('lineHighlight').value) ||
configuration.changed(e, configuration.name('theme')('lineHighlight').value)) {
configuration.changed(e, configuration.name('blame')('file')('lineHighlight').value)) {
Decorations.blameHighlight && Decorations.blameHighlight.dispose();
cfg = configuration.get<IConfig>();
const cfgHighlight = cfg.blame.file.lineHighlight;
const cfgTheme = cfg.theme.lineHighlight;
if (cfgHighlight.enabled) {
Decorations.blameHighlight = window.createTextEditorDecorationType({
gutterIconSize: 'contain',
isWholeLine: true,
overviewRulerLane: OverviewRulerLane.Right,
backgroundColor: cfgHighlight.locations.includes(LineHighlightLocations.Line)
? new ThemeColor('gitlens.lineHighlightBackgroundColor')
: undefined,
overviewRulerColor: cfgHighlight.locations.includes(LineHighlightLocations.OverviewRuler)
? new ThemeColor('gitlens.lineHighlightOverviewRulerColor')
: undefined,
dark: {
backgroundColor: cfgHighlight.locations.includes(LineHighlightLocations.Line)
? cfgTheme.dark.backgroundColor || configuration.defaults.theme.lineHighlight.dark.backgroundColor
: undefined,
gutterIconPath: cfgHighlight.locations.includes(LineHighlightLocations.Gutter)
? this.context.asAbsolutePath('images/dark/highlight-gutter.svg')
: undefined,
overviewRulerColor: cfgHighlight.locations.includes(LineHighlightLocations.OverviewRuler)
? cfgTheme.dark.overviewRulerColor || configuration.defaults.theme.lineHighlight.dark.overviewRulerColor
: undefined
},
light: {
backgroundColor: cfgHighlight.locations.includes(LineHighlightLocations.Line)
? cfgTheme.light.backgroundColor || configuration.defaults.theme.lineHighlight.light.backgroundColor
: undefined,
gutterIconPath: cfgHighlight.locations.includes(LineHighlightLocations.Gutter)
? this.context.asAbsolutePath('images/light/highlight-gutter.svg')
: undefined,
overviewRulerColor: cfgHighlight.locations.includes(LineHighlightLocations.OverviewRuler)
? cfgTheme.light.overviewRulerColor || configuration.defaults.theme.lineHighlight.light.overviewRulerColor
: undefined
}
});
@ -129,40 +121,32 @@ export class AnnotationController extends Disposable {
}
if (initializing ||
configuration.changed(e, configuration.name('recentChanges')('file')('lineHighlight').value) ||
configuration.changed(e, configuration.name('theme')('lineHighlight').value)) {
configuration.changed(e, configuration.name('recentChanges')('file')('lineHighlight').value)) {
Decorations.recentChangesHighlight && Decorations.recentChangesHighlight.dispose();
if (cfg === undefined) {
cfg = configuration.get<IConfig>();
}
const cfgHighlight = cfg.recentChanges.file.lineHighlight;
const cfgTheme = cfg.theme.lineHighlight;
Decorations.recentChangesHighlight = window.createTextEditorDecorationType({
gutterIconSize: 'contain',
isWholeLine: true,
overviewRulerLane: OverviewRulerLane.Right,
backgroundColor: cfgHighlight.locations.includes(LineHighlightLocations.Line)
? new ThemeColor('gitlens.lineHighlightBackgroundColor')
: undefined,
overviewRulerColor: cfgHighlight.locations.includes(LineHighlightLocations.OverviewRuler)
? new ThemeColor('gitlens.lineHighlightOverviewRulerColor')
: undefined,
dark: {
backgroundColor: cfgHighlight.locations.includes(LineHighlightLocations.Line)
? cfgTheme.dark.backgroundColor || configuration.defaults.theme.lineHighlight.dark.backgroundColor
: undefined,
gutterIconPath: cfgHighlight.locations.includes(LineHighlightLocations.Gutter)
? this.context.asAbsolutePath('images/dark/highlight-gutter.svg')
: undefined,
overviewRulerColor: cfgHighlight.locations.includes(LineHighlightLocations.OverviewRuler)
? cfgTheme.dark.overviewRulerColor || configuration.defaults.theme.lineHighlight.dark.overviewRulerColor
: undefined
},
light: {
backgroundColor: cfgHighlight.locations.includes(LineHighlightLocations.Line)
? cfgTheme.light.backgroundColor || configuration.defaults.theme.lineHighlight.light.backgroundColor
: undefined,
gutterIconPath: cfgHighlight.locations.includes(LineHighlightLocations.Gutter)
? this.context.asAbsolutePath('images/light/highlight-gutter.svg')
: undefined,
overviewRulerColor: cfgHighlight.locations.includes(LineHighlightLocations.OverviewRuler)
? cfgTheme.light.overviewRulerColor || configuration.defaults.theme.lineHighlight.light.overviewRulerColor
: undefined
}
});
@ -172,8 +156,7 @@ export class AnnotationController extends Disposable {
if (configuration.changed(e, configuration.name('blame')('file').value) ||
configuration.changed(e, configuration.name('recentChanges')('file').value) ||
configuration.changed(e, configuration.name('annotations')('file').value) ||
configuration.changed(e, configuration.name('theme')('annotations')('file').value)) {
configuration.changed(e, configuration.name('annotations')('file').value)) {
if (cfg === undefined) {
cfg = configuration.get<IConfig>();
}

+ 38
- 77
src/annotations/annotations.ts View File

@ -1,8 +1,7 @@
import { Dates, Objects, Strings } from '../system';
import { DecorationInstanceRenderOptions, DecorationOptions, MarkdownString, ThemableDecorationRenderOptions, window } from 'vscode';
import { DecorationInstanceRenderOptions, DecorationOptions, MarkdownString, ThemableDecorationRenderOptions, ThemeColor, window } from 'vscode';
import { FileAnnotationType } from './annotationController';
import { DiffWithCommand, OpenCommitInRemoteCommand, OpenFileRevisionCommand, ShowQuickCommitDetailsCommand, ShowQuickCommitFileDetailsCommand } from '../commands';
import { IThemeConfig, themeDefaults } from '../configuration';
import { GlyphChars } from '../constants';
import { CommitFormatter, GitCommit, GitDiffChunkLine, GitService, GitUri, ICommitFormatOptions } from '../gitService';
@ -11,15 +10,9 @@ interface IHeatmapConfig {
location?: 'left' | 'right';
}
interface IRenderOptions {
uncommittedForegroundColor?: {
dark: string;
light: string;
};
before?: DecorationInstanceRenderOptions & ThemableDecorationRenderOptions & { height?: string };
dark?: DecorationInstanceRenderOptions;
light?: DecorationInstanceRenderOptions;
interface IRenderOptions extends DecorationInstanceRenderOptions, ThemableDecorationRenderOptions {
height?: string;
uncommittedColor?: string | ThemeColor;
}
export const endOfLineIndex = 1000000;
@ -137,33 +130,23 @@ export class Annotations {
}
static gutter(commit: GitCommit, format: string, dateFormatOrFormatOptions: string | null | ICommitFormatOptions, renderOptions: IRenderOptions): DecorationOptions {
const message = CommitFormatter.fromTemplate(format, commit, dateFormatOrFormatOptions);
return {
const decoration = {
renderOptions: {
before: {
...renderOptions.before,
...{
contentText: Strings.pad(message.replace(/ /g, GlyphChars.Space), 1, 1)
}
},
dark: {
before: commit.isUncommitted
? { ...renderOptions.dark, ...{ color: renderOptions.uncommittedForegroundColor!.dark } }
: { ...renderOptions.dark }
},
light: {
before: commit.isUncommitted
? { ...renderOptions.light, ...{ color: renderOptions.uncommittedForegroundColor!.light } }
: { ...renderOptions.light }
}
before: { ...renderOptions }
} as DecorationInstanceRenderOptions
} as DecorationOptions;
}
static gutterRenderOptions(cfgTheme: IThemeConfig, heatmap: IHeatmapConfig, options: ICommitFormatOptions): IRenderOptions {
const cfgFileTheme = cfgTheme.annotations.file.gutter;
if (commit.isUncommitted) {
decoration.renderOptions!.before!.color = renderOptions.uncommittedColor;
}
const message = CommitFormatter.fromTemplate(format, commit, dateFormatOrFormatOptions);
decoration.renderOptions!.before!.contentText = Strings.pad(message.replace(/ /g, GlyphChars.Space), 1, 1);
return decoration;
}
static gutterRenderOptions(separateLines: boolean, heatmap: IHeatmapConfig, options: ICommitFormatOptions): IRenderOptions {
// Try to get the width of the string, if there is a cap
let width = 4; // Start with a padding
for (const token of Objects.values(options.tokenOptions!)) {
@ -186,54 +169,42 @@ export class Annotations {
}
return {
uncommittedForegroundColor: {
dark: cfgFileTheme.dark.uncommittedForegroundColor || cfgFileTheme.dark.foregroundColor || themeDefaults.annotations.file.gutter.dark.foregroundColor,
light: cfgFileTheme.light.uncommittedForegroundColor || cfgFileTheme.light.foregroundColor || themeDefaults.annotations.file.gutter.light.foregroundColor
},
before: {
borderStyle: borderStyle,
borderWidth: borderWidth,
height: '100%',
margin: '0 26px -1px 0',
width: (width > 4) ? `${width}ch` : undefined
},
dark: {
backgroundColor: cfgFileTheme.dark.backgroundColor || undefined,
color: cfgFileTheme.dark.foregroundColor || themeDefaults.annotations.file.gutter.dark.foregroundColor,
textDecoration: cfgFileTheme.separateLines ? 'overline solid rgba(0, 0, 0, .2)' : 'none'
} as DecorationInstanceRenderOptions,
light: {
backgroundColor: cfgFileTheme.light.backgroundColor || undefined,
color: cfgFileTheme.light.foregroundColor || themeDefaults.annotations.file.gutter.light.foregroundColor,
textDecoration: cfgFileTheme.separateLines ? 'overline solid rgba(0, 0, 0, .05)' : 'none'
} as DecorationInstanceRenderOptions
backgroundColor: new ThemeColor('gitlens.gutterBackgroundColor'),
borderStyle: borderStyle,
borderWidth: borderWidth,
color: new ThemeColor('gitlens.gutterForegroundColor'),
height: '100%',
margin: '0 26px -1px 0',
textDecoration: separateLines ? 'overline solid rgba(0, 0, 0, .2)' : 'none',
width: (width > 4) ? `${width}ch` : undefined,
uncommittedColor: new ThemeColor('gitlens.gutterUncommittedForegroundColor')
} as IRenderOptions;
}
static hover(commit: GitCommit, renderOptions: IRenderOptions, now: number): DecorationOptions {
const decoration = {
renderOptions: { before: { ...renderOptions.before } }
renderOptions: { before: { ...renderOptions } }
} as DecorationOptions;
this.applyHeatmap(decoration, commit.date, now);
return decoration;
}
static hoverRenderOptions(cfgTheme: IThemeConfig, heatmap: IHeatmapConfig): IRenderOptions {
static hoverRenderOptions(heatmap: IHeatmapConfig): IRenderOptions {
if (!heatmap.enabled) return { before: undefined };
return {
before: {
borderStyle: 'solid',
borderWidth: '0 0 0 2px',
contentText: GlyphChars.ZeroWidthSpace,
height: '100%',
margin: '0 26px 0 0',
textDecoration: 'none'
}
borderStyle: 'solid',
borderWidth: '0 0 0 2px',
contentText: GlyphChars.ZeroWidthSpace,
height: '100%',
margin: '0 26px 0 0',
textDecoration: 'none'
} as IRenderOptions;
}
static trailing(commit: GitCommit, format: string, dateFormat: string | null, cfgTheme: IThemeConfig): DecorationOptions {
static trailing(commit: GitCommit, format: string, dateFormat: string | null): DecorationOptions {
const message = CommitFormatter.fromTemplate(format, commit, {
truncateMessageAtNewLine: true,
dateFormat: dateFormat
@ -242,19 +213,9 @@ export class Annotations {
return {
renderOptions: {
after: {
backgroundColor: new ThemeColor('gitlens.trailingLineBackgroundColor'),
color: new ThemeColor('gitlens.trailingLineForegroundColor'),
contentText: Strings.pad(message.replace(/ /g, GlyphChars.Space), 1, 1)
},
dark: {
after: {
backgroundColor: cfgTheme.annotations.line.trailing.dark.backgroundColor || undefined,
color: cfgTheme.annotations.line.trailing.dark.foregroundColor || themeDefaults.annotations.line.trailing.dark.foregroundColor
}
},
light: {
after: {
backgroundColor: cfgTheme.annotations.line.trailing.light.backgroundColor || undefined,
color: cfgTheme.annotations.line.trailing.light.foregroundColor || themeDefaults.annotations.line.trailing.light.foregroundColor
}
}
} as DecorationInstanceRenderOptions
} as DecorationOptions;

+ 3
- 11
src/annotations/gutterBlameAnnotationProvider.ts View File

@ -33,8 +33,8 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
};
const now = Date.now();
const renderOptions = Annotations.gutterRenderOptions(this._config.theme, cfg.heatmap, options);
const separateLines = this._config.theme.annotations.file.gutter.separateLines;
const separateLines = this._config.annotations.file.gutter.separateLines;
const renderOptions = Annotations.gutterRenderOptions(separateLines, cfg.heatmap, options);
this._decorations = [];
const decorationsMap: { [sha: string]: DecorationOptions | undefined } = Object.create(null);
@ -54,7 +54,6 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
if (cfg.compact && !compacted) {
// Since we are wiping out the contextText make sure to copy the objects
gutter.renderOptions = {
...gutter.renderOptions,
before: {
...gutter.renderOptions!.before,
contentText: GlyphChars.Space.repeat(Strings.width(gutter.renderOptions!.before!.contentText!))
@ -62,14 +61,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
};
if (separateLines) {
gutter.renderOptions.dark = {
...gutter.renderOptions.dark,
before: { ...gutter.renderOptions.dark!.before, textDecoration: 'none' }
};
gutter.renderOptions.light = {
...gutter.renderOptions.light,
before: { ...gutter.renderOptions.light!.before, textDecoration: 'none' }
};
gutter.renderOptions!.before!.textDecoration = 'none';
}
compacted = true;

+ 1
- 1
src/annotations/hoverBlameAnnotationProvider.ts View File

@ -20,7 +20,7 @@ export class HoverBlameAnnotationProvider extends BlameAnnotationProviderBase {
const start = process.hrtime();
const now = Date.now();
const renderOptions = Annotations.hoverRenderOptions(this._config.theme, cfg.heatmap);
const renderOptions = Annotations.hoverRenderOptions(cfg.heatmap);
this._decorations = [];
const decorationsMap: { [sha: string]: DecorationOptions } = Object.create(null);

+ 3
- 91
src/configuration.ts View File

@ -170,92 +170,6 @@ export interface IRemotesUrlsConfig {
fileRange: string;
}
export interface IThemeConfig {
annotations: {
file: {
gutter: {
separateLines: boolean;
dark: {
backgroundColor: string | null;
foregroundColor: string;
uncommittedForegroundColor: string | null;
};
light: {
backgroundColor: string | null;
foregroundColor: string;
uncommittedForegroundColor: string | null;
};
};
};
line: {
trailing: {
dark: {
backgroundColor: string | null;
foregroundColor: string;
};
light: {
backgroundColor: string | null;
foregroundColor: string;
};
};
};
};
lineHighlight: {
dark: {
backgroundColor: string;
overviewRulerColor: string;
};
light: {
backgroundColor: string;
overviewRulerColor: string;
};
};
}
export const themeDefaults: IThemeConfig = {
annotations: {
file: {
gutter: {
separateLines: true,
dark: {
backgroundColor: null,
foregroundColor: 'rgb(190, 190, 190)',
uncommittedForegroundColor: null
},
light: {
backgroundColor: null,
foregroundColor: 'rgb(116, 116, 116)',
uncommittedForegroundColor: null
}
}
},
line: {
trailing: {
dark: {
backgroundColor: null,
foregroundColor: 'rgba(153, 153, 153, 0.35)'
},
light: {
backgroundColor: null,
foregroundColor: 'rgba(153, 153, 153, 0.35)'
}
}
}
},
lineHighlight: {
dark: {
backgroundColor: 'rgba(0, 188, 242, 0.2)',
overviewRulerColor: 'rgba(0, 188, 242, 0.6)'
},
light: {
backgroundColor: 'rgba(0, 188, 242, 0.2)',
overviewRulerColor: 'rgba(0, 188, 242, 0.6)'
}
}
};
export interface IConfig {
annotations: {
file: {
@ -272,6 +186,7 @@ export interface IConfig {
changes: boolean;
wholeLine: boolean;
};
separateLines: boolean;
};
hover: {
@ -359,8 +274,6 @@ export interface IConfig {
};
};
theme: IThemeConfig;
debug: boolean;
insiders: boolean;
outputLevel: OutputLevel;
@ -383,7 +296,8 @@ const emptyConfig: IConfig = {
details: false,
changes: false,
wholeLine: false
}
},
separateLines: false
},
hover: {
details: false,
@ -487,7 +401,6 @@ const emptyConfig: IConfig = {
}
}
},
theme: themeDefaults,
debug: false,
insiders: false,
outputLevel: 'verbose' as OutputLevel,
@ -563,7 +476,6 @@ export class Configuration {
this._onDidChange.fire(e);
}
readonly defaults = { theme: themeDefaults };
readonly initializingChangeEvent: ConfigurationChangeEvent = {
affectsConfiguration: (section: string, resource?: Uri) => false
};

+ 2
- 3
src/currentLineController.ts View File

@ -81,8 +81,7 @@ export class CurrentLineController extends Disposable {
if (initializing ||
configuration.changed(e, configuration.name('annotations')('line')('trailing').value) ||
configuration.changed(e, configuration.name('annotations')('line')('hover').value) ||
configuration.changed(e, configuration.name('theme')('annotations')('line')('trailing').value)) {
configuration.changed(e, configuration.name('annotations')('line')('hover').value)) {
changed = true;
}
@ -366,7 +365,7 @@ export class CurrentLineController extends Disposable {
line = line === undefined ? blameLine.line : line;
const cfg = this._config.annotations.line.trailing;
const decoration = Annotations.trailing(commit, cfg.format, cfg.dateFormat === null ? this._config.defaultDateFormat : cfg.dateFormat, this._config.theme);
const decoration = Annotations.trailing(commit, cfg.format, cfg.dateFormat === null ? this._config.defaultDateFormat : cfg.dateFormat);
decoration.range = editor.document.validateRange(new Range(line, endOfLineIndex, line, endOfLineIndex));
editor.setDecorations(annotationDecoration, [decoration]);

Loading…
Cancel
Save