<commit_before>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import {
  JupyterLab, JupyterLabPlugin
} from '@jupyterlab/application';

import {
  ILayoutRestorer
} from '@jupyterlab/apputils';

import {
  each
} from '@phosphor/algorithm';

import {
  TabBar
} from '@phosphor/widgets';


/**
 * The default tab manager extension.
 */
const plugin: JupyterLabPlugin<void> = {
  id: 'jupyter.extensions.tab-manager',
  activate: (app: JupyterLab, restorer: ILayoutRestorer): void => {
    const tabs = new TabBar({ orientation: 'vertical' });
    const populate = () => {
      tabs.clearTabs();
      each(app.shell.widgets('main'), widget => { tabs.addTab(widget.title); });
    };

    restorer.add(tabs, 'tab-manager');
    tabs.id = 'tab-manager';
    tabs.title.label = 'Tabs';
    populate();
    app.shell.activeChanged.connect(() => { tabs.update(); });
    app.shell.currentChanged.connect(() => { populate(); });
    app.shell.addToLeftArea(tabs, { rank: 600 });
  },
  autoStart: true,
  requires: [ILayoutRestorer]
};

<commit_msg>Implement tab manager behavior.<commit_after>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import {
  JupyterLab, JupyterLabPlugin
} from '@jupyterlab/application';

import {
  ILayoutRestorer
} from '@jupyterlab/apputils';

import {
  each
} from '@phosphor/algorithm';

import {
  TabBar, Widget
} from '@phosphor/widgets';


/**
 * The default tab manager extension.
 */
const plugin: JupyterLabPlugin<void> = {
  id: 'jupyter.extensions.tab-manager',
  activate: (app: JupyterLab, restorer: ILayoutRestorer): void => {
    const { commands, shell } = app;
    const tabs = new TabBar({ orientation: 'vertical' });
    const populate = () => {
      tabs.clearTabs();
      each(shell.widgets('main'), widget => { tabs.addTab(widget.title); });
    };

    restorer.add(tabs, 'tab-manager');
    tabs.id = 'tab-manager';
    tabs.title.label = 'Tabs';
    populate();
    shell.addToLeftArea(tabs, { rank: 600 });

    shell.activeChanged.connect(() => { tabs.update(); });
    shell.currentChanged.connect(() => { populate(); });
    tabs.tabActivateRequested.connect((sender, tab) => {
      const id = (tab.title.owner as Widget).id;

      // If the current widget is clicked, toggle shell mode.
      if (shell.currentWidget.id === id) {
        commands.execute('main-jupyterlab:toggle-mode');
        return;
      }

      // If a new tab is picked, switch to single-document mode and show it.
      commands.execute('main-jupyterlab:set-mode', { mode: 'single-document' })
        .then(() => { shell.activateById(id); });
    });
    tabs.tabCloseRequested.connect((sender, tab) => {
      (tab.title.owner as Widget).close();
    });
  },
  autoStart: true,
  requires: [ILayoutRestorer]
};


{'fraction_non_alphanumeric': 0.1608513607815771, 'fraction_numerical': 0.00209351011863224, 'mean_word_length': 3.403993855606759, 'pattern_counts': {'":': 0, '<': 5, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5205582', 'n_tokens_mistral': 973, 'n_tokens_neox': 922, 'n_words': 208}