diff --git a/lib/widget.js b/lib/widget.js index fc7506b..1b16c6a 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -5901,7 +5901,7 @@ Textarea.prototype._updateCursor = function(get) { line = Math.max(0, line); cy = lpos.yi + this.itop + line; - cx = lpos.xi + this.ileft + last.length; + cx = lpos.xi + this.ileft + this._strWidth(last); // XXX Not sure, but this may still sometimes // cause problems when leaving editor. @@ -5926,6 +5926,12 @@ Textarea.prototype._updateCursor = function(get) { } }; +Textarea.prototype._strWidth = function(str) { + if (!this.screen.fullUnicode) return str.length; + str = str.replace(/\x03/g, ''); + return unicode.strWidth(str, 0); +}; + Textarea.prototype.input = Textarea.prototype.setInput = Textarea.prototype.readInput = function(callback) { @@ -6033,6 +6039,7 @@ Textarea.prototype._listener = function(ch, key) { if (this.value.length) { if (this.screen.fullUnicode) { if (unicode.isSurrogate(this.value, this.value.length - 2)) { + // || unicode.isCombining(this.value, this.value.length - 1)) { this.value = this.value.slice(0, -2); } else { this.value = this.value.slice(0, -1);