diff --git a/src/blameAnnotationProvider.ts b/src/blameAnnotationProvider.ts index 351c842..83e571d 100644 --- a/src/blameAnnotationProvider.ts +++ b/src/blameAnnotationProvider.ts @@ -132,7 +132,8 @@ export class BlameAnnotationProvider extends Disposable { else if (typeof shaOrLine === 'number') { const line = shaOrLine - offset; if (line >= 0) { - sha = blame.lines[line].sha; + const commitLine = blame.lines[line]; + sha = commitLine && commitLine.sha; } } else { @@ -193,6 +194,7 @@ export class BlameAnnotationProvider extends Disposable { const hoverMessage = BlameAnnotationFormatter.getAnnotationHover(this._config, l, commit); // Escape single quotes because for some reason that breaks the ::before or ::after element + // https://github.com/Microsoft/vscode/issues/19922 remove once this is released gutter = gutter.replace(/\'/g, '\\\''); lastSha = l.sha; @@ -276,6 +278,7 @@ export class BlameAnnotationProvider extends Disposable { const format = trailing ? BlameAnnotationFormat.Unconstrained : BlameAnnotationFormat.Constrained; // Escape single quotes because for some reason that breaks the ::before or ::after element + // https://github.com/Microsoft/vscode/issues/19922 remove once this is released const gutter = BlameAnnotationFormatter.getAnnotation(this._config, commit, format).replace(/\'/g, '\\\''); const hoverMessage = BlameAnnotationFormatter.getAnnotationHover(this._config, l, commit); diff --git a/src/blameStatusBarController.ts b/src/blameStatusBarController.ts index 6e012f6..6287538 100644 --- a/src/blameStatusBarController.ts +++ b/src/blameStatusBarController.ts @@ -6,7 +6,6 @@ import { TextDocumentComparer, TextEditorComparer } from './comparers'; import { IBlameConfig, IConfig, StatusBarCommand } from './configuration'; import { DocumentSchemes } from './constants'; import GitProvider, { GitCommit, GitUri, IGitBlame, IGitCommitLine } from './gitProvider'; -import { Logger } from './logger'; import * as moment from 'moment'; const activeLineDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({ @@ -160,15 +159,9 @@ export default class BlameStatusBarController extends Disposable { return; } - try { - commitLine = blame.lines[line]; - const sha = commitLine.sha; - commit = blame.commits.get(sha); - } - catch (ex) { - Logger.error(`DEBUG(${this._uri.toString()}): Line ${line} not found in blame; lines=${blame.lines.length}, uriOffset=${this._uri.offset}, repoPath=${blame.repoPath}`); - throw ex; - } + commitLine = blame.lines[line]; + const sha = commitLine && commitLine.sha; + commit = sha && blame.commits.get(sha); } else { const blameLine = await this.git.getBlameForLine(this._uri.fsPath, line, this._uri.sha, this._uri.repoPath); @@ -246,6 +239,7 @@ export default class BlameStatusBarController extends Disposable { } as IBlameConfig; // Escape single quotes because for some reason that breaks the ::before or ::after element + // https://github.com/Microsoft/vscode/issues/19922 remove once this is released const annotation = BlameAnnotationFormatter.getAnnotation(config, commit, BlameAnnotationFormat.Unconstrained).replace(/\'/g, '\\\''); // Get the full commit message -- since blame only returns the summary