<commit_before>import {
  SELECT_TOOL_EDIT,
  MODE_IDLE,
  SELECT_AREA,
  SELECT_HOLE,
  SELECT_LINE,
  SELECT_ITEM,
  UNSELECT_ALL,
  SET_PROPERTIES,
  REMOVE
} from '../constants';

import {ElementsSet} from '../models';
import {Map} from 'immutable';
import {
  removeLine,
  removeHole,
  detectAndUpdateAreas,
  setProperties as setPropertiesOp,
  select,
  unselect,
  unselectAll as unselectAllOp,
  removeItem
} from '../utils/layer-operations';

export default function (state, action) {
  let {scene} = state;

  switch (action.type) {
    case SELECT_TOOL_EDIT:
      return state.set('mode', MODE_IDLE);

    case SELECT_AREA:
      return state.set('scene', selectArea(scene, action.layerID, action.areaID));

    case SELECT_HOLE:
      return state.set('scene', selectHole(scene, action.layerID, action.holeID));

    case SELECT_LINE:
      return state.set('scene', selectLine(scene, action.layerID, action.lineID));

    case SELECT_ITEM:
      return state.set('scene', selectItem(scene, action.layerID, action.itemID));

    case UNSELECT_ALL:
      return state.set('scene', unselectAll(scene));

    case SET_PROPERTIES:
      return state.set('scene', setProperties(scene, action.properties));

    case REMOVE:
      return state.set('scene', remove(scene, action.catalog));

    default:
      return state;
  }
}


function setProperties(scene, properties) {
  return scene.updateIn(['layers', scene.selectedLayer], layer => layer.withMutations(layer => {
    layer.selected.lines.forEach(lineID => setPropertiesOp(layer, 'lines', lineID, properties));
    layer.selected.holes.forEach(holeID => setPropertiesOp(layer, 'holes', holeID, properties));
    layer.selected.areas.forEach(areaID => setPropertiesOp(layer, 'areas', areaID, properties));
    layer.selected.items.forEach(itemID => setPropertiesOp(layer, 'items', itemID, properties));
    unselectAllOp(layer);<commit_msg>avoid unselection after set property<commit_after>import {
  SELECT_TOOL_EDIT,
  MODE_IDLE,
  SELECT_AREA,
  SELECT_HOLE,
  SELECT_LINE,
  SELECT_ITEM,
  UNSELECT_ALL,
  SET_PROPERTIES,
  REMOVE
} from '../constants';

import {ElementsSet} from '../models';
import {Map} from 'immutable';
import {
  removeLine,
  removeHole,
  detectAndUpdateAreas,
  setProperties as setPropertiesOp,
  select,
  unselect,
  unselectAll as unselectAllOp,
  removeItem
} from '../utils/layer-operations';

export default function (state, action) {
  let {scene} = state;

  switch (action.type) {
    case SELECT_TOOL_EDIT:
      return state.set('mode', MODE_IDLE);

    case SELECT_AREA:
      return state.set('scene', selectArea(scene, action.layerID, action.areaID));

    case SELECT_HOLE:
      return state.set('scene', selectHole(scene, action.layerID, action.holeID));

    case SELECT_LINE:
      return state.set('scene', selectLine(scene, action.layerID, action.lineID));

    case SELECT_ITEM:
      return state.set('scene', selectItem(scene, action.layerID, action.itemID));

    case UNSELECT_ALL:
      return state.set('scene', unselectAll(scene));

    case SET_PROPERTIES:
      return state.set('scene', setProperties(scene, action.properties));

    case REMOVE:
      return state.set('scene', remove(scene, action.catalog));

    default:
      return state;
  }
}


function setProperties(scene, properties) {
  return scene.updateIn(['layers', scene.selectedLayer], layer => layer.withMutations(layer => {
    layer.selected.lines.forEach(lineID => setPropertiesOp(layer, 'lines', lineID, properties));
    layer.selected.holes.forEach(holeID => setPropertiesOp(layer, 'holes', holeID, properties));
    layer.selected.areas.forEach(areaID => setPropertiesOp(layer, 'areas', areaID, properties));
    layer.selected.items.forEach(itemID => setPropertiesOp(layer, 'items', itemID, properties));
    // unselectAllOp(layer);
{'fraction_non_alphanumeric': 0.12864583333333332, 'fraction_numerical': 0.0, 'mean_word_length': 4.379551820728292, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '948900', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1180, 'n_words': 257}