<commit_before>import {BrowserWindow, app, globalShortcut} from 'electron'
import {showDevTools, skipSecondaryDevtools} from '../shared/local-debug.desktop'

function setupDevToolsExtensions () {
  if (__DEV__ && process.env.KEYBASE_LOCAL_DEBUG) {
    if (process.env.KEYBASE_DEV_TOOL_EXTENSIONS) {
      process.env.KEYBASE_DEV_TOOL_EXTENSIONS.split(',').forEach(p => {
        BrowserWindow.addDevToolsExtension(p)
      })
    }
  }
}

function setupOpenDevtools () {
  let devToolsState = showDevTools

  globalShortcut.register('CommandOrControl+Alt+k+b', () => {
    devToolsState = !devToolsState
    if (devToolsState) {
      BrowserWindow.getAllWindows().map(bw => bw.webContents.openDevTools())
    } else {
      BrowserWindow.getAllWindows().map(bw => bw.webContents.closeDevTools())
    })
  })
}

function cleanupOpenDevtools () {
  globalShortcut.unregister('CommandOrControl+Alt+k+b')
}

export default function () {
  app.on('ready', () => {
    setupDevToolsExtensions()
    setupOpenDevtools()
  })

  app.on('will-quit', () => {
    cleanupOpenDevtools()
  })

  if (showDevTools) {
    app.on('browser-window-created', (e, win) => {
      win = win || BrowserWindow.getFocusedWindow()

      if (win) {
        win.webContents.addListener('did-navigate', () => {
          if (!skipSecondaryDevtools || win.webContents.getURL().indexOf('renderer/index.html') !== -1) {<commit_msg>Retesting for each window saves some duplicated code<commit_after>import {BrowserWindow, app, globalShortcut} from 'electron'
import {showDevTools, skipSecondaryDevtools} from '../shared/local-debug.desktop'

function setupDevToolsExtensions () {
  if (__DEV__ && process.env.KEYBASE_LOCAL_DEBUG) {
    if (process.env.KEYBASE_DEV_TOOL_EXTENSIONS) {
      process.env.KEYBASE_DEV_TOOL_EXTENSIONS.split(',').forEach(p => {
        BrowserWindow.addDevToolsExtension(p)
      })
    }
  }
}

function setupOpenDevtools () {
  let devToolsState = showDevTools

  globalShortcut.register('CommandOrControl+Alt+k+b', () => {
    devToolsState = !devToolsState
    BrowserWindow.getAllWindows().map(bw => devToolsState ? bw.webContents.openDevTools() : bw.webContents.closeDevTools())
  })
}

function cleanupOpenDevtools () {
  globalShortcut.unregister('CommandOrControl+Alt+k+b')
}

export default function () {
  app.on('ready', () => {
    setupDevToolsExtensions()
    setupOpenDevtools()
  })

  app.on('will-quit', () => {
    cleanupOpenDevtools()
  })

  if (showDevTools) {
    app.on('browser-window-created', (e, win) => {
      win = win || BrowserWindow.getFocusedWindow()

      if (win) {
        win.webContents.addListener('did-navigate', () => {
          if (!skipSecondaryDevtools || win.webContents.getURL().indexOf('renderer/index.html') !== -1) {
{'fraction_non_alphanumeric': 0.14925912540657751, 'fraction_numerical': 0.0007228044813877846, 'mean_word_length': 4.0510948905109485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '3915441', 'n_tokens_mistral': 907, 'n_tokens_neox': 875, 'n_words': 126}