From 5abb3a5586b02783524c5241d967fdbd884ae8d5 Mon Sep 17 00:00:00 2001 From: ashu8912 Date: Wed, 15 Jan 2020 17:50:00 +0530 Subject: [PATCH 1/5] fixed cursor position on tidy --- client/modules/IDE/components/Editor.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index b8e81650..ac10e8e5 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -271,6 +271,7 @@ class Editor extends React.Component { }; 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)); } else if (mode === 'css') { @@ -278,6 +279,7 @@ class Editor extends React.Component { } else if (mode === 'htmlmixed') { this._cm.doc.setValue(beautifyHTML(this._cm.doc.getValue(), beautifyOptions)); } + this._cm.doc.setCursor({ line: currentPosition.line, ch: currentPosition.ch }); } initializeDocuments(files) { From 08f1c52f969f996d19d2ea590a5dbf12b3b10528 Mon Sep 17 00:00:00 2001 From: ashu8912 Date: Sat, 25 Jan 2020 18:30:17 +0530 Subject: [PATCH 2/5] 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) { From 5937af22f365f83f6122c46a7ceb407de4ed10e8 Mon Sep 17 00:00:00 2001 From: ashu8912 Date: Sun, 26 Jan 2020 02:55:07 +0530 Subject: [PATCH 3/5] changed setImmediate with setTimeout --- client/modules/IDE/components/Editor.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index 946bb83c..762409e7 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -280,10 +280,10 @@ class Editor extends React.Component { } else if (mode === 'htmlmixed') { this._cm.doc.setValue(beautifyHTML(this._cm.doc.getValue(), beautifyOptions)); } - setImmediate(() => { + setTimeout(() => { this._cm.focus(); this._cm.doc.setCursor({ line: currentPosition.line, ch: currentPosition.ch + INDENTATION_AMOUNT }); - }); + }, 0); } initializeDocuments(files) { From 8545a3b7ce8f187c396d32666f21362f304168a4 Mon Sep 17 00:00:00 2001 From: ashu8912 Date: Sun, 26 Jan 2020 12:47:37 +0530 Subject: [PATCH 4/5] removed console.log --- client/modules/IDE/components/Editor.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index 762409e7..ac353ab7 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -269,7 +269,6 @@ 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') { From 5891b3b77ab98fe70297a91f1d1a2ea8a160337f Mon Sep 17 00:00:00 2001 From: ashu8912 Date: Wed, 29 Jan 2020 16:12:08 +0530 Subject: [PATCH 5/5] removed console.log --- client/modules/IDE/components/Editor.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/client/modules/IDE/components/Editor.jsx b/client/modules/IDE/components/Editor.jsx index ac353ab7..95f9ba9b 100644 --- a/client/modules/IDE/components/Editor.jsx +++ b/client/modules/IDE/components/Editor.jsx @@ -273,7 +273,6 @@ class Editor extends React.Component { 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') {