components/Editor.jsx: Allow indentation on entering new line (#710)

indentUnit updated on settings->indentation amount change

Fixes https://github.com/processing/p5.js-web-editor/issues/700
This commit is contained in:
Bhawesh Bhansali 2018-10-04 23:06:42 +05:30 committed by Cassie Tarakajian
parent 04191fbaab
commit cf5cb1f6e9

View file

@ -136,6 +136,7 @@ class Editor extends React.Component {
this._cm.getWrapperElement().style['font-size'] = `${this.props.fontSize}px`;
this._cm.setOption('indentWithTabs', this.props.isTabIndent);
this._cm.setOption('tabSize', this.props.indentationAmount);
this._cm.setOption('indentUnit', this.props.indentationAmount);
this.props.provideController({
tidyCode: this.tidyCode,
@ -171,6 +172,7 @@ class Editor extends React.Component {
}
if (this.props.indentationAmount !== prevProps.indentationAmount) {
this._cm.setOption('tabSize', this.props.indentationAmount);
this._cm.setOption('indentUnit', this.props.indentationAmount);
}
if (this.props.isTabIndent !== prevProps.isTabIndent) {
this._cm.setOption('indentWithTabs', this.props.isTabIndent);