fix subsequent clicks in colorpicker

seems like new CodeMirror modifies the position object
This commit is contained in:
tophf 2020-12-08 14:40:57 +03:00
parent 6d04c0eb7d
commit 463c3b5139

View File

@ -555,8 +555,9 @@
} }
const {cm, line, ch, embedderCallback} = this; const {cm, line, ch, embedderCallback} = this;
const to = {line, ch: ch + this.prevColor.length}; const to = {line, ch: ch + this.prevColor.length};
if (cm.getRange(this, to) !== newColor) { const from = {line, ch};
cm.replaceRange(newColor, this, to, '*colorpicker'); if (cm.getRange(from, to) !== newColor) {
cm.replaceRange(newColor, from, to, '*colorpicker');
this.prevColor = newColor; this.prevColor = newColor;
} }
if (typeof embedderCallback === 'function') { if (typeof embedderCallback === 'function') {