<commit_before>// @flow
import { Component } from "react";
import range from "lodash/range";

class HighlightLines extends Component {
  highlightLineRange: Function;

  props: {
    highlightedLineRange: Object,
    editor: Object
  };

  constructor() {
    super();
    this.highlightLineRange = this.highlightLineRange.bind(this);
  }

  componentDidMount() {
    if (!this.props.editor) {
      return;
    }

    this.highlightLineRange();
  }

  componentWillUpdate() {
    this.clearHighlightRange();
  }

  componentDidUpdate() {
    this.highlightLineRange();
  }

  componentWillUnmount() {
    this.clearHighlightRange();
  }

  clearHighlightRange() {
    const { highlightedLineRange, editor } = this.props;

    if (!editor) {
      return;
    }

    const { codeMirror } = editor;

    if (!highlightedLineRange || !editor || !codeMirror) {
      return;
    }

    const { start, end } = highlightedLineRange;

    range(start - 1, end).forEach(line => {
      codeMirror.removeLineClass(line, "line", "highlight-lines");
    });
  }

  highlightLineRange() {
    const { highlightedLineRange, editor } = this.props;

    if (!editor) {
      return;
    }

    const { codeMirror } = editor;

    if (!highlightedLineRange || !codeMirror) {
      return;
    }

    const { start, end } = highlightedLineRange;

    editor.alignLine(start);

    range(start - 1, end).forEach(line => {
      codeMirror.addLineClass(line, "line", "highlight-lines");
    });
  }

  render() {
    return null;
  }
}

HighlightLines.displayName = "HighlightLines";

export default HighlightLines;<commit_msg>Fix line jumping when adding a bp (#2940)<commit_after>// @flow
import { Component } from "react";
import range from "lodash/range";
import isEmpty from "lodash/isEmpty";

class HighlightLines extends Component {
  highlightLineRange: Function;

  props: {
    highlightedLineRange: Object,
    editor: Object
  };

  constructor() {
    super();
    this.highlightLineRange = this.highlightLineRange.bind(this);
  }

  componentDidMount() {
    if (!this.props.editor) {
      return;
    }

    this.highlightLineRange();
  }

  componentWillUpdate() {
    this.clearHighlightRange();
  }

  componentDidUpdate() {
    this.highlightLineRange();
  }

  componentWillUnmount() {
    this.clearHighlightRange();
  }

  clearHighlightRange() {
    const { highlightedLineRange, editor } = this.props;

    if (!editor) {
      return;
    }

    const { codeMirror } = editor;

    if (isEmpty(highlightedLineRange) || !editor || !codeMirror) {
      return;
    }

    const { start, end } = highlightedLineRange;

    range(start - 1, end).forEach(line => {
      codeMirror.removeLineClass(line, "line", "highlight-lines");
    });
  }

  highlightLineRange() {
    const { highlightedLineRange, editor } = this.props;

    if (!editor) {
      return;
    }

    const { codeMirror } = editor;

    if (isEmpty(highlightedLineRange) || !codeMirror) {
      return;
    }

    const { start, end } = highlightedLineRange;

    editor.alignLine(start);

    range(start - 1, end).forEach(line => {
      codeMirror.addLineClass(line, "line", "highlight-lines");
    });
  }

  render() {
    return null;
  }
}

HighlightLines.displayName = "HighlightLines";

export default HighlightLines;
{'fraction_non_alphanumeric': 0.13121212121212122, 'fraction_numerical': 0.0024242424242424242, 'mean_word_length': 3.001212121212121, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6599619', 'n_tokens_mistral': 1071, 'n_tokens_neox': 979, 'n_words': 202}