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:
Diffstat (limited to 'src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts')
-rw-r--r--src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts69
1 files changed, 51 insertions, 18 deletions
diff --git a/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts b/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
index f108213e01b..9969bd9c645 100644
--- a/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
+++ b/src/vs/workbench/contrib/interactive/browser/interactive.contribution.ts
@@ -9,6 +9,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { parse } from 'vs/base/common/marshalling';
import { Schemas } from 'vs/base/common/network';
+import { extname } from 'vs/base/common/resources';
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
import { assertType } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
@@ -23,9 +24,10 @@ import { peekViewBorder /*, peekViewEditorBackground, peekViewResultsBackground
import { Context as SuggestContext } from 'vs/editor/contrib/suggest/browser/suggest';
import { localize } from 'vs/nls';
import { Action2, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
+import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
-import { EditorActivation } from 'vs/platform/editor/common/editor';
+import { EditorActivation, IResourceEditorInput } from 'vs/platform/editor/common/editor';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
@@ -37,20 +39,21 @@ import { contrastBorder, listInactiveSelectionBackground, registerColor, transpa
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { EditorPaneDescriptor, IEditorPaneRegistry } from 'vs/workbench/browser/editor';
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
-import { EditorExtensions, EditorsOrder, IEditorSerializer } from 'vs/workbench/common/editor';
+import { EditorExtensions, EditorsOrder, IEditorFactoryRegistry, IEditorSerializer } from 'vs/workbench/common/editor';
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
// import { Color } from 'vs/base/common/color';
import { PANEL_BORDER } from 'vs/workbench/common/theme';
import { ResourceNotebookCellEdit } from 'vs/workbench/contrib/bulkEdit/browser/bulkCellEdits';
-import { INTERACTIVE_INPUT_CURSOR_BOUNDARY } from 'vs/workbench/contrib/interactive/browser/interactiveCommon';
+import { InteractiveWindowSetting, INTERACTIVE_INPUT_CURSOR_BOUNDARY } from 'vs/workbench/contrib/interactive/browser/interactiveCommon';
import { IInteractiveDocumentService, InteractiveDocumentService } from 'vs/workbench/contrib/interactive/browser/interactiveDocumentService';
import { InteractiveEditor } from 'vs/workbench/contrib/interactive/browser/interactiveEditor';
import { InteractiveEditorInput } from 'vs/workbench/contrib/interactive/browser/interactiveEditorInput';
import { IInteractiveHistoryService, InteractiveHistoryService } from 'vs/workbench/contrib/interactive/browser/interactiveHistoryService';
import { NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
+import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget';
import * as icons from 'vs/workbench/contrib/notebook/browser/notebookIcons';
-import { CellEditType, CellKind, ICellOutput, NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon';
+import { CellEditType, CellKind, CellUri, ICellOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { INotebookContentProvider, INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
import { columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn';
@@ -192,7 +195,7 @@ export class InteractiveDocumentContribution extends Disposable implements IWork
editorResolverService.registerEditor(
`${Schemas.vscodeInteractiveInput}:/**`,
{
- id: InteractiveEditorInput.ID,
+ id: 'vscode-interactive-input',
label: 'Interactive Editor',
priority: RegisteredEditorPriority.exclusive
},
@@ -209,17 +212,31 @@ export class InteractiveDocumentContribution extends Disposable implements IWork
editorResolverService.registerEditor(
`*.interactive`,
{
- id: InteractiveEditorInput.ID,
+ id: 'interactive',
label: 'Interactive Editor',
priority: RegisteredEditorPriority.exclusive
},
{
- canSupportResource: uri => uri.scheme === Schemas.vscodeInteractive,
+ canSupportResource: uri => uri.scheme === Schemas.vscodeInteractive || (uri.scheme === Schemas.vscodeNotebookCell && extname(uri) === '.interactive'),
singlePerResource: true
},
- ({ resource }) => {
- const editorInput = editorService.getEditors(EditorsOrder.SEQUENTIAL).find(editor => editor.editor instanceof InteractiveEditorInput && editor.editor.resource?.toString() === resource.toString());
- return editorInput!;
+ ({ resource, options }) => {
+ const data = CellUri.parse(resource);
+ let notebookUri: URI = resource;
+ let cellOptions: IResourceEditorInput | undefined;
+
+ if (data) {
+ notebookUri = data.notebook;
+ cellOptions = { resource, options };
+ }
+
+ const notebookOptions = { ...options, cellOptions } as INotebookEditorOptions;
+
+ const editorInput = editorService.getEditors(EditorsOrder.SEQUENTIAL).find(editor => editor.editor instanceof InteractiveEditorInput && editor.editor.resource?.toString() === notebookUri.toString());
+ return {
+ editor: editorInput!.editor,
+ options: notebookOptions
+ };
}
);
}
@@ -256,8 +273,13 @@ workbenchContributionsRegistry.registerWorkbenchContribution(InteractiveDocument
workbenchContributionsRegistry.registerWorkbenchContribution(InteractiveInputContentProvider, LifecyclePhase.Starting);
export class InteractiveEditorSerializer implements IEditorSerializer {
+ public static readonly ID = InteractiveEditorInput.ID;
+
+ constructor(@IConfigurationService private configurationService: IConfigurationService) {
+ }
+
canSerialize(): boolean {
- return true;
+ return this.configurationService.getValue<boolean>(InteractiveWindowSetting.interactiveWindowHotExit);
}
serialize(input: EditorInput): string {
@@ -265,11 +287,16 @@ export class InteractiveEditorSerializer implements IEditorSerializer {
return JSON.stringify({
resource: input.primary.resource,
inputResource: input.inputResource,
+ name: input.getName(),
+ data: input.getSerialization()
});
}
deserialize(instantiationService: IInstantiationService, raw: string) {
- type Data = { resource: URI; inputResource: URI };
+ if (!this.canSerialize()) {
+ return undefined;
+ }
+ type Data = { resource: URI; inputResource: URI; data: any };
const data = <Data>parse(raw);
if (!data) {
return undefined;
@@ -280,14 +307,15 @@ export class InteractiveEditorSerializer implements IEditorSerializer {
}
const input = InteractiveEditorInput.create(instantiationService, resource, inputResource);
+ input.restoreSerialization(data.data);
return input;
}
}
-// Registry.as<EditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerEditorInputSerializer(
-// InteractiveEditorInput.ID,
-// InteractiveEditorSerializer
-// );
+Registry.as<IEditorFactoryRegistry>(EditorExtensions.EditorFactory)
+ .registerEditorSerializer(
+ InteractiveEditorSerializer.ID,
+ InteractiveEditorSerializer);
registerSingleton(IInteractiveHistoryService, InteractiveHistoryService);
registerSingleton(IInteractiveDocumentService, InteractiveDocumentService);
@@ -722,15 +750,20 @@ registerThemingParticipant((theme) => {
});
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
- id: 'notebook',
+ id: 'interactiveWindow',
order: 100,
type: 'object',
'properties': {
- [NotebookSetting.interactiveWindowAlwaysScrollOnNewCell]: {
+ [InteractiveWindowSetting.interactiveWindowAlwaysScrollOnNewCell]: {
type: 'boolean',
default: true,
markdownDescription: localize('interactiveWindow.alwaysScrollOnNewCell', "Automatically scroll the interactive window to show the output of the last statement executed. If this value is false, the window will only scroll if the last cell was already the one scrolled to.")
},
+ [InteractiveWindowSetting.interactiveWindowHotExit]: {
+ type: 'boolean',
+ default: false,
+ markdownDescription: localize('interactiveWindow.hotExit', "Controls whether the interactive window sessions should be restored when the workspace reloads.")
+ }
}
});