<commit_before>import { BrowserView, ipcMain } from 'electron';
import { TOOLBAR_HEIGHT } from '~/renderer/app/constants/design';
import { appWindow } from '.';

export class BrowserViewManager {
  public views: { [key: number]: BrowserView } = {};

  constructor() {
    ipcMain.on(
      'browserview-create',
      (e: Electron.IpcMessageEvent, tabId: number) => {
        this.create(tabId);

        appWindow.window.webContents.send(`browserview-created-${tabId}`);
      },
    );

    ipcMain.on(
      'browserview-select',
      (e: Electron.IpcMessageEvent, id: number) => {
        this.select(id);
      },
    );

    ipcMain.on(
      'browserview-remove',
      (e: Electron.IpcMessageEvent, id: number) => {
        this.remove(id);
      },
    );
  }

  public create(tabId: number) {
    const view = new BrowserView();
    view.setAutoResize({ width: true, height: true });
    view.webContents.loadURL('https://google.com');

    this.views[tabId] = view;
  }

  public select(tabId: number) {
    const view = this.views[tabId];

    if (!view || view.isDestroyed()) {
      appWindow.window.setBrowserView(null);
      return;
    }

    appWindow.window.setBrowserView(view);

    const { width, height } = appWindow.window.getBounds();
    view.setBounds({
      x: 0,
      y: TOOLBAR_HEIGHT + 1,
      width,
      height,
    });
  }
<commit_msg>Fix BrowserView size<commit_after>import { BrowserView, ipcMain } from 'electron';
import { TOOLBAR_HEIGHT } from '~/renderer/app/constants/design';
import { appWindow } from '.';

export class BrowserViewManager {
  public views: { [key: number]: BrowserView } = {};

  constructor() {
    ipcMain.on(
      'browserview-create',
      (e: Electron.IpcMessageEvent, tabId: number) => {
        this.create(tabId);

        appWindow.window.webContents.send(`browserview-created-${tabId}`);
      },
    );

    ipcMain.on(
      'browserview-select',
      (e: Electron.IpcMessageEvent, id: number) => {
        this.select(id);
      },
    );

    ipcMain.on(
      'browserview-remove',
      (e: Electron.IpcMessageEvent, id: number) => {
        this.remove(id);
      },
    );
  }

  public create(tabId: number) {
    const view = new BrowserView();
    view.setAutoResize({ width: true, height: true });
    view.webContents.loadURL('https://google.com');

    this.views[tabId] = view;
  }

  public select(tabId: number) {
    const view = this.views[tabId];

    if (!view || view.isDestroyed()) {
      appWindow.window.setBrowserView(null);
      return;
    }

    appWindow.window.setBrowserView(view);

    const { width, height } = appWindow.window.getContentBounds();
    view.setBounds({
      x: 0,
      y: TOOLBAR_HEIGHT + 1,
      width,
      height: height - TOOLBAR_HEIGHT,
    });
  }

{'fraction_non_alphanumeric': 0.15130871280028685, 'fraction_numerical': 0.0014342058085335247, 'mean_word_length': 2.6662286465177396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '1535099', 'n_tokens_mistral': 968, 'n_tokens_neox': 921, 'n_words': 168}