<commit_before>import React, { PureComponent } from 'react';
import { Grid, AutoSizer, ScrollSync } from 'react-virtualized';
import scrollbarSize from 'dom-helpers/util/scrollbarSize';
import Draggable from 'react-draggable';
import PropTypes from 'prop-types';
import Button from 'react-md/lib/Buttons/Button';
import SettingsIcon from '../../icons/SettingsIcon.jsx';

import './styles.scss';

const minColWidth = 20;

export default class Table extends PureComponent {
  constructor(props) {
    super(props);

    this.state = {
      leftColumnWidth: props.columnWidth,
      columnWidths: [],
      selectedColumn: null,
      startPos: null,
    };

    this.forceTableUpdate = this.forceTableUpdate.bind(this);
    this.getColumnWidth = this.getColumnWidth.bind(this);
    this.onDrag = this.onDrag.bind(this);
    this.setSelectedColumn = this.setSelectedColumn.bind(this);

    this.evenOddRowStyle = this.evenOddRowStyle.bind(this);
    this.renderBodyCell = this.renderBodyCell.bind(this);
    this.renderHeaderCell = this.renderHeaderCell.bind(this);
    this.renderLeftHeaderCell = this.renderLeftHeaderCell.bind(this);
    this.renderLeftSideCell = this.renderLeftSideCell.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.columnCount !== this.props.columnCount) {
      this.setState({
        columnWidths: Array(nextProps.columnCount > 1 ?
          nextProps.columnCount - 1 :
          1).fill(nextProps.columnWidth),
      });
    }
    this.forceTableUpdate();
  }

  forceTableUpdate() {
    this.bodyGrid.recomputeGridSize({ columnIndex: 0, rowIndex: 0 });
    this.grid.recomputeGridSize({ columnIndex: 0, rowIndex: 0 });
    this.header.recomputeGridSize({ columnIndex: 0, rowIndex: 0 });
    this.leftHeader.recomputeGridSize({ columnIndex: 0, rowIndex: 0 });
  }

  getColumnWidth({ index = 0 }) {
    if (this.state.columnWidths.length === 0) {
      return this.props.columnWidth;
    }
    return this.state.columnWidths[index];
  }

  onDrag(e, ui) {
    const {
      columnWidths,
      leftColumnWidth,
      selectedColumn,
    } = this.state;

    if (selectedColumn === 'left') {
      this.setState({
        leftColumnWidth: Math.max(leftColumnWidth + (ui.deltaX), minColWidth),
      });
    } else {<commit_msg>moving forceTableUpdate on componentWillReceiveProps<commit_after>import React, { PureComponent } from 'react';
import { Grid, AutoSizer, ScrollSync } from 'react-virtualized';
import scrollbarSize from 'dom-helpers/util/scrollbarSize';
import Draggable from 'react-draggable';
import PropTypes from 'prop-types';
import Button from 'react-md/lib/Buttons/Button';
import SettingsIcon from '../../icons/SettingsIcon.jsx';

import './styles.scss';

const minColWidth = 20;

export default class Table extends PureComponent {
  constructor(props) {
    super(props);

    this.state = {
      leftColumnWidth: props.columnWidth,
      columnWidths: [],
      selectedColumn: null,
      startPos: null,
    };

    this.forceTableUpdate = this.forceTableUpdate.bind(this);
    this.getColumnWidth = this.getColumnWidth.bind(this);
    this.onDrag = this.onDrag.bind(this);
    this.setSelectedColumn = this.setSelectedColumn.bind(this);

    this.evenOddRowStyle = this.evenOddRowStyle.bind(this);
    this.renderBodyCell = this.renderBodyCell.bind(this);
    this.renderHeaderCell = this.renderHeaderCell.bind(this);
    this.renderLeftHeaderCell = this.renderLeftHeaderCell.bind(this);
    this.renderLeftSideCell = this.renderLeftSideCell.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.columnCount !== this.props.columnCount) {
      this.setState({
        columnWidths: Array(nextProps.columnCount > 1 ?
          nextProps.columnCount - 1 :
          1).fill(nextProps.columnWidth),
      });
      this.forceTableUpdate();
    }
  }

  forceTableUpdate() {
    this.bodyGrid.recomputeGridSize({ columnIndex: 0, rowIndex: 0 });
    this.grid.recomputeGridSize({ columnIndex: 0, rowIndex: 0 });
    this.header.recomputeGridSize({ columnIndex: 0, rowIndex: 0 });
    this.leftHeader.recomputeGridSize({ columnIndex: 0, rowIndex: 0 });
  }

  getColumnWidth({ index = 0 }) {
    if (this.state.columnWidths.length === 0) {
      return this.props.columnWidth;
    }
    return this.state.columnWidths[index];
  }

  onDrag(e, ui) {
    const {
      columnWidths,
      leftColumnWidth,
      selectedColumn,
    } = this.state;

    if (selectedColumn === 'left') {
      this.setState({
        leftColumnWidth: Math.max(leftColumnWidth + (ui.deltaX), minColWidth),
      });
    } else {
{'fraction_non_alphanumeric': 0.12567949554250923, 'fraction_numerical': 0.006523157208088715, 'mean_word_length': 3.5544554455445545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '902694', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1402, 'n_words': 261}