Merge pull request #1240 from ashu8912/cursor-pos-final

fixed cursor position on tidy
This commit is contained in:
Cassie Tarakajian 2020-02-03 18:00:17 -05:00 committed by GitHub
commit 69f26c12ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -269,8 +269,8 @@ class Editor extends React.Component {
indent_size: INDENTATION_AMOUNT, indent_size: INDENTATION_AMOUNT,
indent_with_tabs: IS_TAB_INDENT indent_with_tabs: IS_TAB_INDENT
}; };
const mode = this._cm.getOption('mode'); const mode = this._cm.getOption('mode');
const currentPosition = this._cm.doc.getCursor();
if (mode === 'javascript') { if (mode === 'javascript') {
this._cm.doc.setValue(beautifyJS(this._cm.doc.getValue(), beautifyOptions)); this._cm.doc.setValue(beautifyJS(this._cm.doc.getValue(), beautifyOptions));
} else if (mode === 'css') { } else if (mode === 'css') {
@ -278,6 +278,10 @@ class Editor extends React.Component {
} else if (mode === 'htmlmixed') { } else if (mode === 'htmlmixed') {
this._cm.doc.setValue(beautifyHTML(this._cm.doc.getValue(), beautifyOptions)); this._cm.doc.setValue(beautifyHTML(this._cm.doc.getValue(), beautifyOptions));
} }
setTimeout(() => {
this._cm.focus();
this._cm.doc.setCursor({ line: currentPosition.line, ch: currentPosition.ch + INDENTATION_AMOUNT });
}, 0);
} }
initializeDocuments(files) { initializeDocuments(files) {