From 79325b8cca475a84f99a3525e4ae44066c52d495 Mon Sep 17 00:00:00 2001 From: stoppegp Date: Tue, 7 Apr 2020 19:07:12 +0200 Subject: [PATCH] bugfix authorcolors: wrong end position on multiline edit --- www/code/inner.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/www/code/inner.js b/www/code/inner.js index f155eee6a..79b625154 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -459,7 +459,12 @@ define([ editor.on('change', function( cm, change ) { if (change.origin == "+input" || change.origin == "paste") { // add new author mark if text is added. marks from removed text are removed automatically - editor.markText({line: change.from.line, ch: change.from.ch}, {line: change.from.line + change.text.length-1, ch: change.from.ch + change.text[change.text.length-1].length}, {css: "background-color: " + authorcolor}); + if (change.text.length > 1) { + to_ch = change.text[change.text.length-1].length; + } else { + to_ch = change.from.ch + change.text[change.text.length-1].length; + } + editor.markText({line: change.from.line, ch: change.from.ch}, {line: change.from.line + change.text.length-1, ch: to_ch}, {css: "background-color: " + authorcolor}); } else if (change.origin == "setValue") { // on remote update: remove all marks, add new marks editor.getAllMarks().forEach(marker => marker.clear());