Skip to content

Commit 0fb7188

Browse files
committed
Anchors the code lens to the end of the line
1 parent 516bcf7 commit 0fb7188

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/gitCodeLensProvider.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
import { Functions, Iterables, Strings } from './system';
2+
import { Functions, Iterables } from './system';
33
import { CancellationToken, CodeLens, CodeLensProvider, Command, commands, DocumentSelector, Event, EventEmitter, ExtensionContext, Position, Range, SymbolInformation, SymbolKind, TextDocument, Uri, workspace } from 'vscode';
44
import { Commands, DiffWithPreviousCommandArgs, ShowBlameHistoryCommandArgs, ShowFileHistoryCommandArgs, ShowQuickCommitDetailsCommandArgs, ShowQuickCommitFileDetailsCommandArgs, ShowQuickFileHistoryCommandArgs } from './commands';
55
import { BuiltInCommands, DocumentSchemes, ExtensionKey } from './constants';
@@ -184,17 +184,8 @@ export class GitCodeLensProvider implements CodeLensProvider {
184184
// Make sure there is only 1 lens per line
185185
if (lenses.length && lenses[lenses.length - 1].range.start.line === line.lineNumber) return;
186186

187-
let startChar = -1;
188-
try {
189-
startChar = line.text.search(`\\b${Strings.escapeRegExp(symbol.name)}\\b`);
190-
}
191-
catch (ex) { }
192-
if (startChar === -1) {
193-
startChar = line.firstNonWhitespaceCharacterIndex;
194-
}
195-
else {
196-
startChar += Math.floor(symbol.name.length / 2);
197-
}
187+
// Anchor the code lens to the end of the line -- so they are somewhat consistenly placed
188+
let startChar = line.range.end.character - 1;
198189

199190
let blameForRangeFn: (() => IGitBlameLines | undefined) | undefined = undefined;
200191
if (this._documentIsDirty || this._config.codeLens.recentChange.enabled) {

0 commit comments

Comments
 (0)