Browse Source

Fixes errors when selecting the last blank line

main
Eric Amodio 7 years ago
parent
commit
f53ecf8a7e
2 changed files with 8 additions and 11 deletions
  1. +4
    -1
      src/blameAnnotationProvider.ts
  2. +4
    -10
      src/blameStatusBarController.ts

+ 4
- 1
src/blameAnnotationProvider.ts View File

@ -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);

+ 4
- 10
src/blameStatusBarController.ts View File

@ -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

Loading…
Cancel
Save