Fixed Indentation on setCursor

This commit is contained in:
ashu8912 2020-01-25 18:30:17 +05:30
parent 5abb3a5586
commit 08f1c52f96
1 changed files with 6 additions and 2 deletions

View File

@ -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) {