<commit_before>(function() {
  var self = model

  var getSelectOption = function(event) {
    if (event.shiftKey)
    {
      if (event.ctrlKey)
        return 'remove';
      else
        return 'add';
    }
    else if (event.ctrlKey)
      return 'toggle';
    else
      return '';
  };
  
  self.holodeckModeMouseDown = {};

  self.holodeckModeMouseDown.fab = function (holodeck, mdevent) {
    console.log('my holodeckModeMouseDown.fab')
    if (mdevent.button === 0) {
      var queue = mdevent.shiftKey;
      model.fabCount(model.fabCount() + 1);
      if (queue && (model.fabCount() === 1)) {
        var shiftWatch = function (keyEvent) {
          if (!keyEvent.shiftKey) {
            $('body').off('keyup', shiftWatch);
            if (self.mode() === 'fab')
              self.endFabMode();
            else if (self.mode() === 'fab_rotate')
              self.mode('fab_end');
          }
        };
        $('body').on('keyup', shiftWatch);
      }
      var beginFabX = mdevent.offsetX;
      var beginFabY = mdevent.offsetY;
      var beginSnap = !mdevent.ctrlKey;
      holodeck.unitBeginFab(beginFabX, beginFabY, beginSnap);
      self.mode('fab_rotate');
      input.capture(holodeck.div, function (event) {
        if ((event.type === 'mouseup') && (event.button === mdevent.button)) {
          var snap = !event.ctrlKey;
          holodeck.unitEndFab(event.offsetX, event.offsetY, queue, snap).then(function (success) {
            holodeck.showCommandConfirmation("", event.offsetX, event.offsetY);
            if (success)
              api.audio.playSound("/SE/UI/UI_Building_place");
          });
          queue &= (self.mode() !== 'fab_end');
          self.mode('fab');
          input.release();
          if (!queue)
            self.endFabMode();
        }
        else if ((event.type === 'keydown') && (event.keyCode === keyboard.esc)) {
          input.release();
          holodeck.unitCancelFab();
          self.endFabMode();
        }
      });
      return true;
    }
    else if (mdevent.button === 2) {
      self.endFabMode();
      return true;
    }
    return false;
  };

  var holodeckOnSelect = function (wasSelected, prevSelection, promise) {
    return promise.then(function (selection) {
      if (selection) {<commit_msg>extract method for fab down<commit_after>(function() {
  var self = model

  var getSelectOption = function(event) {
    if (event.shiftKey)
    {
      if (event.ctrlKey)
        return 'remove';
      else
        return 'add';
    }
    else if (event.ctrlKey)
      return 'toggle';
    else
      return '';
  };
  
  self.holodeckModeMouseDown = {};

  self.beginFabDown = function(holodeck, mdevent) {
    var queue = mdevent.shiftKey;
    model.fabCount(model.fabCount() + 1);
    if (queue && (model.fabCount() === 1)) {
      var shiftWatch = function (keyEvent) {
        if (!keyEvent.shiftKey) {
          $('body').off('keyup', shiftWatch);
          if (self.mode() === 'fab')
            self.endFabMode();
          else if (self.mode() === 'fab_rotate')
            self.mode('fab_end');
        }
      };
      $('body').on('keyup', shiftWatch);
    }
    var beginFabX = mdevent.offsetX;
    var beginFabY = mdevent.offsetY;
    var beginSnap = !mdevent.ctrlKey;
    holodeck.unitBeginFab(beginFabX, beginFabY, beginSnap);
    self.mode('fab_rotate');
    input.capture(holodeck.div, function (event) {
      if ((event.type === 'mouseup') && (event.button === mdevent.button)) {
        var snap = !event.ctrlKey;
        holodeck.unitEndFab(event.offsetX, event.offsetY, queue, snap).then(function (success) {
          holodeck.showCommandConfirmation("", event.offsetX, event.offsetY);
          if (success)
            api.audio.playSound("/SE/UI/UI_Building_place");
        });
        queue &= (self.mode() !== 'fab_end');
        self.mode('fab');
        input.release();
        if (!queue)
          self.endFabMode();
      }
      else if ((event.type === 'keydown') && (event.keyCode === keyboard.esc)) {
        input.release();
        holodeck.unitCancelFab();
        self.endFabMode();
      }
    });
  }

  self.holodeckModeMouseDown.fab = function (holodeck, mdevent) {
    console.log('my holodeckModeMouseDown.fab')
    if (mdevent.button === 0) {
      self.beginFabDown(holodeck, mdevent)
      return true;
    }
    else if (mdevent.button === 2) {
      self.endFabMode();
      return true;
    }
    return false;
  };

  var holodeckOnSelect = function (wasSelected, prevSelection, promise) {
    return promise.then(function (selection) {
      if (selection) {
{'fraction_non_alphanumeric': 0.1515876468029578, 'fraction_numerical': 0.0017398869073510222, 'mean_word_length': 2.2478813559322033, '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': '136274', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1450, 'n_words': 279}