From cac301f0f7b185c9feb32e8dab2b401f4ba60b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 17 Apr 2019 12:48:54 +0200 Subject: [PATCH] [IMP] editor: set tab size dynamically closes #46 --- src/app.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app.js b/src/app.js index 9851e280..a95cd447 100644 --- a/src/app.js +++ b/src/app.js @@ -47,6 +47,8 @@ class TabbedEditor extends Component { this.editor.setFontSize("13px"); this.editor.setTheme("ace/theme/monokai"); this.editor.session.setMode(MODES[this.state.currentTab]); + const tabSize = this.state.currentTab === "xml" ? 2 : 4; + this.editor.session.setOption("tabSize", tabSize); this.editor.on("blur", () => { const editorValue = this.editor.getValue(); const propsValue = this.props[this.state.currentTab]; @@ -76,6 +78,8 @@ class TabbedEditor extends Component { const mode = MODES[tab]; this.editor.session.setMode(mode); + const tabSize = tab === "xml" ? 2 : 4; + this.editor.session.setOption("tabSize", tabSize); this.state.currentTab = tab; }