From f361e286ed1ede700fa80e90ffae2cc80b0fad06 Mon Sep 17 00:00:00 2001 From: Jeremy Pyne Date: Fri, 11 Mar 2016 14:44:21 -0500 Subject: [PATCH] This minor fix will restore the editors cursor in CoreArea editor boxes when they save the item. There is a check included to prevent this behavior is the server level code changes the file for some reason as then the cursor location could act unpredictably, so instead we just let it reset to the beginning of the file. --- .../umbraco_client/CodeArea/UmbracoEditor.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI/umbraco_client/CodeArea/UmbracoEditor.js b/src/Umbraco.Web.UI/umbraco_client/CodeArea/UmbracoEditor.js index 8f0faf2a28..96ef28f53c 100644 --- a/src/Umbraco.Web.UI/umbraco_client/CodeArea/UmbracoEditor.js +++ b/src/Umbraco.Web.UI/umbraco_client/CodeArea/UmbracoEditor.js @@ -35,9 +35,18 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls.CodeEditor"); this._control.val(code); } else { - //this is a wrapper for CodeMirror + //this is a wrapper for CodeMirror this._editor.focus(); + + var codeChanged = this._editor.getValue() != code; + var cursor = this._editor.doc.getCursor(); + this._editor.setValue(code); + + // Restore cursor position if the server saved code matches. + if (!codeChanged) + this._editor.setCursor(cursor); + this._editor.focus(); } },