diff --git a/lib/hterm.js b/lib/hterm.js index 0557077dc020..90c4e46dc678 100644 --- a/lib/hterm.js +++ b/lib/hterm.js @@ -122,15 +122,15 @@ hterm.Terminal.IO.prototype.writeUTF8 = function (string) { } runes(string).forEach(rune => { - this.terminal_.getTextAttributes().hasUnicode = containsNonLatinCodepoints(rune); + this.terminal_.getTextAttributes().unicodeNode = containsNonLatinCodepoints(rune); this.terminal_.interpret(rune); - this.terminal_.getTextAttributes().hasUnicode = false; + this.terminal_.getTextAttributes().unicodeNode = false; }); }; const oldIsDefault = hterm.TextAttributes.prototype.isDefault; hterm.TextAttributes.prototype.isDefault = function () { - return !this.hasUnicode && oldIsDefault.call(this); + return !this.unicodeNode && oldIsDefault.call(this); }; const oldSetFontSize = hterm.Terminal.prototype.setFontSize; @@ -146,7 +146,7 @@ hterm.Terminal.prototype.setFontSize = function (px) { unicodeNodeStyle.innerHTML = ` .unicode-node { display: inline-block; - max-width: ${this.scrollPort_.characterSize.width}px; + width: ${this.scrollPort_.characterSize.width}px; } `; }; @@ -154,7 +154,7 @@ hterm.Terminal.prototype.setFontSize = function (px) { const oldCreateContainer = hterm.TextAttributes.prototype.createContainer; hterm.TextAttributes.prototype.createContainer = function (text) { const container = oldCreateContainer.call(this, text); - if (container.style && text.length === 1 && containsNonLatinCodepoints(text)) { + if (container.style && text.length < 2 && containsNonLatinCodepoints(text)) { container.className += ' unicode-node'; } return container; @@ -163,11 +163,9 @@ hterm.TextAttributes.prototype.createContainer = function (text) { // Do not match containers when one of them has unicode text (unicode chars need to be alone in their containers) const oldMatchesContainer = hterm.TextAttributes.prototype.matchesContainer; hterm.TextAttributes.prototype.matchesContainer = function (obj) { - const content = typeof obj === 'string' ? obj : obj.textContent; - if (this.hasUnicode || containsNonLatinCodepoints(content)) { - return false; - } - return oldMatchesContainer.call(this, obj); + return oldMatchesContainer.call(this, obj) && + !this.unicodeNode && + !containsNonLatinCodepoints(obj.textContent); }; // there's no option to turn off the size overlay