diff --git a/README.md b/README.md
index 62d1729..401f9a6 100644
--- a/README.md
+++ b/README.md
@@ -639,25 +639,25 @@ GitLens is highly customizable and provides many configuration settings to allow
See also [View Settings](#view-settings 'Jump to the View settings')
-| Name | Description |
-| --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `gitlens.views.repositories.autoRefresh` | Specifies whether to automatically refresh the _Repositories_ view when the repository or the file system changes |
-| `gitlens.views.repositories.autoReveal` | Specifies whether to automatically reveal repositories in the _Repositories_ view when opening files |
-| `gitlens.views.repositories.branches.layout` | Specifies how the _Repositories_ view will display branches
`list` - displays branches as a list
`tree` - displays branches as a tree when branch names contain slashes `/` |
-| `gitlens.views.repositories.enabled` | Specifies whether to show the _Repositories_ view |
+| Name | Description |
+| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `gitlens.views.repositories.autoRefresh` | Specifies whether to automatically refresh the _Repositories_ view when the repository or the file system changes |
+| `gitlens.views.repositories.autoReveal` | Specifies whether to automatically reveal repositories in the _Repositories_ view when opening files |
+| `gitlens.views.repositories.branches.layout` | Specifies how the _Repositories_ view will display branches
`list` - displays branches as a list
`tree` - displays branches as a tree when branch names contain slashes `/` |
+| `gitlens.views.repositories.enabled` | Specifies whether to show the _Repositories_ view |
| `gitlens.views.repositories.files.compact` | Specifies whether to compact (flatten) unnecessary file nesting in the _Repositories_ view
Only applies when `gitlens.views.repositories.files.layout` is set to `tree` or `auto` |
| `gitlens.views.repositories.files.layout` | Specifies how the _Repositories_ view will display files
`auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.views.repositories.files.threshold` value and the number of files at each nesting level
`list` - displays files as a list
`tree` - displays files as a tree |
| `gitlens.views.repositories.files.threshold` | Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the _Repositories_ view
Only applies when `gitlens.views.repositories.files.layout` is set to `auto` |
-| `gitlens.views.repositories.includeWorkingTree` | Specifies whether to include working tree files inside the `Repository Status` node of the _Repositories_ view |
-| `gitlens.views.repositories.location` | Specifies where to show the _Repositories_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view |
-| `gitlens.views.repositories.showTrackingBranch` | Specifies whether to show the tracking branch when displaying local branches in the _Repositories_ view |
+| `gitlens.views.repositories.includeWorkingTree` | Specifies whether to include working tree files inside the `Repository Status` node of the _Repositories_ view |
+| `gitlens.views.repositories.location` | Specifies where to show the _Repositories_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view |
+| `gitlens.views.repositories.showTrackingBranch` | Specifies whether to show the tracking branch when displaying local branches in the _Repositories_ view |
### File History View Settings
See also [View Settings](#view-settings 'Jump to the View settings')
-| Name | Description |
-| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Name | Description |
+| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.views.fileHistory.avatars` | Specifies whether to show avatar images instead of status icons in the _File History_ view |
| `gitlens.views.fileHistory.enabled` | Specifies whether to show the _File History_ view |
| `gitlens.views.fileHistory.location` | Specifies where to show the _File History_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view |
@@ -666,8 +666,8 @@ See also [View Settings](#view-settings 'Jump to the View settings')
See also [View Settings](#view-settings 'Jump to the View settings')
-| Name | Description |
-| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Name | Description |
+| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.views.lineHistory.avatars` | Specifies whether to show avatar images instead of status icons in the _Line History_ view |
| `gitlens.views.lineHistory.enabled` | Specifies whether to show the _Line History_ view |
| `gitlens.views.lineHistory.location` | Specifies where to show the _Line History_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view |
@@ -676,12 +676,12 @@ See also [View Settings](#view-settings 'Jump to the View settings')
See also [View Settings](#view-settings 'Jump to the View settings')
-| Name | Description |
-| ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Name | Description |
+| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `gitlens.views.results.files.compact` | Specifies whether to compact (flatten) unnecessary file nesting in the _Results_ view
Only applies when `gitlens.views.results.files.layout` is set to `tree` or `auto` |
| `gitlens.views.results.files.layout` | Specifies how the _Results_ view will display files
`auto` - automatically switches between displaying files as a `tree` or `list` based on the `gitlens.views.results.files.threshold` value and the number of files at each nesting level
`list` - displays files as a list
`tree` - displays files as a tree |
| `gitlens.views.results.files.threshold` | Specifies when to switch between displaying files as a `tree` or `list` based on the number of files in a nesting level in the _Results_ view
Only applies when `gitlens.views.results.files.layout` is set to `auto` |
-| `gitlens.views.results.location` | Specifies where to show the _Results_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view |
+| `gitlens.views.results.location` | Specifies where to show the _Results_ view
`gitlens` - adds to the GitLens view
`explorer` - adds to the Explorer view
`scm` - adds to the Source Control view |
### View Settings
@@ -697,16 +697,17 @@ See also [View Settings](#view-settings 'Jump to the View settings')
### Code Lens Settings
-| Name | Description |
-| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| `gitlens.codeLens.authors.command` | Specifies the command to be executed when the `authors` code lens is clicked
`gitlens.toggleFileBlame` - toggles file blame annotations
`gitlens.diffWithPrevious` - compares the current committed file with the previous commit
`gitlens.showQuickCommitDetails` - shows a commit details quick pick
`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick
`gitlens.showQuickFileHistory` - shows a file history quick pick
`gitlens.showQuickRepoHistory` - shows a branch history quick pick |
-| `gitlens.codeLens.authors.enabled` | Specifies whether to show an `authors` code lens showing number of authors of the file or code block and the most prominent author (if there is more than one) |
-| `gitlens.codeLens.enabled` | Specifies whether to provide any Git code lens, by default
Use the _Toggle Git Code Lens_ command (`gitlens.toggleCodeLens`) to toggle the Git code lens on and off for the current window |
-| `gitlens.codeLens.recentChange.command` | Specifies the command to be executed when the `recent change` code lens is clicked
`gitlens.toggleFileBlame` - toggles file blame annotations
`gitlens.diffWithPrevious` - compares the current committed file with the previous commit
`gitlens.showQuickCommitDetails` - shows a commit details quick pick
`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick
`gitlens.showQuickFileHistory` - shows a file history quick pick
`gitlens.showQuickRepoHistory` - shows a branch history quick pick |
-| `gitlens.codeLens.recentChange.enabled` | Specifies whether to show a `recent change` code lens showing the author and date of the most recent commit for the file or code block |
-| `gitlens.codeLens.scopes` | Specifies where Git code lens will be shown in the document
`document` - adds code lens at the top of the document
`containers` - adds code lens at the start of container-like symbols (modules, classes, interfaces, etc)
`blocks` - adds code lens at the start of block-like symbols (functions, methods, etc) lines |
-| `gitlens.codeLens.scopesByLanguage` | Specifies where Git code lens will be shown in the document for the specified languages |
-| `gitlens.codeLens.symbolScopes` | Specifies a set of document symbols where Git code lens will or will not be shown in the document
Prefix with `!` to not show Git code lens for the symbol
Must be a member of [`SymbolKind`](https://code.visualstudio.com/docs/extensionAPI/vscode-api#_a-namesymbolkindaspan-classcodeitem-id660symbolkindspan) |
+| Name | Description |
+| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `gitlens.codeLens.authors.command` | Specifies the command to be executed when the `authors` code lens is clicked
`gitlens.toggleFileBlame` - toggles file blame annotations
`gitlens.diffWithPrevious` - compares the current committed file with the previous commit
`gitlens.showQuickCommitDetails` - shows a commit details quick pick
`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick
`gitlens.showQuickFileHistory` - shows a file history quick pick
`gitlens.showQuickRepoHistory` - shows a branch history quick pick |
+| `gitlens.codeLens.authors.enabled` | Specifies whether to provide an `authors` code lens, showing number of authors of the file or code block and the most prominent author (if there is more than one) |
+| `gitlens.codeLens.enabled` | Specifies whether to provide any Git code lens, by default
Use the _Toggle Git Code Lens_ command (`gitlens.toggleCodeLens`) to toggle the Git code lens on and off for the current window |
+| `gitlens.codeLens.includeSingleLineSymbols` | Specifies whether to provide any Git code lens on symbols that span only a single line |
+| `gitlens.codeLens.recentChange.command` | Specifies the command to be executed when the `recent change` code lens is clicked
`gitlens.toggleFileBlame` - toggles file blame annotations
`gitlens.diffWithPrevious` - compares the current committed file with the previous commit
`gitlens.showQuickCommitDetails` - shows a commit details quick pick
`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick
`gitlens.showQuickFileHistory` - shows a file history quick pick
`gitlens.showQuickRepoHistory` - shows a branch history quick pick |
+| `gitlens.codeLens.recentChange.enabled` | Specifies whether to provide a `recent change` code lens, showing the author and date of the most recent commit for the file or code block |
+| `gitlens.codeLens.scopes` | Specifies where Git code lens will be shown in the document
`document` - adds code lens at the top of the document
`containers` - adds code lens at the start of container-like symbols (modules, classes, interfaces, etc)
`blocks` - adds code lens at the start of block-like symbols (functions, methods, etc) lines |
+| `gitlens.codeLens.scopesByLanguage` | Specifies where Git code lens will be shown in the document for the specified languages |
+| `gitlens.codeLens.symbolScopes` | Specifies a set of document symbols where Git code lens will or will not be shown in the document
Prefix with `!` to avoid providing a Git code lens for the symbol
Must be a member of [`SymbolKind`](https://code.visualstudio.com/docs/extensionAPI/vscode-api#_a-namesymbolkindaspan-classcodeitem-id660symbolkindspan) |
#### Current Line Blame Settings
diff --git a/package.json b/package.json
index 963577b..095b9be 100644
--- a/package.json
+++ b/package.json
@@ -180,7 +180,7 @@
"gitlens.codeLens.authors.enabled": {
"type": "boolean",
"default": true,
- "description": "Specifies whether to show an `authors` code lens showing number of authors of the file or code block and the most prominent author (if there is more than one)",
+ "description": "Specifies whether to provide an `authors` code lens, showing number of authors of the file or code block and the most prominent author (if there is more than one)",
"scope": "window"
},
"gitlens.codeLens.enabled": {
@@ -189,6 +189,12 @@
"description": "Specifies whether to provide any Git code lens, by default\nUse the `Toggle Git Code Lens` command (`gitlens.toggleCodeLens`) to toggle the Git code lens on and off for the current window",
"scope": "window"
},
+ "gitlens.codeLens.includeSingleLineSymbols": {
+ "type": "boolean",
+ "default": false,
+ "description": "Specifies whether to provide any Git code lens on symbols that span only a single line",
+ "scope": "window"
+ },
"gitlens.codeLens.recentChange.command": {
"type": "string",
"default": "gitlens.showQuickCommitFileDetails",
@@ -214,7 +220,7 @@
"gitlens.codeLens.recentChange.enabled": {
"type": "boolean",
"default": true,
- "description": "Specifies whether to show a `recent change` code lens showing the author and date of the most recent commit for the file or code block",
+ "description": "Specifies whether to provide a `recent change` code lens, showing the author and date of the most recent commit for the file or code block",
"scope": "window"
},
"gitlens.codeLens.scopes": {
@@ -362,7 +368,7 @@
"type": "string"
},
"uniqueItems": true,
- "description": "Specifies a set of document symbols where Git code lens will or will not be shown in the document\nPrefix with `!` to not show Git code lens for the symbol\nMust be a member of `SymbolKind`",
+ "description": "Specifies a set of document symbols where Git code lens will or will not be shown in the document\nPrefix with `!` to avoid providing a Git code lens for the symbol\nMust be a member of `SymbolKind`",
"scope": "resource"
},
"gitlens.currentLine.dateFormat": {
diff --git a/src/codelens/codeLensProvider.ts b/src/codelens/codeLensProvider.ts
index c1affc3..36c13b1 100644
--- a/src/codelens/codeLensProvider.ts
+++ b/src/codelens/codeLensProvider.ts
@@ -6,6 +6,7 @@ import {
Command,
commands,
DocumentSelector,
+ DocumentSymbol,
Event,
EventEmitter,
ExtensionContext,
@@ -41,7 +42,7 @@ import { DocumentTracker, GitDocumentState } from '../trackers/gitDocumentTracke
export class GitRecentChangeCodeLens extends CodeLens {
constructor(
public readonly languageId: string,
- public readonly symbol: SymbolInformation,
+ public readonly symbol: DocumentSymbol | SymbolInformation,
public readonly uri: GitUri | undefined,
private readonly blame: (() => GitBlameLines | undefined) | undefined,
public readonly blameRange: Range,
@@ -61,7 +62,7 @@ export class GitRecentChangeCodeLens extends CodeLens {
export class GitAuthorsCodeLens extends CodeLens {
constructor(
public readonly languageId: string,
- public readonly symbol: SymbolInformation,
+ public readonly symbol: DocumentSymbol | SymbolInformation,
public readonly uri: GitUri | undefined,
private readonly blame: () => GitBlameLines | undefined,
public readonly blameRange: Range,
@@ -186,7 +187,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
if (symbols !== undefined) {
Logger.log('GitCodeLensProvider.provideCodeLenses:', `${symbols.length} symbol(s) found`);
- symbols.forEach(sym =>
+ for (const sym of symbols) {
this.provideCodeLens(
lenses,
document,
@@ -198,8 +199,8 @@ export class GitCodeLensProvider implements CodeLensProvider {
cfg,
dirty,
dirtyCommand
- )
- );
+ );
+ }
}
if (
@@ -270,10 +271,11 @@ export class GitCodeLensProvider implements CodeLensProvider {
return lenses;
}
- private validateSymbolAndGetBlameRange(
- symbol: SymbolInformation,
+ private getValidateSymbolRange(
+ symbol: SymbolInformation | DocumentSymbol,
languageScope: Required,
- documentRangeFn: () => Range
+ documentRangeFn: () => Range,
+ includeSingleLineSymbols: boolean
): Range | undefined {
let valid = false;
let range: Range | undefined;
@@ -304,7 +306,8 @@ export class GitCodeLensProvider implements CodeLensProvider {
if (valid) {
// Adjust the range to be for the whole file
- if (getRangeFromSymbol(symbol).start.line === 0 && getRangeFromSymbol(symbol).end.line === 0) {
+ range = getRangeFromSymbol(symbol);
+ if (range.start.line === 0 && range.end.line === 0) {
range = documentRangeFn();
}
}
@@ -319,7 +322,10 @@ export class GitCodeLensProvider implements CodeLensProvider {
languageScope.scopes.includes(CodeLensScopes.Containers) ||
languageScope.symbolScopes!.includes(symbolName)
) {
- valid = !languageScope.symbolScopes!.includes(`!${symbolName}`);
+ range = getRangeFromSymbol(symbol);
+ valid =
+ !languageScope.symbolScopes!.includes(`!${symbolName}`) &&
+ (includeSingleLineSymbols || !range.isSingleLine);
}
break;
@@ -327,17 +333,24 @@ export class GitCodeLensProvider implements CodeLensProvider {
case SymbolKind.Enum:
case SymbolKind.Function:
case SymbolKind.Method:
+ case SymbolKind.Property:
if (
languageScope.scopes.includes(CodeLensScopes.Blocks) ||
languageScope.symbolScopes!.includes(symbolName)
) {
- valid = !languageScope.symbolScopes!.includes(`!${symbolName}`);
+ range = getRangeFromSymbol(symbol);
+ valid =
+ !languageScope.symbolScopes!.includes(`!${symbolName}`) &&
+ (includeSingleLineSymbols || !range.isSingleLine);
}
break;
default:
if (languageScope.symbolScopes!.includes(symbolName)) {
- valid = !languageScope.symbolScopes!.includes(`!${symbolName}`);
+ range = getRangeFromSymbol(symbol);
+ valid =
+ !languageScope.symbolScopes!.includes(`!${symbolName}`) &&
+ (includeSingleLineSymbols || !range.isSingleLine);
}
break;
}
@@ -348,7 +361,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
private provideCodeLens(
lenses: CodeLens[],
document: TextDocument,
- symbol: SymbolInformation,
+ symbol: SymbolInformation | DocumentSymbol,
languageScope: Required,
documentRangeFn: () => Range,
blame: GitBlame | undefined,
@@ -357,64 +370,29 @@ export class GitCodeLensProvider implements CodeLensProvider {
dirty: boolean,
dirtyCommand: Command | undefined
): void {
- const blameRange = this.validateSymbolAndGetBlameRange(symbol, languageScope, documentRangeFn);
- if (blameRange === undefined) return;
-
- const line = document.lineAt(getRangeFromSymbol(symbol).start);
- // Make sure there is only 1 lens per line
- if (lenses.length && lenses[lenses.length - 1].range.start.line === line.lineNumber) return;
-
- // Anchor the code lens to the start of the line -- so that the range won't change with edits (otherwise the code lens will be removed and re-added)
- let startChar = 0;
-
- let blameForRangeFn: (() => GitBlameLines | undefined) | undefined;
- if (dirty || cfg.recentChange.enabled) {
- if (!dirty) {
- blameForRangeFn = Functions.once(() => this._git.getBlameForRangeSync(blame!, gitUri!, blameRange));
- }
- lenses.push(
- new GitRecentChangeCodeLens(
- document.languageId,
- symbol,
- gitUri,
- blameForRangeFn,
- blameRange,
- false,
- line.range.with(new Position(line.range.start.line, startChar)),
- cfg.recentChange.command,
- dirtyCommand
- )
+ try {
+ const blameRange = this.getValidateSymbolRange(
+ symbol,
+ languageScope,
+ documentRangeFn,
+ cfg.includeSingleLineSymbols
);
- startChar++;
- }
+ if (blameRange === undefined) return;
- if (cfg.authors.enabled) {
- let multiline = !blameRange.isSingleLine;
- // HACK for Omnisharp, since it doesn't return full ranges
- if (!multiline && document.languageId === 'csharp') {
- switch (symbol.kind) {
- case SymbolKind.File:
- break;
- case SymbolKind.Package:
- case SymbolKind.Module:
- case SymbolKind.Namespace:
- case SymbolKind.Class:
- case SymbolKind.Interface:
- case SymbolKind.Constructor:
- case SymbolKind.Method:
- case SymbolKind.Function:
- case SymbolKind.Enum:
- multiline = true;
- break;
- }
- }
+ const line = document.lineAt(getRangeFromSymbol(symbol).start);
+ // Make sure there is only 1 lens per line
+ if (lenses.length && lenses[lenses.length - 1].range.start.line === line.lineNumber) return;
+
+ // Anchor the code lens to the start of the line -- so that the range won't change with edits (otherwise the code lens will be removed and re-added)
+ let startChar = 0;
- if (multiline && !dirty) {
- if (blameForRangeFn === undefined) {
+ let blameForRangeFn: (() => GitBlameLines | undefined) | undefined;
+ if (dirty || cfg.recentChange.enabled) {
+ if (!dirty) {
blameForRangeFn = Functions.once(() => this._git.getBlameForRangeSync(blame!, gitUri!, blameRange));
}
lenses.push(
- new GitAuthorsCodeLens(
+ new GitRecentChangeCodeLens(
document.languageId,
symbol,
gitUri,
@@ -422,9 +400,71 @@ export class GitCodeLensProvider implements CodeLensProvider {
blameRange,
false,
line.range.with(new Position(line.range.start.line, startChar)),
- cfg.authors.command
+ cfg.recentChange.command,
+ dirtyCommand
)
);
+ startChar++;
+ }
+
+ if (cfg.authors.enabled) {
+ let multiline = !blameRange.isSingleLine;
+ // HACK for Omnisharp, since it doesn't return full ranges
+ if (!multiline && document.languageId === 'csharp') {
+ switch (symbol.kind) {
+ case SymbolKind.File:
+ break;
+ case SymbolKind.Package:
+ case SymbolKind.Module:
+ case SymbolKind.Namespace:
+ case SymbolKind.Class:
+ case SymbolKind.Interface:
+ case SymbolKind.Constructor:
+ case SymbolKind.Method:
+ case SymbolKind.Function:
+ case SymbolKind.Enum:
+ multiline = true;
+ break;
+ }
+ }
+
+ if (multiline && !dirty) {
+ if (blameForRangeFn === undefined) {
+ blameForRangeFn = Functions.once(() =>
+ this._git.getBlameForRangeSync(blame!, gitUri!, blameRange)
+ );
+ }
+ lenses.push(
+ new GitAuthorsCodeLens(
+ document.languageId,
+ symbol,
+ gitUri,
+ blameForRangeFn,
+ blameRange,
+ false,
+ line.range.with(new Position(line.range.start.line, startChar)),
+ cfg.authors.command
+ )
+ );
+ }
+ }
+ }
+ finally {
+ if (isDocumentSymbol(symbol)) {
+ for (const child of symbol.children) {
+ this.provideCodeLens(
+ lenses,
+ document,
+ child,
+ languageScope,
+ documentRangeFn,
+ blame,
+ gitUri,
+ cfg,
+ dirty,
+ dirtyCommand
+ );
+ }
}
}
}
@@ -444,8 +484,13 @@ export class GitCodeLensProvider implements CodeLensProvider {
if (Container.config.debug) {
title += ` [${lens.languageId}: ${SymbolKind[lens.symbol.kind]}(${lens.range.start.character}-${
lens.range.end.character
- }${lens.symbol.containerName ? `|${lens.symbol.containerName}` : ''}), Lines (${lens.blameRange.start.line +
- 1}-${lens.blameRange.end.line + 1}), Commit (${recentCommit.shortSha})]`;
+ }${
+ (lens.symbol as SymbolInformation).containerName
+ ? `|${(lens.symbol as SymbolInformation).containerName}`
+ : ''
+ }), Lines (${lens.blameRange.start.line + 1}-${lens.blameRange.end.line + 1}), Commit (${
+ recentCommit.shortSha
+ })]`;
}
switch (lens.desiredCommand) {
@@ -492,8 +537,11 @@ export class GitCodeLensProvider implements CodeLensProvider {
if (Container.config.debug) {
title += ` [${lens.languageId}: ${SymbolKind[lens.symbol.kind]}(${lens.range.start.character}-${
lens.range.end.character
- }${lens.symbol.containerName ? `|${lens.symbol.containerName}` : ''}), Lines (${lens.blameRange.start.line +
- 1}-${lens.blameRange.end.line + 1}), Authors (${Iterables.join(
+ }${
+ (lens.symbol as SymbolInformation).containerName
+ ? `|${(lens.symbol as SymbolInformation).containerName}`
+ : ''
+ }), Lines (${lens.blameRange.start.line + 1}-${lens.blameRange.end.line + 1}), Authors (${Iterables.join(
Iterables.map(blame.authors.values(), a => a.name),
', '
)})]`;
@@ -636,7 +684,10 @@ export class GitCodeLensProvider implements CodeLensProvider {
}
}
-function getRangeFromSymbol(symbol: SymbolInformation) {
- // Normalize the range to deal with the new api
- return (symbol.location && symbol.location.range) || (symbol as any).range;
+function getRangeFromSymbol(symbol: DocumentSymbol | SymbolInformation) {
+ return isDocumentSymbol(symbol) ? symbol.range : symbol.location.range;
+}
+
+function isDocumentSymbol(symbol: DocumentSymbol | SymbolInformation): symbol is DocumentSymbol {
+ return (symbol as DocumentSymbol).children !== undefined;
}
diff --git a/src/ui/config.ts b/src/ui/config.ts
index 557e411..395250a 100644
--- a/src/ui/config.ts
+++ b/src/ui/config.ts
@@ -131,6 +131,7 @@ export interface CodeLensConfig {
command: CodeLensCommand;
};
enabled: boolean;
+ includeSingleLineSymbols: boolean;
recentChange: {
enabled: boolean;
command: CodeLensCommand;