Skip to content

Commit 59b089e

Browse files
committed
[#941] Add codemirror addon autoCloseBrackets option which by default auto-closes: ()[]{}''"``
1 parent 73a27f8 commit 59b089e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

client/modules/IDE/components/Editor.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import 'codemirror/addon/search/matchesonscrollbar';
2121
import 'codemirror/addon/search/match-highlighter';
2222
import 'codemirror/addon/search/jump-to-line';
2323
import 'codemirror/addon/edit/matchbrackets';
24+
import 'codemirror/addon/edit/closebrackets';
2425

2526
import { JSHINT } from 'jshint';
2627
import { CSSLint } from 'csslint';
@@ -104,6 +105,7 @@ class Editor extends React.Component {
104105
keyMap: 'sublime',
105106
highlightSelectionMatches: true, // highlight current search match
106107
matchBrackets: true,
108+
autoCloseBrackets: this.props.autocloseBracketsQuotes,
107109
lint: {
108110
onUpdateLinting: ((annotations) => {
109111
this.props.hideRuntimeErrorWarning();
@@ -205,6 +207,9 @@ class Editor extends React.Component {
205207
if (this.props.lineNumbers !== prevProps.lineNumbers) {
206208
this._cm.setOption('lineNumbers', this.props.lineNumbers);
207209
}
210+
if (this.props.autocloseBracketsQuotes !== prevProps.autocloseBracketsQuotes) {
211+
this._cm.setOption('autoCloseBrackets', this.props.autocloseBracketsQuotes);
212+
}
208213

209214
if (prevProps.consoleEvents !== this.props.consoleEvents) {
210215
this.props.showRuntimeErrorWarning();
@@ -370,6 +375,7 @@ class Editor extends React.Component {
370375
}
371376

372377
Editor.propTypes = {
378+
autocloseBracketsQuotes: PropTypes.bool.isRequired,
373379
lineNumbers: PropTypes.bool.isRequired,
374380
lintWarning: PropTypes.bool.isRequired,
375381
linewrap: PropTypes.bool.isRequired,

0 commit comments

Comments
 (0)