<commit_before>import React, { PureComponent } from 'react';
import CodeMirrorComponent from 'react-codemirror2';
import className from 'classnames';
import PropTypes from 'prop-types';

import 'codemirror/mode/gfm/gfm';
import 'codemirror/addon/edit/closebrackets';
import 'codemirror/addon/scroll/scrollpastend';
import 'codemirror/addon/scroll/simplescrollbars';
import 'codemirror/addon/selection/active-line';
import 'codemirror/keymap/sublime';

class CodeMirror extends PureComponent {
  static propTypes = {
    options: PropTypes.objectOf(PropTypes.any),
    content: PropTypes.string,
    onChange: PropTypes.func,
    api: PropTypes.func,
    className: PropTypes.oneOfType([
      PropTypes.arrayOf(PropTypes.string),
      PropTypes.string,
    ]),
  }

  static defaultOptions = {
    mode: 'gfm',
    theme: 'dark',
    autofocus: true,
    lineNumbers: false,
    lineWrapping: true,
    styleActiveLine: true,
    scrollbarStyle: 'overlay',
    scrollPastEnd: true,
    indentUnit: 4,
    autoCloseBrackets: true,
    keyMap: 'sublime',
  }

  static defaultProps = {
    options: {},
    content: '',
  }

  state = {
    options: CodeMirror.defaultOptions,
  }

  componentWillMount() {
    this.updateOptions(this.props.options);
  }

  componentWillReceiveProps(nextProps) {
    this.updateOptions(nextProps.options);
  }

  onChange = (editor, metadata, value) => {
    this.props.onChange(value);
  }

  getCodeMirrorRef = (ref) => {
    if (ref && this.props.api) {
      this.props.api(ref);
    }
  }

  updateOptions = (options = {}) => {
    this.setState({
      options: {
        ...CodeMirror.defaultOptions,
        ...this.state.options,
        options,
      },<commit_msg>:bug: Fix CodeMirror custom options<commit_after>import React, { PureComponent } from 'react';
import CodeMirrorComponent from 'react-codemirror2';
import className from 'classnames';
import PropTypes from 'prop-types';

import 'codemirror/mode/gfm/gfm';
import 'codemirror/addon/edit/closebrackets';
import 'codemirror/addon/scroll/scrollpastend';
import 'codemirror/addon/scroll/simplescrollbars';
import 'codemirror/addon/selection/active-line';
import 'codemirror/keymap/sublime';

class CodeMirror extends PureComponent {
  static propTypes = {
    options: PropTypes.objectOf(PropTypes.any),
    content: PropTypes.string,
    onChange: PropTypes.func,
    api: PropTypes.func,
    className: PropTypes.oneOfType([
      PropTypes.arrayOf(PropTypes.string),
      PropTypes.string,
    ]),
  }

  static defaultOptions = {
    mode: 'gfm',
    theme: 'dark',
    autofocus: true,
    lineNumbers: false,
    lineWrapping: true,
    styleActiveLine: true,
    scrollbarStyle: 'overlay',
    scrollPastEnd: true,
    indentUnit: 4,
    autoCloseBrackets: true,
    keyMap: 'sublime',
  }

  static defaultProps = {
    options: {},
    content: '',
  }

  state = {
    options: CodeMirror.defaultOptions,
  }

  componentWillMount() {
    this.updateOptions(this.props.options);
  }

  componentWillReceiveProps(nextProps) {
    this.updateOptions(nextProps.options);
  }

  onChange = (editor, metadata, value) => {
    this.props.onChange(value);
  }

  getCodeMirrorRef = (ref) => {
    if (ref && this.props.api) {
      this.props.api(ref);
    }
  }

  updateOptions = (options = {}) => {
    this.setState({
      options: {
        ...CodeMirror.defaultOptions,
        ...this.state.options,
        ...options,
      },
{'fraction_non_alphanumeric': 0.12924774905605577, 'fraction_numerical': 0.0011617775196049957, 'mean_word_length': 3.3484848484848486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6337250', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1119, 'n_words': 204}