From 08f1c52f969f996d19d2ea590a5dbf12b3b10528 Mon Sep 17 00:00:00 2001 From: ashu8912 Date: Sat, 25 Jan 2020 18:30:17 +0530 Subject: [PATCH] Fixed Indentation on setCursor --- client/modules/IDE/components/Editor.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index ac10e8e5..946bb83c 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -269,17 +269,21 @@ class Editor extends React.Component { indent_size: INDENTATION_AMOUNT, indent_with_tabs: IS_TAB_INDENT }; - + console.log('inside'); const mode = this._cm.getOption('mode'); const currentPosition = this._cm.doc.getCursor(); if (mode === 'javascript') { this._cm.doc.setValue(beautifyJS(this._cm.doc.getValue(), beautifyOptions)); + console.log('beautifying'); } else if (mode === 'css') { this._cm.doc.setValue(beautifyCSS(this._cm.doc.getValue(), beautifyOptions)); } else if (mode === 'htmlmixed') { this._cm.doc.setValue(beautifyHTML(this._cm.doc.getValue(), beautifyOptions)); } - this._cm.doc.setCursor({ line: currentPosition.line, ch: currentPosition.ch }); + setImmediate(() => { + this._cm.focus(); + this._cm.doc.setCursor({ line: currentPosition.line, ch: currentPosition.ch + INDENTATION_AMOUNT }); + }); } initializeDocuments(files) {