Fixes #107 - Double-byte characters break blame layout

This commit is contained in:
Eric Amodio
2017-07-27 00:56:33 -04:00
parent 68a42fd0c7
commit 9d9c3181f7
4 changed files with 56 additions and 17 deletions

View File

@@ -51,11 +51,12 @@ export abstract class Formatter<TItem = any, TOptions extends IFormatOptions = I
let max = options.truncateTo;
const width = Strings.getWidth(s);
if (max === undefined) {
if (this.collapsableWhitespace === 0) return s;
// If we have left over whitespace make sure it gets re-added
const diff = this.collapsableWhitespace - s.length;
const diff = this.collapsableWhitespace - width;
this.collapsableWhitespace = 0;
if (diff <= 0) return s;
@@ -66,7 +67,7 @@ export abstract class Formatter<TItem = any, TOptions extends IFormatOptions = I
max += this.collapsableWhitespace;
this.collapsableWhitespace = 0;
const diff = max - s.length;
const diff = max - width;
if (diff > 0) {
if (options.collapseWhitespace) {
this.collapsableWhitespace = diff;