diff --git a/CHANGELOG.md b/CHANGELOG.md index 50f838a..fda6174 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/README.md b/README.md index fa1f12c..46c443d 100644 --- a/README.md +++ b/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
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
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
Available tokens
`${id}` - commit id
`${author}` - commit author
`${message}` - commit message
`${ago}` - relative commit date (e.g. 1 day ago)
`${date}` - formatted commit date (format specified by `gitlens.currentLine.dateFormat`)
`${agoOrDate}` - commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` - commit author, relative commit date
`${authorAgoOrDate}` - commit author, commit date specified by `gitlens.defaultDateStyle`
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 diff --git a/package.json b/package.json index 4b9a8f4..03a0e90 100644 --- a/package.json +++ b/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, diff --git a/src/annotations/annotations.ts b/src/annotations/annotations.ts index f2227b9..a2e3d3a 100644 --- a/src/annotations/annotations.ts +++ b/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; diff --git a/src/annotations/lineAnnotationController.ts b/src/annotations/lineAnnotationController.ts index fa5daaf..4d682ac 100644 --- a/src/annotations/lineAnnotationController.ts +++ b/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); } diff --git a/src/ui/config.ts b/src/ui/config.ts index d57f512..f4551d2 100644 --- a/src/ui/config.ts +++ b/src/ui/config.ts @@ -265,6 +265,7 @@ export interface IConfig { }; currentLine: { + scrollable: boolean; dateFormat: string | null; enabled: boolean; format: string;