Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Rieken <johannes.rieken@gmail.com>2022-05-04 09:42:43 +0300
committerGitHub <noreply@github.com>2022-05-04 09:42:43 +0300
commit12c535e2bd7f261a94a5aa1267fa940055706f8c (patch)
tree63456f645a98a08889b97032c5312237f95f5d4d /src/vs/workbench/contrib/notebook/common
parent4ef3ed3ce8d7ab1857d41454449d32f946d3ac8c (diff)
parent9556854c8fc9199b4ffd06b4e17140e8fb78d0f4 (diff)
Merge branch 'main' into joh/cellUri
Diffstat (limited to 'src/vs/workbench/contrib/notebook/common')
-rw-r--r--src/vs/workbench/contrib/notebook/common/notebookCommon.ts10
-rw-r--r--src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts2
-rw-r--r--src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts8
-rw-r--r--src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts15
-rw-r--r--src/vs/workbench/contrib/notebook/common/notebookKernelService.ts35
-rw-r--r--src/vs/workbench/contrib/notebook/common/notebookOptions.ts70
6 files changed, 121 insertions, 19 deletions
diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts
index bc1f504dc36..28ff3f4f885 100644
--- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts
@@ -25,8 +25,7 @@ import { IEditorModel } from 'vs/platform/editor/common/editor';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { ThemeColor } from 'vs/platform/theme/common/themeService';
import { UndoRedoGroup } from 'vs/platform/undoRedo/common/undoRedo';
-import { IRevertOptions, ISaveOptions } from 'vs/workbench/common/editor';
-import { EditorInput } from 'vs/workbench/common/editor/editorInput';
+import { IRevertOptions, ISaveOptions, IUntypedEditorInput } from 'vs/workbench/common/editor';
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
import { IWorkingCopyBackupMeta, IWorkingCopySaveEvent } from 'vs/workbench/services/workingCopy/common/workingCopy';
@@ -792,7 +791,7 @@ export interface INotebookEditorModel extends IEditorModel {
hasAssociatedFilePath(): boolean;
load(options?: INotebookLoadOptions): Promise<IResolvedNotebookEditorModel>;
save(options?: ISaveOptions): Promise<boolean>;
- saveAs(target: URI): Promise<EditorInput | undefined>;
+ saveAs(target: URI): Promise<IUntypedEditorInput | undefined>;
revert(options?: IRevertOptions): Promise<void>;
}
@@ -925,7 +924,10 @@ export const NotebookSetting = {
textOutputLineLimit: 'notebook.output.textLineLimit',
globalToolbarShowLabel: 'notebook.globalToolbarShowLabel',
markupFontSize: 'notebook.markup.fontSize',
- interactiveWindowCollapseCodeCells: 'interactiveWindow.collapseCellInputCode'
+ interactiveWindowCollapseCodeCells: 'interactiveWindow.collapseCellInputCode',
+ outputLineHeight: 'notebook.outputLineHeight',
+ outputFontSize: 'notebook.outputFontSize',
+ outputFontFamily: 'notebook.outputFontFamily'
} as const;
export const enum CellStatusbarAlignment {
diff --git a/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts b/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts
index fd2279cba63..689f9ca995e 100644
--- a/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts
+++ b/src/vs/workbench/contrib/notebook/common/notebookContextKeys.ts
@@ -38,6 +38,8 @@ export const NOTEBOOK_CELL_EXECUTING = new RawContextKey<boolean>('notebookCellE
export const NOTEBOOK_CELL_HAS_OUTPUTS = new RawContextKey<boolean>('notebookCellHasOutputs', false);
export const NOTEBOOK_CELL_INPUT_COLLAPSED = new RawContextKey<boolean>('notebookCellInputIsCollapsed', false);
export const NOTEBOOK_CELL_OUTPUT_COLLAPSED = new RawContextKey<boolean>('notebookCellOutputIsCollapsed', false);
+export const NOTEBOOK_CELL_RESOURCE = new RawContextKey<string>('notebookCellResource', '');
+
// Kernels
export const NOTEBOOK_KERNEL = new RawContextKey<string>('notebookKernel', undefined);
export const NOTEBOOK_KERNEL_COUNT = new RawContextKey<number>('notebookKernelCount', 0);
diff --git a/src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts b/src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts
index cffd2b0362d..b8cbd4985d0 100644
--- a/src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts
+++ b/src/vs/workbench/contrib/notebook/common/notebookEditorInput.ts
@@ -102,6 +102,10 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {
}
}
+ if (!(capabilities & EditorInputCapabilities.Readonly)) {
+ capabilities |= EditorInputCapabilities.CanDropIntoEditor;
+ }
+
return capabilities;
}
@@ -120,7 +124,7 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {
return this._editorModelReference.object.isDirty();
}
- override async save(group: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | undefined> {
+ override async save(group: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | IUntypedEditorInput | undefined> {
if (this._editorModelReference) {
if (this.hasCapability(EditorInputCapabilities.Untitled)) {
@@ -135,7 +139,7 @@ export class NotebookEditorInput extends AbstractResourceEditorInput {
return undefined;
}
- override async saveAs(group: GroupIdentifier, options?: ISaveOptions): Promise<EditorInput | undefined> {
+ override async saveAs(group: GroupIdentifier, options?: ISaveOptions): Promise<IUntypedEditorInput | undefined> {
if (!this._editorModelReference) {
return undefined;
}
diff --git a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts
index 8938cff2e80..7cd345036a7 100644
--- a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts
+++ b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts
@@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
-import { IRevertOptions, ISaveOptions } from 'vs/workbench/common/editor';
-import { EditorInput } from 'vs/workbench/common/editor/editorInput';
+import { IRevertOptions, ISaveOptions, IUntypedEditorInput } from 'vs/workbench/common/editor';
import { EditorModel } from 'vs/workbench/common/editor/editorModel';
import { Emitter, Event } from 'vs/base/common/event';
import { ICellDto2, INotebookEditorModel, INotebookLoadOptions, IResolvedNotebookEditorModel, NotebookCellsChangeType, NotebookData, NotebookDocumentBackupData } from 'vs/workbench/contrib/notebook/common/notebookCommon';
@@ -28,8 +27,6 @@ import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/commo
import { StoredFileWorkingCopyState, IStoredFileWorkingCopy, IStoredFileWorkingCopyModel, IStoredFileWorkingCopyModelContentChangedEvent, IStoredFileWorkingCopyModelFactory, IStoredFileWorkingCopySaveEvent } from 'vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { CancellationError } from 'vs/base/common/errors';
-import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebookEditorInput';
-import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { filter } from 'vs/base/common/objects';
import { IFileWorkingCopyManager } from 'vs/workbench/services/workingCopy/common/fileWorkingCopyManager';
import { IUntitledFileWorkingCopy, IUntitledFileWorkingCopyModel, IUntitledFileWorkingCopyModelContentChangedEvent, IUntitledFileWorkingCopyModelFactory } from 'vs/workbench/services/workingCopy/common/untitledFileWorkingCopy';
@@ -59,7 +56,6 @@ export class ComplexNotebookEditorModel extends EditorModel implements INotebook
readonly resource: URI,
readonly viewType: string,
private readonly _contentProvider: INotebookContentProvider,
- @IInstantiationService private readonly _instantiationService: IInstantiationService,
@INotebookService private readonly _notebookService: INotebookService,
@IWorkingCopyService private readonly _workingCopyService: IWorkingCopyService,
@IWorkingCopyBackupService private readonly _workingCopyBackupService: IWorkingCopyBackupService,
@@ -393,7 +389,7 @@ export class ComplexNotebookEditorModel extends EditorModel implements INotebook
});
}
- async saveAs(targetResource: URI): Promise<EditorInput | undefined> {
+ async saveAs(targetResource: URI): Promise<IUntypedEditorInput | undefined> {
if (!this.isResolved()) {
return undefined;
@@ -419,7 +415,7 @@ export class ComplexNotebookEditorModel extends EditorModel implements INotebook
}
this.setDirty(false);
this._onDidSave.fire({});
- return this._instantiationService.createInstance(NotebookEditorInput, targetResource, this.viewType, {});
+ return { resource: targetResource };
}
private async _resolveStats(resource: URI) {
@@ -462,7 +458,6 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
private readonly _hasAssociatedFilePath: boolean,
readonly viewType: string,
private readonly _workingCopyManager: IFileWorkingCopyManager<NotebookFileWorkingCopyModel, NotebookFileWorkingCopyModel>,
- @IInstantiationService private readonly _instantiationService: IInstantiationService,
@IFileService private readonly _fileService: IFileService
) {
super();
@@ -547,14 +542,14 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
return this;
}
- async saveAs(target: URI): Promise<EditorInput | undefined> {
+ async saveAs(target: URI): Promise<IUntypedEditorInput | undefined> {
const newWorkingCopy = await this._workingCopyManager.saveAs(this.resource, target);
if (!newWorkingCopy) {
return undefined;
}
// this is a little hacky because we leave the new working copy alone. BUT
// the newly created editor input will pick it up and claim ownership of it.
- return this._instantiationService.createInstance(NotebookEditorInput, newWorkingCopy.resource, this.viewType, {});
+ return { resource: newWorkingCopy.resource };
}
private static _isStoredFileWorkingCopy(candidate?: IStoredFileWorkingCopy<NotebookFileWorkingCopyModel> | IUntitledFileWorkingCopy<NotebookFileWorkingCopyModel>): candidate is IStoredFileWorkingCopy<NotebookFileWorkingCopyModel> {
diff --git a/src/vs/workbench/contrib/notebook/common/notebookKernelService.ts b/src/vs/workbench/contrib/notebook/common/notebookKernelService.ts
index 6610fe7177d..4f5304600b0 100644
--- a/src/vs/workbench/contrib/notebook/common/notebookKernelService.ts
+++ b/src/vs/workbench/contrib/notebook/common/notebookKernelService.ts
@@ -31,8 +31,13 @@ export interface INotebookKernelChangeEvent {
hasExecutionOrder?: true;
}
-export interface INotebookKernel {
+export const enum NotebookKernelType {
+ Resolved,
+ Proxy = 1
+}
+export interface IResolvedNotebookKernel {
+ readonly type: NotebookKernelType.Resolved;
readonly id: string;
readonly viewType: string;
readonly onDidChange: Event<Readonly<INotebookKernelChangeEvent>>;
@@ -54,6 +59,34 @@ export interface INotebookKernel {
cancelNotebookCellExecution(uri: URI, cellHandles: number[]): Promise<void>;
}
+export const enum ProxyKernelState {
+ Disconnected = 1,
+ Connected = 2,
+ Initializing = 3
+}
+
+export interface INotebookProxyKernelChangeEvent extends INotebookKernelChangeEvent {
+ connectionState?: true;
+}
+
+export interface INotebookProxyKernel {
+ readonly type: NotebookKernelType.Proxy;
+ readonly id: string;
+ readonly viewType: string;
+ readonly extension: ExtensionIdentifier;
+ readonly preloadProvides: string[];
+ readonly onDidChange: Event<Readonly<INotebookProxyKernelChangeEvent>>;
+ label: string;
+ description?: string;
+ detail?: string;
+ kind?: string;
+ supportedLanguages: string[];
+ connectionState: ProxyKernelState;
+ resolveKernel(uri: URI): Promise<string | null>;
+}
+
+export type INotebookKernel = IResolvedNotebookKernel | INotebookProxyKernel;
+
export interface INotebookTextModelLike { uri: URI; viewType: string }
export const INotebookKernelService = createDecorator<INotebookKernelService>('INotebookKernelService');
diff --git a/src/vs/workbench/contrib/notebook/common/notebookOptions.ts b/src/vs/workbench/contrib/notebook/common/notebookOptions.ts
index 9564a563def..426871f84fa 100644
--- a/src/vs/workbench/contrib/notebook/common/notebookOptions.ts
+++ b/src/vs/workbench/contrib/notebook/common/notebookOptions.ts
@@ -62,6 +62,9 @@ export interface NotebookLayoutConfiguration {
showFoldingControls: 'always' | 'mouseover';
dragAndDropEnabled: boolean;
fontSize: number;
+ outputFontSize: number;
+ outputFontFamily: string;
+ outputLineHeight: number;
markupFontSize: number;
focusIndicatorLeftMargin: number;
editorOptionsCustomizations: any | undefined;
@@ -84,9 +87,13 @@ export interface NotebookOptionsChangeEvent {
readonly consolidatedRunButton?: boolean;
readonly dragAndDropEnabled?: boolean;
readonly fontSize?: boolean;
+ readonly outputFontSize?: boolean;
readonly markupFontSize?: boolean;
+ readonly fontFamily?: boolean;
+ readonly outputFontFamily?: boolean;
readonly editorOptionsCustomizations?: boolean;
readonly interactiveWindowCollapseCodeCells?: boolean;
+ readonly outputLineHeight?: boolean;
}
const defaultConfigConstants = Object.freeze({
@@ -134,9 +141,12 @@ export class NotebookOptions extends Disposable {
const showFoldingControls = this._computeShowFoldingControlsOption();
// const { bottomToolbarGap, bottomToolbarHeight } = this._computeBottomToolbarDimensions(compactView, insertToolbarPosition, insertToolbarAlignment);
const fontSize = this.configurationService.getValue<number>('editor.fontSize');
+ const outputFontSize = this.configurationService.getValue<number>(NotebookSetting.outputFontSize);
+ const outputFontFamily = this.configurationService.getValue<string>(NotebookSetting.outputFontFamily);
const markupFontSize = this.configurationService.getValue<number>(NotebookSetting.markupFontSize);
const editorOptionsCustomizations = this.configurationService.getValue(NotebookSetting.cellEditorOptionsCustomizations);
const interactiveWindowCollapseCodeCells: InteractiveWindowCollapseCodeCells = this.configurationService.getValue(NotebookSetting.interactiveWindowCollapseCodeCells);
+ const outputLineHeight = this._computeOutputLineHeight();
this._layoutConfiguration = {
...(compactView ? compactConfigConstants : defaultConfigConstants),
@@ -166,6 +176,9 @@ export class NotebookOptions extends Disposable {
insertToolbarAlignment,
showFoldingControls,
fontSize,
+ outputFontSize,
+ outputFontFamily,
+ outputLineHeight,
markupFontSize,
editorOptionsCustomizations,
focusIndicatorGap: 3,
@@ -185,6 +198,29 @@ export class NotebookOptions extends Disposable {
}));
}
+ private _computeOutputLineHeight(): number {
+ const minimumLineHeight = 8;
+ let lineHeight = this.configurationService.getValue<number>(NotebookSetting.outputLineHeight);
+
+ if (lineHeight < minimumLineHeight) {
+ // Values too small to be line heights in pixels are in ems.
+ let fontSize = this.configurationService.getValue<number>(NotebookSetting.outputFontSize);
+ if (fontSize === 0) {
+ fontSize = this.configurationService.getValue<number>('editor.fontSize');
+ }
+
+ lineHeight = lineHeight * fontSize;
+ }
+
+ // Enforce integer, minimum constraints
+ lineHeight = Math.round(lineHeight);
+ if (lineHeight < minimumLineHeight) {
+ lineHeight = minimumLineHeight;
+ }
+
+ return lineHeight;
+ }
+
private _updateConfiguration(e: IConfigurationChangeEvent) {
const cellStatusBarVisibility = e.affectsConfiguration(NotebookSetting.showCellStatusBar);
const cellToolbarLocation = e.affectsConfiguration(NotebookSetting.cellToolbarLocation);
@@ -199,9 +235,13 @@ export class NotebookOptions extends Disposable {
const showFoldingControls = e.affectsConfiguration(NotebookSetting.showFoldingControls);
const dragAndDropEnabled = e.affectsConfiguration(NotebookSetting.dragAndDropEnabled);
const fontSize = e.affectsConfiguration('editor.fontSize');
+ const outputFontSize = e.affectsConfiguration(NotebookSetting.outputFontSize);
const markupFontSize = e.affectsConfiguration(NotebookSetting.markupFontSize);
+ const fontFamily = e.affectsConfiguration('editor.fontFamily');
+ const outputFontFamily = e.affectsConfiguration(NotebookSetting.outputFontFamily);
const editorOptionsCustomizations = e.affectsConfiguration(NotebookSetting.cellEditorOptionsCustomizations);
const interactiveWindowCollapseCodeCells = e.affectsConfiguration(NotebookSetting.interactiveWindowCollapseCodeCells);
+ const outputLineHeight = e.affectsConfiguration(NotebookSetting.outputLineHeight);
if (
!cellStatusBarVisibility
@@ -217,9 +257,13 @@ export class NotebookOptions extends Disposable {
&& !showFoldingControls
&& !dragAndDropEnabled
&& !fontSize
+ && !outputFontSize
&& !markupFontSize
+ && !fontFamily
+ && !outputFontFamily
&& !editorOptionsCustomizations
- && !interactiveWindowCollapseCodeCells) {
+ && !interactiveWindowCollapseCodeCells
+ && !outputLineHeight) {
return;
}
@@ -281,10 +325,18 @@ export class NotebookOptions extends Disposable {
configuration.fontSize = this.configurationService.getValue<number>('editor.fontSize');
}
+ if (outputFontSize) {
+ configuration.outputFontSize = this.configurationService.getValue<number>(NotebookSetting.outputFontSize) ?? configuration.fontSize;
+ }
+
if (markupFontSize) {
configuration.markupFontSize = this.configurationService.getValue<number>(NotebookSetting.markupFontSize);
}
+ if (outputFontFamily) {
+ configuration.outputFontFamily = this.configurationService.getValue<string>(NotebookSetting.outputFontFamily);
+ }
+
if (editorOptionsCustomizations) {
configuration.editorOptionsCustomizations = this.configurationService.getValue(NotebookSetting.cellEditorOptionsCustomizations);
}
@@ -293,6 +345,10 @@ export class NotebookOptions extends Disposable {
configuration.interactiveWindowCollapseCodeCells = this.configurationService.getValue(NotebookSetting.interactiveWindowCollapseCodeCells);
}
+ if (outputLineHeight || fontSize || outputFontSize) {
+ configuration.outputLineHeight = this._computeOutputLineHeight();
+ }
+
this._layoutConfiguration = Object.freeze(configuration);
// trigger event
@@ -310,9 +366,13 @@ export class NotebookOptions extends Disposable {
consolidatedRunButton,
dragAndDropEnabled,
fontSize,
+ outputFontSize,
markupFontSize,
+ fontFamily,
+ outputFontFamily,
editorOptionsCustomizations,
- interactiveWindowCollapseCodeCells
+ interactiveWindowCollapseCodeCells,
+ outputLineHeight
});
}
@@ -502,7 +562,10 @@ export class NotebookOptions extends Disposable {
runGutter: this._layoutConfiguration.cellRunGutter,
dragAndDropEnabled: this._layoutConfiguration.dragAndDropEnabled,
fontSize: this._layoutConfiguration.fontSize,
+ outputFontSize: this._layoutConfiguration.outputFontSize,
+ outputFontFamily: this._layoutConfiguration.outputFontFamily,
markupFontSize: this._layoutConfiguration.markupFontSize,
+ outputLineHeight: this._layoutConfiguration.outputLineHeight,
};
}
@@ -517,7 +580,10 @@ export class NotebookOptions extends Disposable {
runGutter: 0,
dragAndDropEnabled: false,
fontSize: this._layoutConfiguration.fontSize,
+ outputFontSize: this._layoutConfiguration.outputFontSize,
+ outputFontFamily: this._layoutConfiguration.outputFontFamily,
markupFontSize: this._layoutConfiguration.markupFontSize,
+ outputLineHeight: this._layoutConfiguration.outputLineHeight,
};
}