<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

const electron = require('electron')
const app = electron.app
const Menu = require('menu')
const Shell = require('shell')

const init = () => {
  var template = [
    {
      label: 'File',
      submenu: [
        {
          label: 'New Tab',
          accelerator: 'CmdOrCtrl+T',
          click: function (item, focusedWindow) {
            focusedWindow.webContents.send('shortcut-new-frame')
          }
        }, {
          label: 'New Window',
          accelerator: 'CmdOrCtrl+N',
          click: () => process.emit('new-window')
        }, {
          type: 'separator'
        }, {
          label: 'Close Window',
          accelerator: 'CmdOrCtrl+Shift+W',
          click: () => process.emit('close-window')
        }, {
          label: 'Close Tab',
          accelerator: 'CmdOrCtrl+W',
          click: function (item, focusedWindow) {
            focusedWindow.webContents.send('shortcut-close-frame')
          }
        }<commit_msg>fix crash on new tab with no windows active<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

const electron = require('electron')
const app = electron.app
const Menu = require('menu')
const Shell = require('shell')

const init = () => {
  var template = [
    {
      label: 'File',
      submenu: [
        {
          label: 'New Tab',
          accelerator: 'CmdOrCtrl+T',
          click: function (item, focusedWindow) {
            if (focusedWindow) {
              focusedWindow.webContents.send('shortcut-new-frame')
            } else {
              // no active windows
              process.emit('new-window')
            }
          }
        }, {
          label: 'New Window',
          accelerator: 'CmdOrCtrl+N',
          click: () => process.emit('new-window')
        }, {
          type: 'separator'
        }, {
          label: 'Close Window',
          accelerator: 'CmdOrCtrl+Shift+W',
          click: () => process.emit('close-window')
        }, {
          label: 'Close Tab',
          accelerator: 'CmdOrCtrl+W',
          click: function (item, focusedWindow) {
            focusedWindow.webContents.send('shortcut-close-frame')
          }
        }
{'fraction_non_alphanumeric': 0.13122529644268774, 'fraction_numerical': 0.0031620553359683794, 'mean_word_length': 1.8925714285714286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '702936', 'n_tokens_mistral': 716, 'n_tokens_neox': 709, 'n_words': 195}