Procházet zdrojové kódy

Adds changes hover to file annotations

main
Eric Amodio před 7 roky
rodič
revize
c02ff46dc3
8 změnil soubory, kde provedl 73 přidání a 36 odebrání
  1. +7
    -0
      CHANGELOG.md
  2. +8
    -3
      README.md
  3. +14
    -4
      package.json
  4. +37
    -15
      src/annotations/blameAnnotationProvider.ts
  5. +1
    -4
      src/annotations/gutterBlameAnnotationProvider.ts
  6. +1
    -1
      src/annotations/hoverBlameAnnotationProvider.ts
  7. +4
    -2
      src/configuration.ts
  8. +1
    -7
      src/currentLineController.ts

+ 7
- 0
CHANGELOG.md Zobrazit soubor

@ -5,12 +5,19 @@ 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 `changes` (diff) hover annotation support to both the `gutter` and `hover` file blame annotations
- Adds `gitlens.annotations.file.gutter.hover.changes` setting to specify whether or not to provide a changes (diff) hover annotation over the gutter blame annotations
- Adds `gitlens.annotations.file.hover.details` setting to specify whether or not to provide a commit details hover annotation over each line
- Adds `gitlens.annotations.file.hover.changes` setting to specify whether or not to provide a changes (diff) hover annotation over each line
### Changed
- Changes `gitlens.codeLens.customLocationSymbols` setting to both include and exclude (using a `!` prefix) symbols and therefore is always applied
### Removed
- Removes `Custom` from the `gitlens.codeLens.locations` setting as it wasn't really required
- Removes properties (symbol `Property`) from being included in the `Blocks` option of the `gitlens.codeLens.locations` setting -- can be easily re-added by setting `"gitlens.codeLens.customLocationSymbols": [ "Property" ]` if desired
- Removes `gitlens.annotations.file.hover.wholeLine` setting as it didn't really make sense
### Fixed
- Fixes issue where changing `gitlens.blame.file.annotationType` wouldn't correctly update the blame annotations if they were currently active

+ 8
- 3
README.md Zobrazit soubor

