<commit_before>iD.behavior.DrawWay = function(context, wayId, index, mode, baseGraph) {
    var way = context.entity(wayId),
        isArea = way.geometry() === 'area',
        finished = false,
        annotation = t((way.isDegenerate() ?
            'operations.start.annotation.' :
            'operations.continue.annotation.') + context.geometry(wayId)),
        draw = iD.behavior.Draw(context);

    var startIndex = typeof index === 'undefined' ? way.nodes.length - 1 : 0,
        start = iD.Node({loc: context.graph().entity(way.nodes[startIndex]).loc}),
        end = iD.Node({loc: context.map().mouseCoordinates()}),
        segment = iD.Way({
            nodes: [start.id, end.id],
            tags: _.clone(way.tags)
        });

    var f = context[way.isDegenerate() ? 'replace' : 'perform'];
    if (isArea) {
        f(iD.actions.AddEntity(end),
            iD.actions.AddVertex(wayId, end.id, index));
    } else {
        f(iD.actions.AddEntity(start),
            iD.actions.AddEntity(end),
            iD.actions.AddEntity(segment));
    }

    function move(datum) {
        var loc = context.map().mouseCoordinates();

        if (datum.type === 'node') {
            if (datum.id === end.id) {
                context.surface().selectAll('.way, .node')
                    .filter(function (d) { return d.id === end.id; })
                    .classed('active', true);
            } else {
                loc = datum.loc;
            }
        } else if (datum.type === 'midpoint' || datum.type === 'way') {
            var way = datum.type === 'way' ?
                datum :
                context.entity(datum.ways[0].id);
            loc = iD.geo.chooseIndex(way, d3.mouse(context.surface().node()), context).loc;
        }

        context.replace(iD.actions.MoveNode(end.id, loc));
    }

    function undone() {
        context.enter(iD.modes.Browse(context));<commit_msg>Revert "Don't snap to midpoints, snap to their parent way"<commit_after>iD.behavior.DrawWay = function(context, wayId, index, mode, baseGraph) {
    var way = context.entity(wayId),
        isArea = way.geometry() === 'area',
        finished = false,
        annotation = t((way.isDegenerate() ?
            'operations.start.annotation.' :
            'operations.continue.annotation.') + context.geometry(wayId)),
        draw = iD.behavior.Draw(context);

    var startIndex = typeof index === 'undefined' ? way.nodes.length - 1 : 0,
        start = iD.Node({loc: context.graph().entity(way.nodes[startIndex]).loc}),
        end = iD.Node({loc: context.map().mouseCoordinates()}),
        segment = iD.Way({
            nodes: [start.id, end.id],
            tags: _.clone(way.tags)
        });

    var f = context[way.isDegenerate() ? 'replace' : 'perform'];
    if (isArea) {
        f(iD.actions.AddEntity(end),
            iD.actions.AddVertex(wayId, end.id, index));
    } else {
        f(iD.actions.AddEntity(start),
            iD.actions.AddEntity(end),
            iD.actions.AddEntity(segment));
    }

    function move(datum) {
        var loc = context.map().mouseCoordinates();

        if (datum.type === 'node' || datum.type === 'midpoint') {
            loc = datum.loc;
        } else if (datum.type === 'way') {
            loc = iD.geo.chooseIndex(datum, d3.mouse(context.surface().node()), context).loc;
        }

        context.replace(iD.actions.MoveNode(end.id, loc));
    }

    function undone() {
        context.enter(iD.modes.Browse(context));
{'fraction_non_alphanumeric': 0.1655667144906743, 'fraction_numerical': 0.0020086083213773313, 'mean_word_length': 2.1208594449418086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7360446', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1075, 'n_words': 191}