<commit_before>import {remote} from 'electron'
import path from 'path'
const state = {
  tabs: [],
  activeTab: '',
  tabObjects: {},
  tabIndex: -1,
  activeTitle: ''
}

const getters = {
  getTabs: state => {
    return state.tabs
  },
  getActiveTab: state => {
    return state.activeTab
  },
  getTabIndex: state => {
    return state.tabIndex
  },
  getPreviousTabId: (state, getters) => (position) => {
    let previousActiveTabPos = position < 1 ? 0 : position - 1
    return state.tabs[previousActiveTabPos]
  },
  tabTitle: (state, getters) => (tabId) => {
    console.log('getting title from tabs store')
    console.log(`tab id is: ${tabId}`)
    return _.get(state.tabObjects, `${tabId}.title`)
  }
}

const mutations = {
  pushTab (state, tabId) {
    console.log('...pushing...')
    state.tabs.push(tabId)
    console.log(state.tabs)
  },
  pushTabTitle(state, tab) {
    let title
    if (tab.title) {
      title = tab.title
    } else {
      title = `Untitled${tab.index}`
    }
    _.set(state.tabObjects, `${tab.id}.title`, title)
  },
  pushTabObject(state, tab) {
    console.log('logging tab on push tab object')
    console.log(tab)
    if (tab.filename) {
      _.set(state.tabObjects, `${tab.id}.filename`, tab.filename)
      // tab title should reflect basename of filename
      let basename = path.basename(tab.filename)
      _.set(state.tabObjects, `${tab.id}.title`, basename)
      // update global active references for electron-main
      remote.getGlobal('tab').activeFilename = tab.filename
      remote.getGlobal('tab').activeTitle = basename
    }
  },
  removeTab (state, tabId) {
    // keep check for index in this function to ensure tabid still exists
    let index = _.indexOf(state.tabs, tabId)
    if (index !== -1) {
      state.tabs.splice(index, 1)
    }
  },<commit_msg>OCC-247: removed extension from filename when converting to tab title.<commit_after>import {remote} from 'electron'
import path from 'path'
const state = {
  tabs: [],
  activeTab: '',
  tabObjects: {},
  tabIndex: -1,
  activeTitle: ''
}

const getters = {
  getTabs: state => {
    return state.tabs
  },
  getActiveTab: state => {
    return state.activeTab
  },
  getTabIndex: state => {
    return state.tabIndex
  },
  getPreviousTabId: (state, getters) => (position) => {
    let previousActiveTabPos = position < 1 ? 0 : position - 1
    return state.tabs[previousActiveTabPos]
  },
  tabTitle: (state, getters) => (tabId) => {
    console.log('getting title from tabs store')
    console.log(`tab id is: ${tabId}`)
    return _.get(state.tabObjects, `${tabId}.title`)
  }
}

const mutations = {
  pushTab (state, tabId) {
    console.log('...pushing...')
    state.tabs.push(tabId)
    console.log(state.tabs)
  },
  pushTabTitle(state, tab) {
    let title
    if (tab.title) {
      title = tab.title
    } else {
      title = `Untitled${tab.index}`
    }
    _.set(state.tabObjects, `${tab.id}.title`, title)
  },
  pushTabObject(state, tab) {
    console.log('logging tab on push tab object')
    console.log(tab)
    if (tab.filename) {
      _.set(state.tabObjects, `${tab.id}.filename`, tab.filename)
      // tab title should reflect basename minus extension of filename
      let fullPath = tab.filename
      let basename = path.basename(fullPath)
      let extension = path.extname(basename)
      let doctored = basename.substring(0, basename.lastIndexOf(extension))
      _.set(state.tabObjects, `${tab.id}.title`, doctored)
      // update global active references for electron-main
      remote.getGlobal('tab').activeFilename = tab.filename
      remote.getGlobal('tab').activeTitle = doctored
    }
  },
  removeTab (state, tabId) {
    // keep check for index in this function to ensure tabid still exists
    let index = _.indexOf(state.tabs, tabId)
    if (index !== -1) {
      state.tabs.splice(index, 1)
    }
  },
{'fraction_non_alphanumeric': 0.14470284237726097, 'fraction_numerical': 0.004134366925064599, 'mean_word_length': 2.958077709611452, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '4606978', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1254, 'n_words': 305}