Browse Source

Adds support for DocumentSymbols (hierachy)

Adds codeLens.includeSingleLineSymbols setting
main
Eric Amodio 6 years ago
parent
commit
84992d81e6
4 changed files with 161 additions and 102 deletions
  1. +27
    -26
      README.md
  2. +9
    -3
      package.json
  3. +124
    -73
      src/codelens/codeLensProvider.ts
  4. +1
    -0
      src/ui/config.ts

+ 27
- 26
README.md View File

@ -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<br />`list` - displays branches as a list<br />`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<br />`list` - displays branches as a list<br />`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<br />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<br />`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<br />`list` - displays files as a list<br />`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<br />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<br />`gitlens` - adds to the GitLens view<br />`explorer` - adds to the Explorer view<br />`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<br />`gitlens` - adds to the GitLens view<br />`explorer` - adds to the Explorer view<br />`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<br />`gitlens` - adds to the GitLens view<br />`explorer` - adds to the Explorer view<br />`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<br />`gitlens` - adds to the GitLens view<br />`explorer` - adds to the Explorer view<br />`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<br />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<br />`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<br />`list` - displays files as a list<br />`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<br />Only applies when `gitlens.views.results.files.layout` is set to `auto` |
| `gitlens.views.results.location` | Specifies where to show the _Results_ view<br />`gitlens` - adds to the GitLens view<br />`explorer` - adds to the Explorer view<br />`scm` - adds to the Source Control view |
| `gitlens.views.results.location` | Specifies where to show the _Results_ view<br />`gitlens` - adds to the GitLens view<br />`explorer` - adds to the Explorer view<br />`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<br />`gitlens.toggleFileBlame` - toggles file blame annotations<br />`gitlens.diffWithPrevious` - compares the current committed file with the previous commit<br />`gitlens.showQuickCommitDetails` - shows a commit details quick pick<br />`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick<br />`gitlens.showQuickFileHistory` - shows a file history quick pick<br />`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<br />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<br />`gitlens.toggleFileBlame` - toggles file blame annotations<br />`gitlens.diffWithPrevious` - compares the current committed file with the previous commit<br />`gitlens.showQuickCommitDetails` - shows a commit details quick pick<br />`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick<br />`gitlens.showQuickFileHistory` - shows a file history quick pick<br />`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<br />`document` - adds code lens at the top of the document<br />`containers` - adds code lens at the start of container-like symbols (modules, classes, interfaces, etc)<br />`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<br />Prefix with `!` to not show Git code lens for the symbol<br />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<br />`gitlens.toggleFileBlame` - toggles file blame annotations<br />`gitlens.diffWithPrevious` - compares the current committed file with the previous commit<br />`gitlens.showQuickCommitDetails` - shows a commit details quick pick<br />`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick<br />`gitlens.showQuickFileHistory` - shows a file history quick pick<br />`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<br />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<br />`gitlens.toggleFileBlame` - toggles file blame annotations<br />`gitlens.diffWithPrevious` - compares the current committed file with the previous commit<br />`gitlens.showQuickCommitDetails` - shows a commit details quick pick<br />`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick<br />`gitlens.showQuickFileHistory` - shows a file history quick pick<br />`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<br />`document` - adds code lens at the top of the document<br />`containers` - adds code lens at the start of container-like symbols (modules, classes, interfaces, etc)<br />`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<br />Prefix with `!` to avoid providing a Git code lens for the symbol<br />Must be a member of [`SymbolKind`](https://code.visualstudio.com/docs/extensionAPI/vscode-api#_a-namesymbolkindaspan-classcodeitem-id660symbolkindspan) |
#### Current Line Blame Settings

+ 9
- 3
package.json View File

@ -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": {

+ 124
- 73
src/codelens/codeLensProvider.ts View File

@ -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<CodeLensLanguageScope>,
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<CodeLensLanguageScope>,
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;
}

+ 1
- 0
src/ui/config.ts View File

@ -131,6 +131,7 @@ export interface CodeLensConfig {
command: CodeLensCommand;
};
enabled: boolean;
includeSingleLineSymbols: boolean;
recentChange: {
enabled: boolean;
command: CodeLensCommand;

Loading…
Cancel
Save