Path: blob/main/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Schemas } from '../../../../base/common/network.js';6import { IDisposable, Disposable, DisposableStore, dispose } from '../../../../base/common/lifecycle.js';7import { parse } from '../../../../base/common/marshalling.js';8import { extname, isEqual } from '../../../../base/common/resources.js';9import { assertType } from '../../../../base/common/types.js';10import { URI } from '../../../../base/common/uri.js';11import { toFormattedString } from '../../../../base/common/jsonFormatter.js';12import { ITextModel, ITextBufferFactory, ITextBuffer } from '../../../../editor/common/model.js';13import { IModelService } from '../../../../editor/common/services/model.js';14import { ILanguageSelection, ILanguageService } from '../../../../editor/common/languages/language.js';15import { ITextModelContentProvider, ITextModelService } from '../../../../editor/common/services/resolverService.js';16import * as nls from '../../../../nls.js';17import { Extensions, IConfigurationPropertySchema, IConfigurationRegistry } from '../../../../platform/configuration/common/configurationRegistry.js';18import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js';19import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';20import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';21import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js';22import { Registry } from '../../../../platform/registry/common/platform.js';23import { EditorPaneDescriptor, IEditorPaneRegistry } from '../../../browser/editor.js';24import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry, WorkbenchPhase, registerWorkbenchContribution2 } from '../../../common/contributions.js';25import { IEditorSerializer, IEditorFactoryRegistry, EditorExtensions } from '../../../common/editor.js';26import { EditorInput } from '../../../common/editor/editorInput.js';27import { NotebookEditor } from './notebookEditor.js';28import { NotebookEditorInput, NotebookEditorInputOptions } from '../common/notebookEditorInput.js';29import { INotebookService } from '../common/notebookService.js';30import { NotebookService } from './services/notebookServiceImpl.js';31import { CellKind, CellUri, IResolvedNotebookEditorModel, NotebookWorkingCopyTypeIdentifier, NotebookSetting, ICellOutput, ICell, NotebookCellsChangeType, NotebookMetadataUri } from '../common/notebookCommon.js';32import { IEditorService } from '../../../services/editor/common/editorService.js';33import { IUndoRedoService } from '../../../../platform/undoRedo/common/undoRedo.js';34import { INotebookEditorModelResolverService } from '../common/notebookEditorModelResolverService.js';35import { NotebookDiffEditorInput } from '../common/notebookDiffEditorInput.js';36import { NotebookTextDiffEditor } from './diff/notebookDiffEditor.js';37import { INotebookEditorWorkerService } from '../common/services/notebookWorkerService.js';38import { NotebookEditorWorkerServiceImpl } from './services/notebookWorkerServiceImpl.js';39import { INotebookCellStatusBarService } from '../common/notebookCellStatusBarService.js';40import { NotebookCellStatusBarService } from './services/notebookCellStatusBarServiceImpl.js';41import { INotebookEditorService } from './services/notebookEditorService.js';42import { NotebookEditorWidgetService } from './services/notebookEditorServiceImpl.js';43import { IJSONContributionRegistry, Extensions as JSONExtensions } from '../../../../platform/jsonschemas/common/jsonContributionRegistry.js';44import { IJSONSchema, IJSONSchemaMap } from '../../../../base/common/jsonSchema.js';45import { Event } from '../../../../base/common/event.js';46import { getFormattedOutputJSON, getStreamOutputData } from './diff/diffElementViewModel.js';47import { NotebookModelResolverServiceImpl } from '../common/notebookEditorModelResolverServiceImpl.js';48import { INotebookKernelHistoryService, INotebookKernelService } from '../common/notebookKernelService.js';49import { NotebookKernelService } from './services/notebookKernelServiceImpl.js';50import { IWorkingCopyIdentifier } from '../../../services/workingCopy/common/workingCopy.js';51import { IResourceEditorInput } from '../../../../platform/editor/common/editor.js';52import { IExtensionService } from '../../../services/extensions/common/extensions.js';53import { IWorkingCopyEditorHandler, IWorkingCopyEditorService } from '../../../services/workingCopy/common/workingCopyEditorService.js';54import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';55import { ILabelService } from '../../../../platform/label/common/label.js';56import { IEditorGroupsService } from '../../../services/editor/common/editorGroupsService.js';57import { NotebookRendererMessagingService } from './services/notebookRendererMessagingServiceImpl.js';58import { INotebookRendererMessagingService } from '../common/notebookRendererMessagingService.js';59import { INotebookCellOutlineDataSourceFactory, NotebookCellOutlineDataSourceFactory } from './viewModel/notebookOutlineDataSourceFactory.js';6061// Editor Controller62import './controller/coreActions.js';63import './controller/insertCellActions.js';64import './controller/executeActions.js';65import './controller/sectionActions.js';66import './controller/layoutActions.js';67import './controller/editActions.js';68import './controller/cellOutputActions.js';69import './controller/apiActions.js';70import './controller/foldingController.js';71import './controller/chat/notebook.chat.contribution.js';72import './controller/variablesActions.js';7374// Editor Contribution75import './contrib/editorHint/emptyCellEditorHint.js';76import './contrib/clipboard/notebookClipboard.js';77import './contrib/find/notebookFind.js';78import './contrib/format/formatting.js';79import './contrib/saveParticipants/saveParticipants.js';80import './contrib/gettingStarted/notebookGettingStarted.js';81import './contrib/layout/layoutActions.js';82import './contrib/marker/markerProvider.js';83import './contrib/navigation/arrow.js';84import './contrib/outline/notebookOutline.js';85import './contrib/profile/notebookProfile.js';86import './contrib/cellStatusBar/statusBarProviders.js';87import './contrib/cellStatusBar/contributedStatusBarItemController.js';88import './contrib/cellStatusBar/executionStatusBarItemController.js';89import './contrib/editorStatusBar/editorStatusBar.js';90import './contrib/undoRedo/notebookUndoRedo.js';91import './contrib/cellCommands/cellCommands.js';92import './contrib/viewportWarmup/viewportWarmup.js';93import './contrib/troubleshoot/layout.js';94import './contrib/debug/notebookBreakpoints.js';95import './contrib/debug/notebookCellPausing.js';96import './contrib/debug/notebookDebugDecorations.js';97import './contrib/execute/executionEditorProgress.js';98import './contrib/kernelDetection/notebookKernelDetection.js';99import './contrib/cellDiagnostics/cellDiagnostics.js';100import './contrib/multicursor/notebookMulticursor.js';101import './contrib/multicursor/notebookSelectionHighlight.js';102import './contrib/notebookVariables/notebookInlineVariables.js';103104// Diff Editor Contribution105import './diff/notebookDiffActions.js';106107// Services108import { editorOptionsRegistry } from '../../../../editor/common/config/editorOptions.js';109import { NotebookExecutionStateService } from './services/notebookExecutionStateServiceImpl.js';110import { NotebookExecutionService } from './services/notebookExecutionServiceImpl.js';111import { INotebookExecutionService } from '../common/notebookExecutionService.js';112import { INotebookKeymapService } from '../common/notebookKeymapService.js';113import { NotebookKeymapService } from './services/notebookKeymapServiceImpl.js';114import { PLAINTEXT_LANGUAGE_ID } from '../../../../editor/common/languages/modesRegistry.js';115import { INotebookExecutionStateService } from '../common/notebookExecutionStateService.js';116import { ILanguageFeaturesService } from '../../../../editor/common/services/languageFeatures.js';117import { NotebookInfo } from '../../../../editor/common/languageFeatureRegistry.js';118import { COMMENTEDITOR_DECORATION_KEY } from '../../comments/browser/commentReply.js';119import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';120import { NotebookKernelHistoryService } from './services/notebookKernelHistoryServiceImpl.js';121import { INotebookLoggingService } from '../common/notebookLoggingService.js';122import { NotebookLoggingService } from './services/notebookLoggingServiceImpl.js';123import product from '../../../../platform/product/common/product.js';124import { NotebookVariables } from './contrib/notebookVariables/notebookVariables.js';125import { AccessibleViewRegistry } from '../../../../platform/accessibility/browser/accessibleViewRegistry.js';126import { NotebookAccessibilityHelp } from './notebookAccessibilityHelp.js';127import { NotebookAccessibleView } from './notebookAccessibleView.js';128import { DefaultFormatter } from '../../format/browser/formatActionsMultiple.js';129import { NotebookMultiTextDiffEditor } from './diff/notebookMultiDiffEditor.js';130import { NotebookMultiDiffEditorInput } from './diff/notebookMultiDiffEditorInput.js';131import { getFormattedMetadataJSON } from '../common/model/notebookCellTextModel.js';132import { INotebookOutlineEntryFactory, NotebookOutlineEntryFactory } from './viewModel/notebookOutlineEntryFactory.js';133import { getFormattedNotebookMetadataJSON } from '../common/model/notebookMetadataTextModel.js';134import { NotebookOutputEditor } from './outputEditor/notebookOutputEditor.js';135import { NotebookOutputEditorInput } from './outputEditor/notebookOutputEditorInput.js';136137/*--------------------------------------------------------------------------------------------- */138139Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(140EditorPaneDescriptor.create(141NotebookEditor,142NotebookEditor.ID,143'Notebook Editor'144),145[146new SyncDescriptor(NotebookEditorInput)147]148);149150Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(151EditorPaneDescriptor.create(152NotebookTextDiffEditor,153NotebookTextDiffEditor.ID,154'Notebook Diff Editor'155),156[157new SyncDescriptor(NotebookDiffEditorInput)158]159);160161Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(162EditorPaneDescriptor.create(163NotebookOutputEditor,164NotebookOutputEditor.ID,165'Notebook Output Editor'166),167[168new SyncDescriptor(NotebookOutputEditorInput)169]170);171172Registry.as<IEditorPaneRegistry>(EditorExtensions.EditorPane).registerEditorPane(173EditorPaneDescriptor.create(174NotebookMultiTextDiffEditor,175NotebookMultiTextDiffEditor.ID,176'Notebook Diff Editor'177),178[179new SyncDescriptor(NotebookMultiDiffEditorInput)180]181);182183class NotebookDiffEditorSerializer implements IEditorSerializer {184constructor(@IConfigurationService private readonly _configurationService: IConfigurationService) { }185canSerialize(): boolean {186return true;187}188189serialize(input: EditorInput): string {190assertType(input instanceof NotebookDiffEditorInput);191return JSON.stringify({192resource: input.resource,193originalResource: input.original.resource,194name: input.getName(),195originalName: input.original.getName(),196textDiffName: input.getName(),197viewType: input.viewType,198});199}200201deserialize(instantiationService: IInstantiationService, raw: string) {202type Data = { resource: URI; originalResource: URI; name: string; originalName: string; viewType: string; textDiffName: string | undefined; group: number };203const data = <Data>parse(raw);204if (!data) {205return undefined;206}207const { resource, originalResource, name, viewType } = data;208if (!data || !URI.isUri(resource) || !URI.isUri(originalResource) || typeof name !== 'string' || typeof viewType !== 'string') {209return undefined;210}211212if (this._configurationService.getValue('notebook.experimental.enableNewDiffEditor')) {213return NotebookMultiDiffEditorInput.create(instantiationService, resource, name, undefined, originalResource, viewType);214} else {215return NotebookDiffEditorInput.create(instantiationService, resource, name, undefined, originalResource, viewType);216}217}218219static canResolveBackup(editorInput: EditorInput, backupResource: URI): boolean {220return false;221}222223}224type SerializedNotebookEditorData = { resource: URI; preferredResource: URI; viewType: string; options?: NotebookEditorInputOptions };225class NotebookEditorSerializer implements IEditorSerializer {226canSerialize(input: EditorInput): boolean {227return input.typeId === NotebookEditorInput.ID;228}229serialize(input: EditorInput): string {230assertType(input instanceof NotebookEditorInput);231const data: SerializedNotebookEditorData = {232resource: input.resource,233preferredResource: input.preferredResource,234viewType: input.viewType,235options: input.options236};237return JSON.stringify(data);238}239deserialize(instantiationService: IInstantiationService, raw: string) {240const data = <SerializedNotebookEditorData>parse(raw);241if (!data) {242return undefined;243}244const { resource, preferredResource, viewType, options } = data;245if (!data || !URI.isUri(resource) || typeof viewType !== 'string') {246return undefined;247}248249const input = NotebookEditorInput.getOrCreate(instantiationService, resource, preferredResource, viewType, options);250return input;251}252}253254export type SerializedNotebookOutputEditorData = { notebookUri: URI; cellIndex: number; outputIndex: number };255class NotebookOutputEditorSerializer implements IEditorSerializer {256canSerialize(input: EditorInput): boolean {257return input.typeId === NotebookOutputEditorInput.ID;258}259serialize(input: EditorInput): string | undefined {260assertType(input instanceof NotebookOutputEditorInput);261262const data = input.getSerializedData(); // in case of cell movement etc get latest indices263if (!data) {264return undefined;265}266267return JSON.stringify(data);268}269deserialize(instantiationService: IInstantiationService, raw: string): EditorInput | undefined {270const data = <SerializedNotebookOutputEditorData>parse(raw);271if (!data) {272return undefined;273}274275const input = instantiationService.createInstance(NotebookOutputEditorInput, data.notebookUri, data.cellIndex, undefined, data.outputIndex);276return input;277}278}279280Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(281NotebookEditorInput.ID,282NotebookEditorSerializer283);284285Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(286NotebookDiffEditorInput.ID,287NotebookDiffEditorSerializer288);289290Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory).registerEditorSerializer(291NotebookOutputEditorInput.ID,292NotebookOutputEditorSerializer293);294295export class NotebookContribution extends Disposable implements IWorkbenchContribution {296297static readonly ID = 'workbench.contrib.notebook';298299private _uriComparisonKeyComputer?: IDisposable;300301constructor(302@IUndoRedoService undoRedoService: IUndoRedoService,303@IConfigurationService configurationService: IConfigurationService,304@ICodeEditorService private readonly codeEditorService: ICodeEditorService,305) {306super();307308this.updateCellUndoRedoComparisonKey(configurationService, undoRedoService);309310// Watch for changes to undoRedoPerCell setting311this._register(configurationService.onDidChangeConfiguration(e => {312if (e.affectsConfiguration(NotebookSetting.undoRedoPerCell)) {313this.updateCellUndoRedoComparisonKey(configurationService, undoRedoService);314}315}));316317// register comment decoration318this.codeEditorService.registerDecorationType('comment-controller', COMMENTEDITOR_DECORATION_KEY, {});319}320321// Add or remove the cell undo redo comparison key based on the user setting322private updateCellUndoRedoComparisonKey(configurationService: IConfigurationService, undoRedoService: IUndoRedoService) {323const undoRedoPerCell = configurationService.getValue<boolean>(NotebookSetting.undoRedoPerCell);324325if (!undoRedoPerCell) {326// Add comparison key to map cell => main document327if (!this._uriComparisonKeyComputer) {328this._uriComparisonKeyComputer = undoRedoService.registerUriComparisonKeyComputer(CellUri.scheme, {329getComparisonKey: (uri: URI): string => {330if (undoRedoPerCell) {331return uri.toString();332}333return NotebookContribution._getCellUndoRedoComparisonKey(uri);334}335});336}337} else {338// Dispose comparison key339this._uriComparisonKeyComputer?.dispose();340this._uriComparisonKeyComputer = undefined;341}342}343344private static _getCellUndoRedoComparisonKey(uri: URI) {345const data = CellUri.parse(uri);346if (!data) {347return uri.toString();348}349350return data.notebook.toString();351}352353override dispose(): void {354super.dispose();355this._uriComparisonKeyComputer?.dispose();356}357}358359class CellContentProvider implements ITextModelContentProvider {360361static readonly ID = 'workbench.contrib.cellContentProvider';362363private readonly _registration: IDisposable;364365constructor(366@ITextModelService textModelService: ITextModelService,367@IModelService private readonly _modelService: IModelService,368@ILanguageService private readonly _languageService: ILanguageService,369@INotebookEditorModelResolverService private readonly _notebookModelResolverService: INotebookEditorModelResolverService,370) {371this._registration = textModelService.registerTextModelContentProvider(CellUri.scheme, this);372}373374dispose(): void {375this._registration.dispose();376}377378async provideTextContent(resource: URI): Promise<ITextModel | null> {379const existing = this._modelService.getModel(resource);380if (existing) {381return existing;382}383const data = CellUri.parse(resource);384// const data = parseCellUri(resource);385if (!data) {386return null;387}388389const ref = await this._notebookModelResolverService.resolve(data.notebook);390let result: ITextModel | null = null;391392if (!ref.object.isResolved()) {393return null;394}395396for (const cell of ref.object.notebook.cells) {397if (cell.uri.toString() === resource.toString()) {398const bufferFactory: ITextBufferFactory = {399create: (defaultEOL) => {400return { textBuffer: cell.textBuffer as ITextBuffer, disposable: Disposable.None };401},402getFirstLineText: (limit: number) => {403return cell.textBuffer.getLineContent(1).substring(0, limit);404}405};406const languageId = this._languageService.getLanguageIdByLanguageName(cell.language);407const languageSelection = languageId ? this._languageService.createById(languageId) : (cell.cellKind === CellKind.Markup ? this._languageService.createById('markdown') : this._languageService.createByFilepathOrFirstLine(resource, cell.textBuffer.getLineContent(1)));408result = this._modelService.createModel(409bufferFactory,410languageSelection,411resource412);413break;414}415}416417if (!result) {418ref.dispose();419return null;420}421422const once = Event.any(result.onWillDispose, ref.object.notebook.onWillDispose)(() => {423once.dispose();424ref.dispose();425});426427return result;428}429}430431class CellInfoContentProvider {432433static readonly ID = 'workbench.contrib.cellInfoContentProvider';434435private readonly _disposables: IDisposable[] = [];436437constructor(438@ITextModelService textModelService: ITextModelService,439@IModelService private readonly _modelService: IModelService,440@ILanguageService private readonly _languageService: ILanguageService,441@ILabelService private readonly _labelService: ILabelService,442@INotebookEditorModelResolverService private readonly _notebookModelResolverService: INotebookEditorModelResolverService,443) {444this._disposables.push(textModelService.registerTextModelContentProvider(Schemas.vscodeNotebookCellMetadata, {445provideTextContent: this.provideMetadataTextContent.bind(this)446}));447448this._disposables.push(textModelService.registerTextModelContentProvider(Schemas.vscodeNotebookCellOutput, {449provideTextContent: this.provideOutputTextContent.bind(this)450}));451452this._disposables.push(this._labelService.registerFormatter({453scheme: Schemas.vscodeNotebookCellMetadata,454formatting: {455label: '${path} (metadata)',456separator: '/'457}458}));459460this._disposables.push(this._labelService.registerFormatter({461scheme: Schemas.vscodeNotebookCellOutput,462formatting: {463label: '${path} (output)',464separator: '/'465}466}));467}468469dispose(): void {470dispose(this._disposables);471}472473async provideMetadataTextContent(resource: URI): Promise<ITextModel | null> {474const existing = this._modelService.getModel(resource);475if (existing) {476return existing;477}478479const data = CellUri.parseCellPropertyUri(resource, Schemas.vscodeNotebookCellMetadata);480if (!data) {481return null;482}483484const ref = await this._notebookModelResolverService.resolve(data.notebook);485let result: ITextModel | null = null;486487const mode = this._languageService.createById('json');488const disposables = new DisposableStore();489for (const cell of ref.object.notebook.cells) {490if (cell.handle === data.handle) {491const cellIndex = ref.object.notebook.cells.indexOf(cell);492const metadataSource = getFormattedMetadataJSON(ref.object.notebook.transientOptions.transientCellMetadata, cell.metadata, cell.language, true);493result = this._modelService.createModel(494metadataSource,495mode,496resource497);498this._disposables.push(disposables.add(ref.object.notebook.onDidChangeContent(e => {499if (result && e.rawEvents.some(event => (event.kind === NotebookCellsChangeType.ChangeCellMetadata || event.kind === NotebookCellsChangeType.ChangeCellLanguage) && event.index === cellIndex)) {500const value = getFormattedMetadataJSON(ref.object.notebook.transientOptions.transientCellMetadata, cell.metadata, cell.language, true);501if (result.getValue() !== value) {502result.setValue(value);503}504}505})));506break;507}508}509510if (!result) {511ref.dispose();512return null;513}514515const once = result.onWillDispose(() => {516disposables.dispose();517once.dispose();518ref.dispose();519});520521return result;522}523524private parseStreamOutput(op?: ICellOutput): { content: string; mode: ILanguageSelection } | undefined {525if (!op) {526return;527}528529const streamOutputData = getStreamOutputData(op.outputs);530if (streamOutputData) {531return {532content: streamOutputData,533mode: this._languageService.createById(PLAINTEXT_LANGUAGE_ID)534};535}536537return;538}539540private _getResult(data: {541notebook: URI;542outputId?: string | undefined;543}, cell: ICell) {544let result: { content: string; mode: ILanguageSelection } | undefined = undefined;545546const mode = this._languageService.createById('json');547const op = cell.outputs.find(op => op.outputId === data.outputId || op.alternativeOutputId === data.outputId);548const streamOutputData = this.parseStreamOutput(op);549if (streamOutputData) {550result = streamOutputData;551return result;552}553554const obj = cell.outputs.map(output => ({555metadata: output.metadata,556outputItems: output.outputs.map(opit => ({557mimeType: opit.mime,558data: opit.data.toString()559}))560}));561562const outputSource = toFormattedString(obj, {});563result = {564content: outputSource,565mode566};567568return result;569}570571async provideOutputsTextContent(resource: URI): Promise<ITextModel | null> {572const existing = this._modelService.getModel(resource);573if (existing) {574return existing;575}576577const data = CellUri.parseCellPropertyUri(resource, Schemas.vscodeNotebookCellOutput);578if (!data) {579return null;580}581582const ref = await this._notebookModelResolverService.resolve(data.notebook);583const cell = ref.object.notebook.cells.find(cell => cell.handle === data.handle);584585if (!cell) {586ref.dispose();587return null;588}589590const mode = this._languageService.createById('json');591const model = this._modelService.createModel(getFormattedOutputJSON(cell.outputs || []), mode, resource, true);592const cellModelListener = Event.any(cell.onDidChangeOutputs ?? Event.None, cell.onDidChangeOutputItems ?? Event.None)(() => {593model.setValue(getFormattedOutputJSON(cell.outputs || []));594});595596const once = model.onWillDispose(() => {597once.dispose();598cellModelListener.dispose();599ref.dispose();600});601602return model;603}604605async provideOutputTextContent(resource: URI): Promise<ITextModel | null> {606const existing = this._modelService.getModel(resource);607if (existing) {608return existing;609}610611const data = CellUri.parseCellOutputUri(resource);612if (!data) {613return this.provideOutputsTextContent(resource);614}615616const ref = await this._notebookModelResolverService.resolve(data.notebook);617const cell = ref.object.notebook.cells.find(cell => !!cell.outputs.find(op => op.outputId === data.outputId || op.alternativeOutputId === data.outputId));618619if (!cell) {620ref.dispose();621return null;622}623624const result = this._getResult(data, cell);625626if (!result) {627ref.dispose();628return null;629}630631const model = this._modelService.createModel(result.content, result.mode, resource);632const cellModelListener = Event.any(cell.onDidChangeOutputs ?? Event.None, cell.onDidChangeOutputItems ?? Event.None)(() => {633const newResult = this._getResult(data, cell);634635if (!newResult) {636return;637}638639model.setValue(newResult.content);640model.setLanguage(newResult.mode.languageId);641});642643const once = model.onWillDispose(() => {644once.dispose();645cellModelListener.dispose();646ref.dispose();647});648649return model;650}651}652653class NotebookMetadataContentProvider {654static readonly ID = 'workbench.contrib.notebookMetadataContentProvider';655656private readonly _disposables: IDisposable[] = [];657658constructor(659@ITextModelService textModelService: ITextModelService,660@IModelService private readonly _modelService: IModelService,661@ILanguageService private readonly _languageService: ILanguageService,662@ILabelService private readonly _labelService: ILabelService,663@INotebookEditorModelResolverService private readonly _notebookModelResolverService: INotebookEditorModelResolverService,664) {665this._disposables.push(textModelService.registerTextModelContentProvider(Schemas.vscodeNotebookMetadata, {666provideTextContent: this.provideMetadataTextContent.bind(this)667}));668669this._disposables.push(this._labelService.registerFormatter({670scheme: Schemas.vscodeNotebookMetadata,671formatting: {672label: '${path} (metadata)',673separator: '/'674}675}));676}677678dispose(): void {679dispose(this._disposables);680}681682async provideMetadataTextContent(resource: URI): Promise<ITextModel | null> {683const existing = this._modelService.getModel(resource);684if (existing) {685return existing;686}687688const data = NotebookMetadataUri.parse(resource);689if (!data) {690return null;691}692693const ref = await this._notebookModelResolverService.resolve(data);694let result: ITextModel | null = null;695696const mode = this._languageService.createById('json');697const disposables = new DisposableStore();698const metadataSource = getFormattedNotebookMetadataJSON(ref.object.notebook.transientOptions.transientDocumentMetadata, ref.object.notebook.metadata);699result = this._modelService.createModel(700metadataSource,701mode,702resource703);704705if (!result) {706ref.dispose();707return null;708}709710this._disposables.push(disposables.add(ref.object.notebook.onDidChangeContent(e => {711if (result && e.rawEvents.some(event => (event.kind === NotebookCellsChangeType.ChangeCellContent || event.kind === NotebookCellsChangeType.ChangeDocumentMetadata || event.kind === NotebookCellsChangeType.ModelChange))) {712const value = getFormattedNotebookMetadataJSON(ref.object.notebook.transientOptions.transientDocumentMetadata, ref.object.notebook.metadata);713if (result.getValue() !== value) {714result.setValue(value);715}716}717})));718719const once = result.onWillDispose(() => {720disposables.dispose();721once.dispose();722ref.dispose();723});724725return result;726}727}728729class RegisterSchemasContribution extends Disposable implements IWorkbenchContribution {730731static readonly ID = 'workbench.contrib.registerCellSchemas';732733constructor() {734super();735this.registerMetadataSchemas();736}737738private registerMetadataSchemas(): void {739const jsonRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);740const metadataSchema: IJSONSchema = {741properties: {742['language']: {743type: 'string',744description: 'The language for the cell'745}746},747// patternProperties: allSettings.patternProperties,748additionalProperties: true,749allowTrailingCommas: true,750allowComments: true751};752753jsonRegistry.registerSchema('vscode://schemas/notebook/cellmetadata', metadataSchema);754}755}756757class NotebookEditorManager implements IWorkbenchContribution {758759static readonly ID = 'workbench.contrib.notebookEditorManager';760761private readonly _disposables = new DisposableStore();762763constructor(764@IEditorService private readonly _editorService: IEditorService,765@INotebookEditorModelResolverService private readonly _notebookEditorModelService: INotebookEditorModelResolverService,766@IEditorGroupsService editorGroups: IEditorGroupsService767) {768// OPEN notebook editor for models that have turned dirty without being visible in an editor769type E = IResolvedNotebookEditorModel;770this._disposables.add(Event.debounce<E, E[]>(771this._notebookEditorModelService.onDidChangeDirty,772(last, current) => !last ? [current] : [...last, current],773100774)(this._openMissingDirtyNotebookEditors, this));775776// CLOSE editors when we are about to open conflicting notebooks777this._disposables.add(_notebookEditorModelService.onWillFailWithConflict(e => {778for (const group of editorGroups.groups) {779const conflictInputs = group.editors.filter(input => input instanceof NotebookEditorInput && input.viewType !== e.viewType && isEqual(input.resource, e.resource));780const p = group.closeEditors(conflictInputs);781e.waitUntil(p);782}783}));784}785786dispose(): void {787this._disposables.dispose();788}789790private _openMissingDirtyNotebookEditors(models: IResolvedNotebookEditorModel[]): void {791const result: IResourceEditorInput[] = [];792for (const model of models) {793if (model.isDirty() && !this._editorService.isOpened({ resource: model.resource, typeId: NotebookEditorInput.ID, editorId: model.viewType }) && extname(model.resource) !== '.interactive') {794result.push({795resource: model.resource,796options: { inactive: true, preserveFocus: true, pinned: true, override: model.viewType }797});798}799}800if (result.length > 0) {801this._editorService.openEditors(result);802}803}804}805806class SimpleNotebookWorkingCopyEditorHandler extends Disposable implements IWorkbenchContribution, IWorkingCopyEditorHandler {807808static readonly ID = 'workbench.contrib.simpleNotebookWorkingCopyEditorHandler';809810constructor(811@IInstantiationService private readonly _instantiationService: IInstantiationService,812@IWorkingCopyEditorService private readonly _workingCopyEditorService: IWorkingCopyEditorService,813@IExtensionService private readonly _extensionService: IExtensionService,814@INotebookService private readonly _notebookService: INotebookService815) {816super();817818this._installHandler();819}820821async handles(workingCopy: IWorkingCopyIdentifier): Promise<boolean> {822const viewType = this.handlesSync(workingCopy);823if (!viewType) {824return false;825}826827return this._notebookService.canResolve(viewType);828}829830private handlesSync(workingCopy: IWorkingCopyIdentifier): string /* viewType */ | undefined {831const viewType = this._getViewType(workingCopy);832if (!viewType || viewType === 'interactive') {833return undefined;834}835836return viewType;837}838839isOpen(workingCopy: IWorkingCopyIdentifier, editor: EditorInput): boolean {840if (!this.handlesSync(workingCopy)) {841return false;842}843844return editor instanceof NotebookEditorInput && editor.viewType === this._getViewType(workingCopy) && isEqual(workingCopy.resource, editor.resource);845}846847createEditor(workingCopy: IWorkingCopyIdentifier): EditorInput {848return NotebookEditorInput.getOrCreate(this._instantiationService, workingCopy.resource, undefined, this._getViewType(workingCopy)!);849}850851private async _installHandler(): Promise<void> {852await this._extensionService.whenInstalledExtensionsRegistered();853854this._register(this._workingCopyEditorService.registerHandler(this));855}856857private _getViewType(workingCopy: IWorkingCopyIdentifier) {858const notebookType = NotebookWorkingCopyTypeIdentifier.parse(workingCopy.typeId);859if (notebookType && notebookType.viewType === notebookType.notebookType) {860return notebookType?.viewType;861}862return undefined;863}864}865866class NotebookLanguageSelectorScoreRefine {867868static readonly ID = 'workbench.contrib.notebookLanguageSelectorScoreRefine';869870constructor(871@INotebookService private readonly _notebookService: INotebookService,872@ILanguageFeaturesService languageFeaturesService: ILanguageFeaturesService,873) {874languageFeaturesService.setNotebookTypeResolver(this._getNotebookInfo.bind(this));875}876877private _getNotebookInfo(uri: URI): NotebookInfo | undefined {878const cellUri = CellUri.parse(uri);879if (!cellUri) {880return undefined;881}882const notebook = this._notebookService.getNotebookTextModel(cellUri.notebook);883if (!notebook) {884return undefined;885}886return {887uri: notebook.uri,888type: notebook.viewType889};890}891}892893const workbenchContributionsRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);894registerWorkbenchContribution2(NotebookContribution.ID, NotebookContribution, WorkbenchPhase.BlockStartup);895registerWorkbenchContribution2(CellContentProvider.ID, CellContentProvider, WorkbenchPhase.BlockStartup);896registerWorkbenchContribution2(CellInfoContentProvider.ID, CellInfoContentProvider, WorkbenchPhase.BlockStartup);897registerWorkbenchContribution2(NotebookMetadataContentProvider.ID, NotebookMetadataContentProvider, WorkbenchPhase.BlockStartup);898registerWorkbenchContribution2(RegisterSchemasContribution.ID, RegisterSchemasContribution, WorkbenchPhase.BlockStartup);899registerWorkbenchContribution2(NotebookEditorManager.ID, NotebookEditorManager, WorkbenchPhase.BlockRestore);900registerWorkbenchContribution2(NotebookLanguageSelectorScoreRefine.ID, NotebookLanguageSelectorScoreRefine, WorkbenchPhase.BlockRestore);901registerWorkbenchContribution2(SimpleNotebookWorkingCopyEditorHandler.ID, SimpleNotebookWorkingCopyEditorHandler, WorkbenchPhase.BlockRestore);902workbenchContributionsRegistry.registerWorkbenchContribution(NotebookVariables, LifecyclePhase.Eventually);903904AccessibleViewRegistry.register(new NotebookAccessibleView());905AccessibleViewRegistry.register(new NotebookAccessibilityHelp());906907registerSingleton(INotebookService, NotebookService, InstantiationType.Delayed);908registerSingleton(INotebookEditorWorkerService, NotebookEditorWorkerServiceImpl, InstantiationType.Delayed);909registerSingleton(INotebookEditorModelResolverService, NotebookModelResolverServiceImpl, InstantiationType.Delayed);910registerSingleton(INotebookCellStatusBarService, NotebookCellStatusBarService, InstantiationType.Delayed);911registerSingleton(INotebookEditorService, NotebookEditorWidgetService, InstantiationType.Delayed);912registerSingleton(INotebookKernelService, NotebookKernelService, InstantiationType.Delayed);913registerSingleton(INotebookKernelHistoryService, NotebookKernelHistoryService, InstantiationType.Delayed);914registerSingleton(INotebookExecutionService, NotebookExecutionService, InstantiationType.Delayed);915registerSingleton(INotebookExecutionStateService, NotebookExecutionStateService, InstantiationType.Delayed);916registerSingleton(INotebookRendererMessagingService, NotebookRendererMessagingService, InstantiationType.Delayed);917registerSingleton(INotebookKeymapService, NotebookKeymapService, InstantiationType.Delayed);918registerSingleton(INotebookLoggingService, NotebookLoggingService, InstantiationType.Delayed);919registerSingleton(INotebookCellOutlineDataSourceFactory, NotebookCellOutlineDataSourceFactory, InstantiationType.Delayed);920registerSingleton(INotebookOutlineEntryFactory, NotebookOutlineEntryFactory, InstantiationType.Delayed);921922const schemas: IJSONSchemaMap = {};923function isConfigurationPropertySchema(x: IConfigurationPropertySchema | { [path: string]: IConfigurationPropertySchema }): x is IConfigurationPropertySchema {924return (typeof x.type !== 'undefined' || typeof x.anyOf !== 'undefined');925}926for (const editorOption of editorOptionsRegistry) {927const schema = editorOption.schema;928if (schema) {929if (isConfigurationPropertySchema(schema)) {930schemas[`editor.${editorOption.name}`] = schema;931} else {932for (const key in schema) {933if (Object.hasOwnProperty.call(schema, key)) {934schemas[key] = schema[key];935}936}937}938}939}940941const editorOptionsCustomizationSchema: IConfigurationPropertySchema = {942description: nls.localize('notebook.editorOptions.experimentalCustomization', 'Settings for code editors used in notebooks. This can be used to customize most editor.* settings.'),943default: {},944allOf: [945{946properties: schemas,947}948// , {949// patternProperties: {950// '^\\[.*\\]$': {951// type: 'object',952// default: {},953// properties: schemas954// }955// }956// }957],958tags: ['notebookLayout']959};960961const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);962configurationRegistry.registerConfiguration({963id: 'notebook',964order: 100,965title: nls.localize('notebookConfigurationTitle', "Notebook"),966type: 'object',967properties: {968[NotebookSetting.displayOrder]: {969description: nls.localize('notebook.displayOrder.description', "Priority list for output mime types"),970type: 'array',971items: {972type: 'string'973},974default: []975},976[NotebookSetting.cellToolbarLocation]: {977description: nls.localize('notebook.cellToolbarLocation.description', "Where the cell toolbar should be shown, or whether it should be hidden."),978type: 'object',979additionalProperties: {980markdownDescription: nls.localize('notebook.cellToolbarLocation.viewType', "Configure the cell toolbar position for for specific file types"),981type: 'string',982enum: ['left', 'right', 'hidden']983},984default: {985'default': 'right'986},987tags: ['notebookLayout']988},989[NotebookSetting.showCellStatusBar]: {990description: nls.localize('notebook.showCellStatusbar.description', "Whether the cell status bar should be shown."),991type: 'string',992enum: ['hidden', 'visible', 'visibleAfterExecute'],993enumDescriptions: [994nls.localize('notebook.showCellStatusbar.hidden.description', "The cell Status bar is always hidden."),995nls.localize('notebook.showCellStatusbar.visible.description', "The cell Status bar is always visible."),996nls.localize('notebook.showCellStatusbar.visibleAfterExecute.description', "The cell Status bar is hidden until the cell has executed. Then it becomes visible to show the execution status.")],997default: 'visible',998tags: ['notebookLayout']999},1000[NotebookSetting.cellExecutionTimeVerbosity]: {1001description: nls.localize('notebook.cellExecutionTimeVerbosity.description', "Controls the verbosity of the cell execution time in the cell status bar."),1002type: 'string',1003enum: ['default', 'verbose'],1004enumDescriptions: [1005nls.localize('notebook.cellExecutionTimeVerbosity.default.description', "The cell execution duration is visible, with advanced information in the hover tooltip."),1006nls.localize('notebook.cellExecutionTimeVerbosity.verbose.description', "The cell last execution timestamp and duration are visible, with advanced information in the hover tooltip.")],1007default: 'default',1008tags: ['notebookLayout']1009},1010[NotebookSetting.textDiffEditorPreview]: {1011description: nls.localize('notebook.diff.enablePreview.description', "Whether to use the enhanced text diff editor for notebook."),1012type: 'boolean',1013default: true,1014tags: ['notebookLayout']1015},1016[NotebookSetting.diffOverviewRuler]: {1017description: nls.localize('notebook.diff.enableOverviewRuler.description', "Whether to render the overview ruler in the diff editor for notebook."),1018type: 'boolean',1019default: false,1020tags: ['notebookLayout']1021},1022[NotebookSetting.cellToolbarVisibility]: {1023markdownDescription: nls.localize('notebook.cellToolbarVisibility.description', "Whether the cell toolbar should appear on hover or click."),1024type: 'string',1025enum: ['hover', 'click'],1026default: 'click',1027tags: ['notebookLayout']1028},1029[NotebookSetting.undoRedoPerCell]: {1030description: nls.localize('notebook.undoRedoPerCell.description', "Whether to use separate undo/redo stack for each cell."),1031type: 'boolean',1032default: true,1033tags: ['notebookLayout']1034},1035[NotebookSetting.compactView]: {1036description: nls.localize('notebook.compactView.description', "Control whether the notebook editor should be rendered in a compact form. For example, when turned on, it will decrease the left margin width."),1037type: 'boolean',1038default: true,1039tags: ['notebookLayout']1040},1041[NotebookSetting.focusIndicator]: {1042description: nls.localize('notebook.focusIndicator.description', "Controls where the focus indicator is rendered, either along the cell borders or on the left gutter."),1043type: 'string',1044enum: ['border', 'gutter'],1045default: 'gutter',1046tags: ['notebookLayout']1047},1048[NotebookSetting.insertToolbarLocation]: {1049description: nls.localize('notebook.insertToolbarPosition.description', "Control where the insert cell actions should appear."),1050type: 'string',1051enum: ['betweenCells', 'notebookToolbar', 'both', 'hidden'],1052enumDescriptions: [1053nls.localize('insertToolbarLocation.betweenCells', "A toolbar that appears on hover between cells."),1054nls.localize('insertToolbarLocation.notebookToolbar', "The toolbar at the top of the notebook editor."),1055nls.localize('insertToolbarLocation.both', "Both toolbars."),1056nls.localize('insertToolbarLocation.hidden', "The insert actions don't appear anywhere."),1057],1058default: 'both',1059tags: ['notebookLayout']1060},1061[NotebookSetting.globalToolbar]: {1062description: nls.localize('notebook.globalToolbar.description', "Control whether to render a global toolbar inside the notebook editor."),1063type: 'boolean',1064default: true,1065tags: ['notebookLayout']1066},1067[NotebookSetting.stickyScrollEnabled]: {1068description: nls.localize('notebook.stickyScrollEnabled.description', "Experimental. Control whether to render notebook Sticky Scroll headers in the notebook editor."),1069type: 'boolean',1070default: false,1071tags: ['notebookLayout']1072},1073[NotebookSetting.stickyScrollMode]: {1074description: nls.localize('notebook.stickyScrollMode.description', "Control whether nested sticky lines appear to stack flat or indented."),1075type: 'string',1076enum: ['flat', 'indented'],1077enumDescriptions: [1078nls.localize('notebook.stickyScrollMode.flat', "Nested sticky lines appear flat."),1079nls.localize('notebook.stickyScrollMode.indented', "Nested sticky lines appear indented."),1080],1081default: 'indented',1082tags: ['notebookLayout']1083},1084[NotebookSetting.consolidatedOutputButton]: {1085description: nls.localize('notebook.consolidatedOutputButton.description', "Control whether outputs action should be rendered in the output toolbar."),1086type: 'boolean',1087default: true,1088tags: ['notebookLayout']1089},1090// [NotebookSetting.openOutputInPreviewEditor]: {1091// description: nls.localize('notebook.output.openInPreviewEditor.description', "Controls whether or not the action to open a cell output in a preview editor is enabled. This action can be used via the cell output menu."),1092// type: 'boolean',1093// default: false,1094// tags: ['preview']1095// },1096[NotebookSetting.showFoldingControls]: {1097description: nls.localize('notebook.showFoldingControls.description', "Controls when the Markdown header folding arrow is shown."),1098type: 'string',1099enum: ['always', 'never', 'mouseover'],1100enumDescriptions: [1101nls.localize('showFoldingControls.always', "The folding controls are always visible."),1102nls.localize('showFoldingControls.never', "Never show the folding controls and reduce the gutter size."),1103nls.localize('showFoldingControls.mouseover', "The folding controls are visible only on mouseover."),1104],1105default: 'mouseover',1106tags: ['notebookLayout']1107},1108[NotebookSetting.dragAndDropEnabled]: {1109description: nls.localize('notebook.dragAndDrop.description', "Control whether the notebook editor should allow moving cells through drag and drop."),1110type: 'boolean',1111default: true,1112tags: ['notebookLayout']1113},1114[NotebookSetting.consolidatedRunButton]: {1115description: nls.localize('notebook.consolidatedRunButton.description', "Control whether extra actions are shown in a dropdown next to the run button."),1116type: 'boolean',1117default: false,1118tags: ['notebookLayout']1119},1120[NotebookSetting.globalToolbarShowLabel]: {1121description: nls.localize('notebook.globalToolbarShowLabel', "Control whether the actions on the notebook toolbar should render label or not."),1122type: 'string',1123enum: ['always', 'never', 'dynamic'],1124default: 'always',1125tags: ['notebookLayout']1126},1127[NotebookSetting.textOutputLineLimit]: {1128markdownDescription: nls.localize('notebook.textOutputLineLimit', "Controls how many lines of text are displayed in a text output. If {0} is enabled, this setting is used to determine the scroll height of the output.", '`#notebook.output.scrolling#`'),1129type: 'number',1130default: 30,1131tags: ['notebookLayout', 'notebookOutputLayout'],1132minimum: 1,1133},1134[NotebookSetting.LinkifyOutputFilePaths]: {1135description: nls.localize('notebook.disableOutputFilePathLinks', "Control whether to disable filepath links in the output of notebook cells."),1136type: 'boolean',1137default: true,1138tags: ['notebookOutputLayout']1139},1140[NotebookSetting.minimalErrorRendering]: {1141description: nls.localize('notebook.minimalErrorRendering', "Control whether to render error output in a minimal style."),1142type: 'boolean',1143default: false,1144tags: ['notebookOutputLayout']1145},1146[NotebookSetting.markupFontSize]: {1147markdownDescription: nls.localize('notebook.markup.fontSize', "Controls the font size in pixels of rendered markup in notebooks. When set to {0}, 120% of {1} is used.", '`0`', '`#editor.fontSize#`'),1148type: 'number',1149default: 0,1150tags: ['notebookLayout']1151},1152[NotebookSetting.markdownLineHeight]: {1153markdownDescription: nls.localize('notebook.markdown.lineHeight', "Controls the line height in pixels of markdown cells in notebooks. When set to {0}, {1} will be used", '`0`', '`normal`'),1154type: 'number',1155default: 0,1156tags: ['notebookLayout']1157},1158[NotebookSetting.cellEditorOptionsCustomizations]: editorOptionsCustomizationSchema,1159[NotebookSetting.interactiveWindowCollapseCodeCells]: {1160markdownDescription: nls.localize('notebook.interactiveWindow.collapseCodeCells', "Controls whether code cells in the interactive window are collapsed by default."),1161type: 'string',1162enum: ['always', 'never', 'fromEditor'],1163default: 'fromEditor'1164},1165[NotebookSetting.outputLineHeight]: {1166markdownDescription: nls.localize('notebook.outputLineHeight', "Line height of the output text within notebook cells.\n - When set to 0, editor line height is used.\n - Values between 0 and 8 will be used as a multiplier with the font size.\n - Values greater than or equal to 8 will be used as effective values."),1167type: 'number',1168default: 0,1169tags: ['notebookLayout', 'notebookOutputLayout']1170},1171[NotebookSetting.outputFontSize]: {1172markdownDescription: nls.localize('notebook.outputFontSize', "Font size for the output text within notebook cells. When set to 0, {0} is used.", '`#editor.fontSize#`'),1173type: 'number',1174default: 0,1175tags: ['notebookLayout', 'notebookOutputLayout']1176},1177[NotebookSetting.outputFontFamily]: {1178markdownDescription: nls.localize('notebook.outputFontFamily', "The font family of the output text within notebook cells. When set to empty, the {0} is used.", '`#editor.fontFamily#`'),1179type: 'string',1180tags: ['notebookLayout', 'notebookOutputLayout']1181},1182[NotebookSetting.outputScrolling]: {1183markdownDescription: nls.localize('notebook.outputScrolling', "Initially render notebook outputs in a scrollable region when longer than the limit."),1184type: 'boolean',1185tags: ['notebookLayout', 'notebookOutputLayout'],1186default: typeof product.quality === 'string' && product.quality !== 'stable' // only enable as default in insiders1187},1188[NotebookSetting.outputWordWrap]: {1189markdownDescription: nls.localize('notebook.outputWordWrap', "Controls whether the lines in output should wrap."),1190type: 'boolean',1191tags: ['notebookLayout', 'notebookOutputLayout'],1192default: false1193},1194[NotebookSetting.defaultFormatter]: {1195description: nls.localize('notebookFormatter.default', "Defines a default notebook formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter."),1196type: ['string', 'null'],1197default: null,1198enum: DefaultFormatter.extensionIds,1199enumItemLabels: DefaultFormatter.extensionItemLabels,1200markdownEnumDescriptions: DefaultFormatter.extensionDescriptions1201},1202[NotebookSetting.formatOnSave]: {1203markdownDescription: nls.localize('notebook.formatOnSave', "Format a notebook on save. A formatter must be available and the editor must not be shutting down. When {0} is set to `afterDelay`, the file will only be formatted when saved explicitly.", '`#files.autoSave#`'),1204type: 'boolean',1205tags: ['notebookLayout'],1206default: false1207},1208[NotebookSetting.insertFinalNewline]: {1209markdownDescription: nls.localize('notebook.insertFinalNewline', "When enabled, insert a final new line into the end of code cells when saving a notebook."),1210type: 'boolean',1211tags: ['notebookLayout'],1212default: false1213},1214[NotebookSetting.formatOnCellExecution]: {1215markdownDescription: nls.localize('notebook.formatOnCellExecution', "Format a notebook cell upon execution. A formatter must be available."),1216type: 'boolean',1217default: false1218},1219[NotebookSetting.confirmDeleteRunningCell]: {1220markdownDescription: nls.localize('notebook.confirmDeleteRunningCell', "Control whether a confirmation prompt is required to delete a running cell."),1221type: 'boolean',1222default: true1223},1224[NotebookSetting.findFilters]: {1225markdownDescription: nls.localize('notebook.findFilters', "Customize the Find Widget behavior for searching within notebook cells. When both markup source and markup preview are enabled, the Find Widget will search either the source code or preview based on the current state of the cell."),1226type: 'object',1227properties: {1228markupSource: {1229type: 'boolean',1230default: true1231},1232markupPreview: {1233type: 'boolean',1234default: true1235},1236codeSource: {1237type: 'boolean',1238default: true1239},1240codeOutput: {1241type: 'boolean',1242default: true1243}1244},1245default: {1246markupSource: true,1247markupPreview: true,1248codeSource: true,1249codeOutput: true1250},1251tags: ['notebookLayout']1252},1253[NotebookSetting.remoteSaving]: {1254markdownDescription: nls.localize('notebook.remoteSaving', "Enables the incremental saving of notebooks between processes and across Remote connections. When enabled, only the changes to the notebook are sent to the extension host, improving performance for large notebooks and slow network connections."),1255type: 'boolean',1256default: typeof product.quality === 'string' && product.quality !== 'stable', // only enable as default in insiders1257tags: ['experimental']1258},1259[NotebookSetting.scrollToRevealCell]: {1260markdownDescription: nls.localize('notebook.scrolling.revealNextCellOnExecute.description', "How far to scroll when revealing the next cell upon running {0}.", 'notebook.cell.executeAndSelectBelow'),1261type: 'string',1262enum: ['fullCell', 'firstLine', 'none'],1263markdownEnumDescriptions: [1264nls.localize('notebook.scrolling.revealNextCellOnExecute.fullCell.description', 'Scroll to fully reveal the next cell.'),1265nls.localize('notebook.scrolling.revealNextCellOnExecute.firstLine.description', 'Scroll to reveal the first line of the next cell.'),1266nls.localize('notebook.scrolling.revealNextCellOnExecute.none.description', 'Do not scroll.'),1267],1268default: 'fullCell'1269},1270[NotebookSetting.cellGenerate]: {1271markdownDescription: nls.localize('notebook.cellGenerate', "Enable experimental generate action to create code cell with inline chat enabled."),1272type: 'boolean',1273default: true1274},1275[NotebookSetting.notebookVariablesView]: {1276markdownDescription: nls.localize('notebook.VariablesView.description', "Enable the experimental notebook variables view within the debug panel."),1277type: 'boolean',1278default: false1279},1280[NotebookSetting.notebookInlineValues]: {1281markdownDescription: nls.localize('notebook.inlineValues.description', "Control whether to show inline values within notebook code cells after cell execution. Values will remain until the cell is edited, re-executed, or explicitly cleared via the Clear All Outputs toolbar button or the `Notebook: Clear Inline Values` command."),1282type: 'string',1283enum: ['on', 'auto', 'off'],1284enumDescriptions: [1285nls.localize('notebook.inlineValues.on', "Always show inline values, with a regex fallback if no inline value provider is registered. Note: There may be a performance impact in larger cells if the fallback is used."),1286nls.localize('notebook.inlineValues.auto', "Show inline values only when an inline value provider is registered."),1287nls.localize('notebook.inlineValues.off', "Never show inline values."),1288],1289default: 'off'1290},1291[NotebookSetting.cellFailureDiagnostics]: {1292markdownDescription: nls.localize('notebook.cellFailureDiagnostics', "Show available diagnostics for cell failures."),1293type: 'boolean',1294default: true1295},1296[NotebookSetting.outputBackupSizeLimit]: {1297markdownDescription: nls.localize('notebook.backup.sizeLimit', "The limit of notebook output size in kilobytes (KB) where notebook files will no longer be backed up for hot reload. Use 0 for unlimited."),1298type: 'number',1299default: 100001300},1301[NotebookSetting.multiCursor]: {1302markdownDescription: nls.localize('notebook.multiCursor.enabled', "Experimental. Enables a limited set of multi cursor controls across multiple cells in the notebook editor. Currently supported are core editor actions (typing/cut/copy/paste/composition) and a limited subset of editor commands."),1303type: 'boolean',1304default: false1305},1306[NotebookSetting.markupFontFamily]: {1307markdownDescription: nls.localize('notebook.markup.fontFamily', "Controls the font family of rendered markup in notebooks. When left blank, this will fall back to the default workbench font family."),1308type: 'string',1309default: '',1310tags: ['notebookLayout']1311}1312}1313});131413151316