<commit_before>import {TabHeaderComponent, Props, Tab} from "./TabHeaderComponent";
import * as React from "react";
import * as _ from "lodash";
import {ipcRenderer} from "electron";
import {remote} from "electron";
import * as css from "./css/styles";
import {saveWindowBounds} from "./ViewUtils";
import {SearchComponent} from "./SearchComponent";
import {isMenuShortcut, isKeybindingForEvent} from "./keyevents/Keybindings";
import {KeyboardAction} from "../Enums";
import {UserEvent} from "../Interfaces";
import {isModifierKey} from "./ViewUtils";
import {TabComponent} from "./TabComponent";
import {FontService} from "../services/FontService";

type ApplicationState = {
    tabs: Tab[];
    focusedTabIndex: number;
};

export class ApplicationComponent extends React.Component<{}, ApplicationState> {
    constructor(props: {}) {
        super(props);
        // Necessary because "remote" does not exist in electron-mocha tests
        if (remote) {
            const electronWindow = remote.BrowserWindow.getAllWindows()[0];

            electronWindow
                .on("move", () => saveWindowBounds(electronWindow))
                .on("resize", () => {
                    saveWindowBounds(electronWindow);
                    this.recalculateDimensions();
                })
                .webContents
                .on("devtools-opened", () => this.recalculateDimensions())
                .on("devtools-closed", () => this.recalculateDimensions());

            ipcRenderer.on("change-working-directory", (_event: Event, directory: string) =>
                this.focusedTab.focusedPane.session.directory = directory,
            );

            FontService.instance.onChange(() => this.forceUpdate());

            window.onbeforeunload = () => {
                electronWindow
                    .removeAllListeners()
                    .webContents
                    .removeAllListeners("devtools-opened")
                    .removeAllListeners("devtools-closed")
                    .removeAllListeners("found-in-page");

                this.closeAllTabs();
            };<commit_msg>Recalculate dimensions on font change.<commit_after>import {TabHeaderComponent, Props, Tab} from "./TabHeaderComponent";
import * as React from "react";
import * as _ from "lodash";
import {ipcRenderer} from "electron";
import {remote} from "electron";
import * as css from "./css/styles";
import {saveWindowBounds} from "./ViewUtils";
import {SearchComponent} from "./SearchComponent";
import {isMenuShortcut, isKeybindingForEvent} from "./keyevents/Keybindings";
import {KeyboardAction} from "../Enums";
import {UserEvent} from "../Interfaces";
import {isModifierKey} from "./ViewUtils";
import {TabComponent} from "./TabComponent";
import {FontService} from "../services/FontService";

type ApplicationState = {
    tabs: Tab[];
    focusedTabIndex: number;
};

export class ApplicationComponent extends React.Component<{}, ApplicationState> {
    constructor(props: {}) {
        super(props);
        // Necessary because "remote" does not exist in electron-mocha tests
        if (remote) {
            const electronWindow = remote.BrowserWindow.getAllWindows()[0];

            electronWindow
                .on("move", () => saveWindowBounds(electronWindow))
                .on("resize", () => {
                    saveWindowBounds(electronWindow);
                    this.recalculateDimensions();
                })
                .webContents
                .on("devtools-opened", () => this.recalculateDimensions())
                .on("devtools-closed", () => this.recalculateDimensions());

            ipcRenderer.on("change-working-directory", (_event: Event, directory: string) =>
                this.focusedTab.focusedPane.session.directory = directory,
            );

            FontService.instance.onChange(() => {
                this.forceUpdate();
                this.recalculateDimensions();
            });

            window.onbeforeunload = () => {
                electronWindow
                    .removeAllListeners()
                    .webContents
                    .removeAllListeners("devtools-opened")
                    .removeAllListeners("devtools-closed")
                    .removeAllListeners("found-in-page");

                this.closeAllTabs();
            };
{'fraction_non_alphanumeric': 0.12764976958525345, 'fraction_numerical': 0.0004608294930875576, 'mean_word_length': 2.3443759630200307, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '2629169', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1054, 'n_words': 239}