Skip to content

Commit 69f26c1

Browse files
authored
Merge pull request #1240 from ashu8912/cursor-pos-final
fixed cursor position on tidy
2 parents ec3b1f1 + 5891b3b commit 69f26c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

client/modules/IDE/components/Editor.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,19 @@ class Editor extends React.Component {
269269
indent_size: INDENTATION_AMOUNT,
270270
indent_with_tabs: IS_TAB_INDENT
271271
};
272-
273272
const mode = this._cm.getOption('mode');
273+
const currentPosition = this._cm.doc.getCursor();
274274
if (mode === 'javascript') {
275275
this._cm.doc.setValue(beautifyJS(this._cm.doc.getValue(), beautifyOptions));
276276
} else if (mode === 'css') {
277277
this._cm.doc.setValue(beautifyCSS(this._cm.doc.getValue(), beautifyOptions));
278278
} else if (mode === 'htmlmixed') {
279279
this._cm.doc.setValue(beautifyHTML(this._cm.doc.getValue(), beautifyOptions));
280280
}
281+
setTimeout(() => {
282+
this._cm.focus();
283+
this._cm.doc.setCursor({ line: currentPosition.line, ch: currentPosition.ch + INDENTATION_AMOUNT });
284+
}, 0);
281285
}
282286

283287
initializeDocuments(files) {

0 commit comments

Comments
 (0)