@ -43,10 +43,13 @@ GitLens provides an unobtrusive blame annotation at the end of the current line,
- Contains the commit message and date, by [default](#file-blame-annotation-settings)
- Adds a `details` hover annotation to the line's annotation, which provides more commit details ([optional](#file-blame-annotation-settings), on by default)
![File Blame Annotations (hover)](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-file-blame-annotations.png)
![File Details Blame Annotations (hover)](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-file-blame-annotations.png)
- Provides a **quick-access command bar** with `Open Changes`, `Blame Previous Revision`, `Open in Remote`, and `Show More Actions` command buttons
- Clicking the commit id will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
- Adds a `changes` (diff) hover annotation to the line's annotation, which provides **instant access** to the line's previous version ([optional](#file-blame-annotation-settings), on by default)
- 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 a `heatmap` (age) indicator to the gutter annotations (on right edge by [default](#file-blame-annotation-settings)), which provides an easy, at-a-glance way to tell the age of a line ([optional](#file-blame-annotation-settings), on by default)
- Indicator ranges from bright yellow (newer) to dark brown (older)
- Press `Escape` to quickly toggle the annotations off
@ -76,7 +79,7 @@ GitLens provides an unobtrusive blame annotation at the end of the current line,
- Adds on-demand, [customizable](#file-recent-changes-annotation-settings) and [themeable](#theme-settings), **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-blame-annotation-settings), on by default)
- 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`)
- Adds a `changes` (diff) hover annotation to each line, which provides **instant** access to the line's previous version ([optional](#file-recent-changes-annotation-settings), on by default)
- Clicking on `Changes` will run the `Compare File Revisions` command (`gitlens.diffWith`)
@ -316,9 +319,11 @@ GitLens is highly customizable and provides many configuration settings to allow
|`gitlens.annotations.file.gutter.heatmap.enabled`|Specifies whether or not to provide a heatmap indicator in the gutter blame annotations
|`gitlens.annotations.file.gutter.heatmap.location`|Specifies where the heatmap indicators will be shown in the gutter blame annotations<br />`left` - adds a heatmap indicator on the left edge of the gutter blame annotations<br />`right` - adds a heatmap indicator on the right edge of the gutter blame annotations
|`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.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
|`gitlens.annotations.file.hover.wholeLine`|Specifies whether or not to trigger hover annotations over the whole line
#### Line Blame Annotation Settings

+ 14
- 4
package.json Zobrazit soubor

@ -107,20 +107,30 @@
"default": true,
"description": "Specifies whether or not to provide a commit details hover annotation over the gutter blame annotations"
},
"gitlens.annotations.file.gutter.hover.changes": {
"type": "boolean",
"default": true,
"description": "Specifies whether or not to provide a changes (diff) hover annotation over the gutter blame annotations"
},
"gitlens.annotations.file.gutter.hover.wholeLine": {
"type": "boolean",
"default": true,
"description": "Specifies whether or not to trigger hover annotations over the whole line"
},
"gitlens.annotations.file.hover.heatmap.enabled": {
"gitlens.annotations.file.hover.details": {
"type": "boolean",
"default": true,
"description": "Specifies whether or not to provide heatmap indicators on the left edge of each line"
"description": "Specifies whether or not to provide a commit details hover annotation over each line"
},
"gitlens.annotations.file.hover.wholeLine": {
"gitlens.annotations.file.hover.changes": {
"type": "boolean",
"default": true,
"description": "Specifies whether or not to trigger hover annotations over the whole line"
"description": "Specifies whether or not to provide a changes (diff) hover annotation over each line"
},
"gitlens.annotations.file.hover.heatmap.enabled": {
"type": "boolean",
"default": true,
"description": "Specifies whether or not to provide heatmap indicators on the left edge of each line"
},
"gitlens.annotations.file.recentChanges.hover.details": {
"type": "boolean",

+ 37
- 15
src/annotations/blameAnnotationProvider.ts Zobrazit soubor

@ -5,7 +5,7 @@ import { AnnotationProviderBase } from './annotationProvider';
import { Annotations, endOfLineIndex } from './annotations';
import { GitBlame, GitCommit, GitService, GitUri } from '../gitService';
export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase implements HoverProvider {
export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase {
protected _blame: Promise<GitBlame | undefined>;
protected _hoverProviderDisposable: Disposable;
@ -74,23 +74,22 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
return blame;
}
registerHoverProvider() {
this._hoverProviderDisposable = languages.registerHoverProvider({ pattern: this.document.uri.fsPath }, this);
}
async provideHover(document: TextDocument, position: Position, token: CancellationToken): Promise<Hover | undefined> {
// Avoid double annotations if we are showing the whole-file hover blame annotations
if (this._config.blame.line.enabled && this.editor.selection.start.line === position.line) return undefined;
registerHoverProviders(providers: { details: boolean, changes: boolean }) {
if (!providers.details && !providers.changes) return;
const cfg = this._config.annotations.file.gutter;
if (!cfg.hover.wholeLine && position.character !== 0) return undefined;
const blame = await this.getBlame();
if (blame === undefined) return undefined;
const subscriptions: Disposable[] = [];
if (providers.changes) {
subscriptions.push(languages.registerHoverProvider({ pattern: this.document.uri.fsPath }, { provideHover: this.provideChangesHover.bind(this) } as HoverProvider));
}
if (providers.details) {
subscriptions.push(languages.registerHoverProvider({ pattern: this.document.uri.fsPath }, { provideHover: this.provideDetailsHover.bind(this) } as HoverProvider));
}
const line = blame.lines[position.line];
this._hoverProviderDisposable = Disposable.from(...subscriptions);
}
const commit = blame.commits.get(line.sha);
async provideDetailsHover(document: TextDocument, position: Position, token: CancellationToken): Promise<Hover | undefined> {
const commit = await this.getCommitForHover(position);
if (commit === undefined) return undefined;
// Get the full commit message -- since blame only returns the summary
@ -107,4 +106,27 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
const message = Annotations.getHoverMessage(logCommit || commit, this._config.defaultDateFormat, this.git.hasRemotes(commit.repoPath), this._config.blame.file.annotationType);
return new Hover(message, document.validateRange(new Range(position.line, 0, position.line, endOfLineIndex)));
}
async provideChangesHover(document: TextDocument, position: Position, token: CancellationToken): Promise<Hover | undefined> {
const commit = await this.getCommitForHover(position);
if (commit === undefined) return undefined;
const hover = await Annotations.changesHover(commit, position.line, await GitUri.fromUri(document.uri, this.git), this.git);
return new Hover(hover.hoverMessage!, document.validateRange(new Range(position.line, 0, position.line, endOfLineIndex)));
}
private async getCommitForHover(position: Position): Promise<GitCommit | undefined> {
// Avoid double annotations if we are showing the whole-file hover blame annotations
if (this._config.blame.line.enabled && this.editor.selection.start.line === position.line) return undefined;
const cfg = this._config.annotations.file.gutter;
if (!cfg.hover.wholeLine && position.character !== 0) return undefined;
const blame = await this.getBlame();
if (blame === undefined) return undefined;
const line = blame.lines[position.line];
return blame.commits.get(line.sha);
}
}

+ 1
- 4
src/annotations/gutterBlameAnnotationProvider.ts Zobrazit soubor

@ -119,10 +119,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
const duration = process.hrtime(start);
Logger.log(`${(duration[0] * 1000) + Math.floor(duration[1] / 1000000)} ms to compute gutter blame annotations`);
if (cfg.hover.details) {
this.registerHoverProvider();
}
this.registerHoverProviders(cfg.hover);
this.selection(shaOrLine, blame);
return true;
}

+ 1
- 1
src/annotations/hoverBlameAnnotationProvider.ts Zobrazit soubor

@ -63,7 +63,7 @@ export class HoverBlameAnnotationProvider extends BlameAnnotationProviderBase {
Logger.log(`${(duration[0] * 1000) + Math.floor(duration[1] / 1000000)} ms to compute hover blame annotations`);
}
this.registerHoverProvider();
this.registerHoverProviders(cfg);
this.selection(shaOrLine, blame);
return true;
}

+ 4
- 2
src/configuration.ts Zobrazit soubor

@ -238,15 +238,17 @@ export interface IConfig {
};
hover: {
details: boolean;
changes: boolean;
wholeLine: boolean;
};
};
hover: {
details: boolean;
changes: boolean;
heatmap: {
enabled: boolean;
};
wholeLine: boolean;
};
recentChanges: {
@ -267,8 +269,8 @@ export interface IConfig {
format: string;
dateFormat: string | null;
hover: {
changes: boolean;
details: boolean;
changes: boolean;
wholeLine: boolean;
};
};

+ 1
- 7
src/currentLineController.ts Zobrazit soubor

@ -338,13 +338,7 @@ export class CurrentLineController extends Disposable {
break;
}
case FileAnnotationType.Hover: {
const cfgHover = this._config.annotations.file.hover;
if (cfgHover.wholeLine) {
showStartIndex = 0;
}
else if (showStartIndex !== 0) {
showAtStart = true;
}
showStartIndex = 0;
break;
}

Načítá se…
Zrušit
Uložit