Просмотр исходного кода

Adds scrollable setting to the current line annotation

Closes #149, #290, #265
main
Eric Amodio 6 лет назад
Родитель
Сommit
3dfdbd7c85
6 измененных файлов: 16 добавлений и 3 удалений
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -0
      README.md
  3. +6
    -0
      package.json
  4. +4
    -2
      src/annotations/annotations.ts
  5. +3
    -1
      src/annotations/lineAnnotationController.ts
  6. +1
    -0
      src/ui/config.ts

+ 1
- 0
CHANGELOG.md Просмотреть файл

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Added
- Adds an indicator to the *GitLens* explorer branch history to mark the synchronization point between the local and remote branch (if available)
- Adds `${agoOrDate}` and `${authorAgoOrDate}` tokens to `gitlens.blame.format`, `gitlens.currentLine.format`, `gitlens.explorers.commitFormat`, `gitlens.explorers.stashFormat`, and `gitlens.statusBar.format` settings which will honor the `gitlens.defaultDateStyle` setting — closes [#312](https://github.com/eamodio/vscode-gitlens/issues/312)
- Adds `gitlens.currentLine.scrollable` setting to specify whether the current line blame annotation can be scrolled into view when it is outside the viewport — closes [#149](https://github.com/eamodio/vscode-gitlens/issues/149), [#290](https://github.com/eamodio/vscode-gitlens/issues/290), [#265](https://github.com/eamodio/vscode-gitlens/issues/265)
### Removed
- Removes the unnecessary *Show File Blame Annotations* (`gitlens.showFileBlame`) command — *Toggle File Blame Annotations* (`gitlens.toggleFileBlame`) provides similar functionality

+ 1
- 0
README.md Просмотреть файл

@ -585,6 +585,7 @@ See also [Explorer Settings](#explorer-settings "Jump to the Explorer settings")
|`gitlens.currentLine.dateFormat`|Specifies how to format absolute dates (using the `${date}` token) for the current line blame annotations<br />See https://momentjs.com/docs/#/displaying/format/ for valid formats
|`gitlens.currentLine.enabled`|Specifies whether to provide a blame annotation for the current line, by default<br />Use the *Toggle Line Blame Annotations* command (`gitlens.toggleLineBlame`) to toggle the annotations on and off for the current window
|`gitlens.currentLine.format`|Specifies the format of the current line blame annotation<br />Available tokens<br />`${id}` - commit id<br />`${author}` - commit author<br />`${message}` - commit message<br />`${ago}` - relative commit date (e.g. 1 day ago)<br />`${date}` - formatted commit date (format specified by `gitlens.currentLine.dateFormat`)<br />`${agoOrDate}` - commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` - commit author, relative commit date<br />`${authorAgoOrDate}` - commit author, commit date specified by `gitlens.defaultDateStyle`<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
|`gitlens.currentLine.scrollable`|Specifies whether the current line blame annotation can be scrolled into view when it is outside the viewport
### Gutter Blame Settings

+ 6
- 0
package.json Просмотреть файл

@ -329,6 +329,12 @@
"description": "Specifies the format of the current line blame annotation\nAvailable tokens\n ${id} - commit id\n ${author} - commit author\n ${message} - commit message\n ${ago} - relative commit date (e.g. 1 day ago)\n ${date} - formatted commit date (format specified by `gitlens.currentLine.dateFormat`)\n ${agoOrDate} - commit date specified by `gitlens.defaultDateStyle`\n ${authorAgo} - commit author, relative commit date\n ${authorAgoOrDate} - commit author, commit date specified by `gitlens.defaultDateStyle`\nSee https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting",
"scope": "window"
},
"gitlens.currentLine.scrollable": {
"type": "boolean",
"default": true,
"description": "Specifies whether the current line blame annotation can be scrolled into view when it is outside the viewport",
"scope": "window"
},
"gitlens.debug": {
"type": "boolean",
"default": false,

+ 4
- 2
src/annotations/annotations.ts Просмотреть файл

@ -258,7 +258,7 @@ export class Annotations {
// } as IRenderOptions;
// }
static trailing(commit: GitCommit, format: string, dateFormat: string | null): DecorationOptions {
static trailing(commit: GitCommit, format: string, dateFormat: string | null, scrollable: boolean = true): DecorationOptions {
const message = CommitFormatter.fromTemplate(format, commit, {
truncateMessageAtNewLine: true,
dateFormat: dateFormat
@ -271,7 +271,9 @@ export class Annotations {
color: new ThemeColor('gitlens.trailingLineForegroundColor'),
contentText: Strings.pad(message.replace(/ /g, GlyphChars.Space), 1, 1),
fontWeight: 'normal',
fontStyle: 'normal'
fontStyle: 'normal',
// Pull the decoration out of the document flow if we want to be scrollable
textDecoration: `none;${scrollable ? '' : ' position: absolute;'}`
}
} as DecorationInstanceRenderOptions
} as DecorationOptions;

+ 3
- 1
src/annotations/lineAnnotationController.ts Просмотреть файл

@ -187,12 +187,14 @@ export class LineAnnotationController extends Disposable {
// Make sure the editor hasn't died since the await above and that we are still on the same line(s)
if (editor.document === undefined || !Container.lineTracker.includesAll(lines)) return;
const scrollable = Container.config.currentLine.scrollable;
const decorations = [];
for (const l of lines) {
const state = Container.lineTracker.getState(l);
if (state === undefined || state.commit === undefined) continue;
const decoration = Annotations.trailing(state.commit, cfg.format, cfg.dateFormat === null ? Container.config.defaultDateFormat : cfg.dateFormat);
const decoration = Annotations.trailing(state.commit, cfg.format, cfg.dateFormat === null ? Container.config.defaultDateFormat : cfg.dateFormat, scrollable);
decoration.range = editor.document.validateRange(new Range(l, RangeEndOfLineIndex, l, RangeEndOfLineIndex));
decorations.push(decoration);
}

+ 1
- 0
src/ui/config.ts Просмотреть файл

@ -265,6 +265,7 @@ export interface IConfig {
};
currentLine: {
scrollable: boolean;
dateFormat: string | null;
enabled: boolean;
format: string;

Загрузка…
Отмена
Сохранить