<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as DOM from 'vs/base/browser/dom';
import { RunOnceScheduler } from 'vs/base/common/async';
import { Disposable } from 'vs/base/common/lifecycle';
import { CellEditState, IInsetRenderOutput, INotebookEditor, INotebookEditorContribution, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { registerNotebookContribution } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
import { BUILTIN_RENDERER_ID, CellKind, cellRangesToIndexes } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';

class NotebookClipboardContribution extends Disposable implements INotebookEditorContribution {
	static id: string = 'workbench.notebook.viewportCustomMarkdown';
	private readonly _warmupViewport: RunOnceScheduler;

	constructor(private readonly _notebookEditor: INotebookEditor,
		@INotebookService private readonly _notebookService: INotebookService) {
		super();

		this._warmupViewport = new RunOnceScheduler(() => this._warmupViewportNow(), 200);

		this._register(this._notebookEditor.onDidScroll(() => {
			this._warmupViewport.schedule();
		}));
	}

	private _warmupViewportNow() {
		const visibleRanges = this._notebookEditor.getVisibleRangesPlusViewportAboveBelow();
		cellRangesToIndexes(visibleRanges).forEach(index => {
			const cell = this._notebookEditor.viewModel?.viewCells[index];

			if (cell?.cellKind === CellKind.Markdown && cell?.editState === CellEditState.Preview) {
				this._notebookEditor.createMarkdownPreview(cell);<commit_msg>Don't warmup markdown preview when input is collapsed<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as DOM from 'vs/base/browser/dom';
import { RunOnceScheduler } from 'vs/base/common/async';
import { Disposable } from 'vs/base/common/lifecycle';
import { CellEditState, IInsetRenderOutput, INotebookEditor, INotebookEditorContribution, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { registerNotebookContribution } from 'vs/workbench/contrib/notebook/browser/notebookEditorExtensions';
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
import { BUILTIN_RENDERER_ID, CellKind, cellRangesToIndexes } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';

class NotebookClipboardContribution extends Disposable implements INotebookEditorContribution {
	static id: string = 'workbench.notebook.viewportCustomMarkdown';
	private readonly _warmupViewport: RunOnceScheduler;

	constructor(private readonly _notebookEditor: INotebookEditor,
		@INotebookService private readonly _notebookService: INotebookService) {
		super();

		this._warmupViewport = new RunOnceScheduler(() => this._warmupViewportNow(), 200);

		this._register(this._notebookEditor.onDidScroll(() => {
			this._warmupViewport.schedule();
		}));
	}

	private _warmupViewportNow() {
		const visibleRanges = this._notebookEditor.getVisibleRangesPlusViewportAboveBelow();
		cellRangesToIndexes(visibleRanges).forEach(index => {
			const cell = this._notebookEditor.viewModel?.viewCells[index];

			if (cell?.cellKind === CellKind.Markdown && cell?.editState === CellEditState.Preview && !cell.metadata?.inputCollapsed) {
				this._notebookEditor.createMarkdownPreview(cell);
{'fraction_non_alphanumeric': 0.18179669030732862, 'fraction_numerical': 0.0014184397163120568, 'mean_word_length': 3.8079545454545456, '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': '1379123', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1107, 'n_words': 221}