From 360fee9febdfcc172cb656cb4d0ccd4a7d63dbfb Mon Sep 17 00:00:00 2001 From: Yann Flory Date: Mon, 11 Apr 2016 17:58:30 +0200 Subject: [PATCH] Fix a new cursor error with Codepad --- www/code/rt_codemirror.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/www/code/rt_codemirror.js b/www/code/rt_codemirror.js index 1e3b61ea3..08b0d625e 100644 --- a/www/code/rt_codemirror.js +++ b/www/code/rt_codemirror.js @@ -173,8 +173,8 @@ define([ newCursor.ch = removedTextColumnIndex; } } - else if(cursor.line === removedTextLineNumber && cursor.ch > removedTextLineNumber) { - newCursor.ch -= Math.min(length, cursor.ch-removedTextLineNumber); + else if(cursor.line === removedTextLineNumber && cursor.ch > removedTextColumnIndex) { + newCursor.ch -= Math.min(length, cursor.ch-removedTextColumnIndex); } return newCursor; }; @@ -327,7 +327,8 @@ define([ var oldCursorCMEnd = cmEditor.getCursor('to'); var newCursor; var newSelection; - if(oldCursorCMStart !== oldCursorCMEnd) { // Selection + if(oldCursorCMStart.line !== oldCursorCMEnd.line + && oldCursorCMStart.ch !== oldCursorCMEnd.ch) { // Selection if (op.toRemove > 0) { newSelection = [transformCursorCMRemove(oldValue, oldCursorCMStart, op.offset, op.toRemove), transformCursorCMRemove(oldValue, oldCursorCMEnd, op.offset, op.toRemove)]; }