From 7816c17cb54ef9d5b00e24e235d2121efb3304a4 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 23 Aug 2019 16:31:57 +0200 Subject: [PATCH] Fix backspace shortcut in codemirror --- www/common/sframe-common-codemirror.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index f910f12b6..6174e3a4c 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -416,8 +416,12 @@ define([ "Backspace": function () { var cursor = doc.getCursor(); var line = doc.getLine(cursor.line); - if (line.substring(0, cursor.ch).trim() === "") { editor.execCommand("indentLess"); } - else { editor.execCommand("delCharBefore"); } + var beforeCursor = line.substring(0, cursor.ch); + if (beforeCursor && beforeCursor.trim() === "") { + editor.execCommand("indentLess"); + } else { + editor.execCommand("delCharBefore"); + } }, });