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.

This commit is contained in:
Jeremy Pyne
2016-03-11 14:44:21 -05:00
parent a91669abc0
commit f361e286ed

View File

@@ -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();
}
},