Skip to content

Commit 84becec

Browse files
author
Eric Amodio
committed
Moves lens start char to center on symbol
Also helps move lens after other lenses
1 parent c395a58 commit 84becec

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/codeLensProvider.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,16 @@ export default class GitCodeLensProvider implements CodeLensProvider {
7676
}
7777

7878
const line = document.lineAt(symbol.location.range.start);
79-
lenses.push(new GitBlameCodeLens(this.blameProvider, document.fileName, symbol.location.range, line.range.with(new Position(line.range.start.line, line.firstNonWhitespaceCharacterIndex))));
80-
lenses.push(new GitHistoryCodeLens(this.repoPath, document.fileName, line.range.with(new Position(line.range.start.line, line.firstNonWhitespaceCharacterIndex + 1))));
79+
80+
let startChar = line.text.indexOf(symbol.name); //line.firstNonWhitespaceCharacterIndex;
81+
if (startChar === -1) {
82+
startChar = line.firstNonWhitespaceCharacterIndex;
83+
} else {
84+
startChar += (symbol.name.length / 2) - 1;
85+
}
86+
87+
lenses.push(new GitBlameCodeLens(this.blameProvider, document.fileName, symbol.location.range, line.range.with(new Position(line.range.start.line, startChar))));
88+
lenses.push(new GitHistoryCodeLens(this.repoPath, document.fileName, line.range.with(new Position(line.range.start.line, startChar + 1))));
8189
}
8290

8391
resolveCodeLens(lens: CodeLens, token: CancellationToken): Thenable<CodeLens> {

0 commit comments

Comments
 (0)