<commit_before>'use babel';

const path = require('path');

export default class PaneByType {

  static activate() {
    this.skipIds = [];

    atom.workspace.onDidOpen(event => {
      const id = event.item.id;
      this.skipIds.push(id);
      this.moveToCorrectPane(event.item, event.pane);
      const index = this.skipIds.indexOf(id);
      this.skipIds.splice(index, 1);
    });
  }

  /**
   * Move item to the first pane that has a file with the same extension
   * @param  {object} item to move
   * @param  {Pane} pane current pane
   */
  static moveToCorrectPane(item, pane) {
    const ext = this.getFileExtension(item);
    if (!this.paneHasType(pane, ext)) {
      const paneWithType = this.getPaneWithType(ext);

      if (paneWithType) {
        paneWithType.activate();
        pane.moveItemToPane(item, paneWithType);
        paneWithType.activateItem(item);
      }
    }
  }
<commit_msg>Fix tab (file) replication while moving already existing items (only on atom 1.4.3, and upwards)<commit_after>'use babel';

const path = require('path');

export default class PaneByType {

  static activate() {
    this.skipIds = [];

    atom.workspace.onDidOpen(event => {
      const id = event.item.id;
      this.skipIds.push(id);
      this.moveToCorrectPane(event.item, event.pane);
      const index = this.skipIds.indexOf(id);
      this.skipIds.splice(index, 1);
    });
  }

  /**
   * Move item to the first pane that has a file with the same extension
   * @param  {object} item to move
   * @param  {Pane} pane current pane
   */
  static moveToCorrectPane(item, pane) {
    const ext = this.getFileExtension(item);
    if (!this.paneHasType(pane, ext)) {
      const paneWithType = this.getPaneWithType(ext);

      if (paneWithType) {
        paneWithType.activate()
        const existingItem = paneWithType.itemForURI(item.buffer.getUri());

        if (existingItem) {
          pane.destroyItem(item);
          paneWithType.activateItem(existingItem);
        }
        else {
          pane.moveItemToPane(item, paneWithType);
          paneWithType.activateItem(item);
        }
      }
    }
  }

{'fraction_non_alphanumeric': 0.12060065696855936, 'fraction_numerical': 0.002346316283435007, 'mean_word_length': 2.701388888888889, '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': '6569838', 'n_tokens_mistral': 709, 'n_tokens_neox': 676, 'n_words': 154}