mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-12 19:18:32 -05:00
Fixes #5 - Finding first non-white-space fails sometimes
This commit is contained in:
@@ -3,6 +3,7 @@ import {CancellationToken, CodeLens, CodeLensProvider, commands, DocumentSelecto
|
|||||||
import {BuiltInCommands, Commands, DocumentSchemes, WorkspaceState} from './constants';
|
import {BuiltInCommands, Commands, DocumentSchemes, WorkspaceState} from './constants';
|
||||||
import GitProvider, {IGitBlame, IGitBlameLines, IGitCommit} from './gitProvider';
|
import GitProvider, {IGitBlame, IGitBlameLines, IGitCommit} from './gitProvider';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
export class GitRecentChangeCodeLens extends CodeLens {
|
export class GitRecentChangeCodeLens extends CodeLens {
|
||||||
constructor(private git: GitProvider, public fileName: string, public symbolKind: SymbolKind, public blameRange: Range, range: Range) {
|
constructor(private git: GitProvider, public fileName: string, public symbolKind: SymbolKind, public blameRange: Range, range: Range) {
|
||||||
@@ -95,7 +96,11 @@ export default class GitCodeLensProvider implements CodeLensProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let startChar = line.text.search(`\\b${symbol.name}\\b`); //line.firstNonWhitespaceCharacterIndex;
|
let startChar = -1;
|
||||||
|
try {
|
||||||
|
startChar = line.text.search(`\\b${_.escapeRegExp(symbol.name)}\\b`);
|
||||||
|
}
|
||||||
|
catch (ex) { }
|
||||||
if (startChar === -1) {
|
if (startChar === -1) {
|
||||||
startChar = line.firstNonWhitespaceCharacterIndex;
|
startChar = line.firstNonWhitespaceCharacterIndex;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user