<commit_before>const CommonSelectors = require('../lib/common_selectors');
const LineString = require('../feature_types/line_string');
const isEventAtCoordinates = require('../lib/is_event_at_coordinates');
const doubleClickZoom = require('../lib/double_click_zoom');
const Constants = require('../constants');
const createVertex = require('../lib/create_vertex');

module.exports = function(ctx, opts) {
  const featureId = opts.featureId;

  let line, currentVertexPosition;
  if (featureId) {
    line = ctx.store.get(featureId);
    if (!line) {
      throw new Error('Could not find a feature with the provided featureId');
    }
    // const from = opts.from;
    // if (!from) {
    //   throw new Error('Please use the `from` property to indicate which coordinate to continue the line from');
    // }
    currentVertexPosition = 0 //line.coordinates.length;
  } else {
    line = new LineString(ctx, {
      type: Constants.geojsonTypes.FEATURE,
      properties: {},
      geometry: {
        type: Constants.geojsonTypes.LINE_STRING,
        coordinates: []
      }
    });
    currentVertexPosition = 0;

    if (ctx._test) ctx._test.line = line;

    ctx.store.add(line);
  }

  return {
    start: function() {
      ctx.store.clearSelected();
      doubleClickZoom.disable(ctx);
      ctx.ui.queueMapClasses({ mouse: Constants.cursors.ADD });
      ctx.ui.setActiveButton(Constants.types.LINE);
      this.on('mousemove', CommonSelectors.true, (e) => {<commit_msg>Reverse coordinates array to start editing at the beginning<commit_after>const CommonSelectors = require('../lib/common_selectors');
const LineString = require('../feature_types/line_string');
const isEventAtCoordinates = require('../lib/is_event_at_coordinates');
const doubleClickZoom = require('../lib/double_click_zoom');
const Constants = require('../constants');
const createVertex = require('../lib/create_vertex');

module.exports = function(ctx, opts) {
  const featureId = opts.featureId;

  let line, currentVertexPosition;
  if (featureId) {
    line = ctx.store.get(featureId);
    if (!line) {
      throw new Error('Could not find a feature with the provided featureId');
    }
    const from = opts.from;
    if (!from) {
      throw new Error('Please use the `from` property to indicate which coordinate to continue the line from');
    }
    if (from === 'end') {
      currentVertexPosition = line.coordinates.length;
    } else if (from === 'start') {
      line.coordinates.reverse();
      currentVertexPosition = line.coordinates.length;
    } else {
      throw new Error('`from` should be either \'start\' or \'end\'');
    }

  } else {
    line = new LineString(ctx, {
      type: Constants.geojsonTypes.FEATURE,
      properties: {},
      geometry: {
        type: Constants.geojsonTypes.LINE_STRING,
        coordinates: []
      }
    });
    currentVertexPosition = 0;

    if (ctx._test) ctx._test.line = line;

    ctx.store.add(line);
  }

  return {
    start: function() {
      ctx.store.clearSelected();
      doubleClickZoom.disable(ctx);
      ctx.ui.queueMapClasses({ mouse: Constants.cursors.ADD });
      ctx.ui.setActiveButton(Constants.types.LINE);
      this.on('mousemove', CommonSelectors.true, (e) => {
{'fraction_non_alphanumeric': 0.13803775920767564, 'fraction_numerical': 0.0009285051067780873, 'mean_word_length': 3.230366492146597, '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': '5774510', 'n_tokens_mistral': 956, 'n_tokens_neox': 944, 'n_words': 223}