Skip to content

Commit

Permalink
FIX monochar emojis by displaying them smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
Caillou committed Jun 5, 2020
1 parent 5e696fd commit bc81943
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/ace/css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ styles.join("\n")
text-align: center;
}

.ace_emoji {
font-size: .5rem;
transform: translateX(-.125rem);
}

.ace_cursor-layer {
z-index: 4;
}
Expand Down
15 changes: 12 additions & 3 deletions lib/ace/layer/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,9 @@ var Text = function(parentEl) {

this.$renderToken = function(parent, screenColumn, token, value) {
var self = this;
var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g;


var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])|(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;

var valueFragment = this.dom.createFragment(this.element);

var m;
Expand All @@ -356,7 +357,8 @@ var Text = function(parentEl) {
var controlCharacter = m[3];
var cjkSpace = m[4];
var cjk = m[5];

var emoji = m[6];

if (!self.showSpaces && simpleSpace)
continue;

Expand Down Expand Up @@ -402,6 +404,13 @@ var Text = function(parentEl) {
span.className = "ace_cjk";
span.textContent = cjk;
valueFragment.appendChild(span);
} else if (emoji) {
screenColumn += 1;
var span = this.dom.createElement("span");
span.style.width = (self.config.characterWidth) + "px";
span.className = "ace_emoji";
span.textContent = emoji;
valueFragment.appendChild(span);
}
}

Expand Down

0 comments on commit bc81943

Please sign in to comment.