Skip to content

Commit

Permalink
Closes #542 - adds file annotation option to modes
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Dec 31, 2018
1 parent 7ca0da6 commit 18ee54d
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 48 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- Adds the ability to turn on file annotations (blame, heatmap, and recent changes) via user-defined modes — closes [#542](https://github.com/eamodio/vscode-gitlens/issues/542)

## [9.2.4] - 2018-12-26

### Added
Expand Down
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -831,12 +831,12 @@ See also [View Settings](#view-settings- 'Jump to the View settings')

### Modes Settings [#](#modes-settings- 'Modes Settings')

| Name | Description |
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.mode.active` | Specifies the active GitLens mode, if any |
| `gitlens.mode.statusBar.enabled` | Specifies whether to provide the active GitLens mode in the status bar |
| `gitlens.mode.statusBar.alignment` | Specifies the active GitLens mode alignment in the status bar<br /><br />`left` - aligns to the left<br />`right` - aligns to the right |
| `gitlens.modes` | Specifies the user-defined GitLens modes |
| Name | Description |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `gitlens.mode.active` | Specifies the active GitLens mode, if any |
| `gitlens.mode.statusBar.enabled` | Specifies whether to provide the active GitLens mode in the status bar |
| `gitlens.mode.statusBar.alignment` | Specifies the active GitLens mode alignment in the status bar<br /><br />`left` - aligns to the left<br />`right` - aligns to the right |
| `gitlens.modes` | Specifies the user-defined GitLens modes<br /><br />Example &mdash; adds heatmap annotations to the built-in _Reviewing_ mode<br />`"gitlens.modes": { "review": { "annotations": "heatmap" } }`<br /><br />Example &mdash; adds a new _Annotating_ mode with blame annotations<br />`"gitlens.modes": {`<br />&nbsp;&nbsp;&nbsp;&nbsp;`"annotate": {`<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"name": "Annotating",`<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"statusBarItemName": "Annotating",`<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"description": "for root cause analysis",`<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"annotations": "blame",`<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"codeLens": false,`<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"currentLine": false,`<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`"hovers": true`<br />&nbsp;&nbsp;&nbsp;&nbsp;`}`<br />`}` |

### Advanced Settings [#](#advanced-settings- 'Advanced Settings')

Expand Down
98 changes: 68 additions & 30 deletions package.json
Expand Up @@ -841,65 +841,75 @@
"properties": {
"zen": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
"type": "string",
"description": "Specifies the friendly name of this user-defined mode"
},
"statusBarItemName": {
"type": "string"
"type": "string",
"description": "Specifies the name shown in the status bar when this user-defined mode is active"
},
"description": {
"type": "string"
"type": "string",
"description": "Specifies the description of this user-defined mode"
},
"codeLens": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show any Git code lens when this user-defined mode is active"
},
"currentLine": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show a blame annotation for the current line when this user-defined mode is active"
},
"hovers": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show any hovers when this user-defined mode is active"
},
"statusBar": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show blame information in the status bar when this user-defined mode is active"
},
"views": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show any GitLens views when this user-defined mode is active"
}
}
},
"review": {
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
"type": "string",
"description": "Specifies the friendly name of this user-defined mode"
},
"statusBarItemName": {
"type": "string"
"type": "string",
"description": "Specifies the name shown in the status bar when this user-defined mode is active"
},
"description": {
"type": "string"
"type": "string",
"description": "Specifies the description of this user-defined mode"
},
"codeLens": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show any Git code lens when this user-defined mode is active"
},
"currentLine": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show a blame annotation for the current line when this user-defined mode is active"
},
"hovers": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show any hovers when this user-defined mode is active"
},
"statusBar": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show blame information in the status bar when this user-defined mode is active"
},
"views": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show any GitLens views when this user-defined mode is active"
}
}
}
Expand All @@ -911,28 +921,50 @@
],
"properties": {
"name": {
"type": "string"
"type": "string",
"description": "Specifies the friendly name of this user-defined mode"
},
"statusBarItemName": {
"type": "string"
"type": "string",
"description": "Specifies the name shown in the status bar when this user-defined mode is active"
},
"description": {
"type": "string"
"type": "string",
"description": "Specifies the description of this user-defined mode"
},
"annotations": {
"type": "string",
"enum": [
"blame",
"heatmap",
"recentChanges"
],
"enumDescriptions": [
"Shows the gutter blame annotations",
"Shows the gutter heatmap annotations",
"Shows the recently changed lines annotations"
],
"description": "Specifies which (if any) file annotations will be shown when this user-defined mode is active"
},
"codeLens": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show any Git code lens when this user-defined mode is active"
},
"currentLine": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show a blame annotation for the current line when this user-defined mode is active"
},
"hovers": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show any hovers when this user-defined mode is active"
},
"statusBar": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show blame information in the status bar when this user-defined mode is active"
},
"views": {
"type": "boolean"
"type": "boolean",
"description": "Specifies whether to show any GitLens views when this user-defined mode is active"
}
}
},
Expand Down Expand Up @@ -967,6 +999,12 @@
"verbose",
"debug"
],
"enumDescriptions": [
"Logs nothing",
"Logs only errors",
"Logs all errors, warnings, and messages",
"Logs all errors, warnings, and messages with extra context useful for debugging"
],
"markdownDescription": "Specifies how much (if any) output will be sent to the GitLens output channel",
"scope": "window"
},
Expand Down
5 changes: 1 addition & 4 deletions src/annotations/annotations.ts
Expand Up @@ -344,10 +344,7 @@ export class Annotations {
static heatmapRenderOptions(): IRenderOptions {
return {
borderStyle: 'solid',
borderWidth: '0 0 0 2px',
contentText: GlyphChars.ZeroWidthSpace,
height: '100%',
margin: '0 26px -1px 0'
borderWidth: '0 0 0 2px'
} as IRenderOptions;
}

Expand Down
14 changes: 11 additions & 3 deletions src/annotations/fileAnnotationController.ts
Expand Up @@ -19,7 +19,7 @@ import {
workspace
} from 'vscode';
import { AnnotationsToggleMode, configuration, FileAnnotationType, HighlightLocations } from '../configuration';
import { CommandContext, isTextEditor, setCommandContext } from '../constants';
import { CommandContext, GlyphChars, isTextEditor, setCommandContext } from '../constants';
import { Container } from '../container';
import { KeyboardScope, KeyCommand, Keys } from '../keyboard';
import { Logger } from '../logger';
Expand Down Expand Up @@ -49,7 +49,13 @@ export const Decorations = {
textDecoration: 'none'
} as DecorationRenderOptions),
blameHighlight: undefined as TextEditorDecorationType | undefined,
heatmapAnnotation: window.createTextEditorDecorationType({} as DecorationRenderOptions),
heatmapAnnotation: window.createTextEditorDecorationType({
before: {
contentText: GlyphChars.ZeroWidthSpace,
height: '100%',
margin: '0 26px -1px 0'
}
} as DecorationRenderOptions),
heatmapHighlight: undefined as TextEditorDecorationType | undefined,
recentChangesAnnotation: undefined as TextEditorDecorationType | undefined,
recentChangesHighlight: undefined as TextEditorDecorationType | undefined
Expand Down Expand Up @@ -389,7 +395,8 @@ export class FileAnnotationController implements Disposable {
async toggle(
editor: TextEditor | undefined,
type: FileAnnotationType,
shaOrLine?: string | number
shaOrLine?: string | number,
on?: boolean
): Promise<boolean> {
if (editor !== undefined) {
const trackedDocument = await Container.tracker.getOrAdd(editor.document);
Expand All @@ -405,6 +412,7 @@ export class FileAnnotationController implements Disposable {
if (provider === undefined) return this.show(editor!, type, shaOrLine);

const reopen = provider.annotationType !== type;
if (on === true && !reopen) return true;

if (this.isInWindowToggle()) {
await this.clearAll();
Expand Down

0 comments on commit 18ee54d

Please sign in to comment.