mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
@@ -61,6 +61,8 @@ import { isEqual } from 'vs/base/common/resources';
|
|||||||
import { NotebookFindContrib } from 'vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget';
|
import { NotebookFindContrib } from 'vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget';
|
||||||
import { INTERACTIVE_WINDOW_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
import { INTERACTIVE_WINDOW_EDITOR_ID } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||||
import 'vs/css!./interactiveEditor';
|
import 'vs/css!./interactiveEditor';
|
||||||
|
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||||
|
import { deepClone } from 'vs/base/common/objects';
|
||||||
|
|
||||||
const DECORATION_KEY = 'interactiveInputDecoration';
|
const DECORATION_KEY = 'interactiveInputDecoration';
|
||||||
const INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'InteractiveEditorViewState';
|
const INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'InteractiveEditorViewState';
|
||||||
@@ -93,6 +95,7 @@ export class InteractiveEditor extends EditorPane {
|
|||||||
#instantiationService: IInstantiationService;
|
#instantiationService: IInstantiationService;
|
||||||
#languageService: ILanguageService;
|
#languageService: ILanguageService;
|
||||||
#contextKeyService: IContextKeyService;
|
#contextKeyService: IContextKeyService;
|
||||||
|
#configurationService: IConfigurationService;
|
||||||
#notebookKernelService: INotebookKernelService;
|
#notebookKernelService: INotebookKernelService;
|
||||||
#keybindingService: IKeybindingService;
|
#keybindingService: IKeybindingService;
|
||||||
#menuService: IMenuService;
|
#menuService: IMenuService;
|
||||||
@@ -102,6 +105,7 @@ export class InteractiveEditor extends EditorPane {
|
|||||||
#extensionService: IExtensionService;
|
#extensionService: IExtensionService;
|
||||||
#widgetDisposableStore: DisposableStore = this._register(new DisposableStore());
|
#widgetDisposableStore: DisposableStore = this._register(new DisposableStore());
|
||||||
#lastLayoutDimensions?: { readonly dimension: DOM.Dimension; readonly position: DOM.IDomPosition };
|
#lastLayoutDimensions?: { readonly dimension: DOM.Dimension; readonly position: DOM.IDomPosition };
|
||||||
|
#editorOptions: IEditorOptions;
|
||||||
#notebookOptions: NotebookOptions;
|
#notebookOptions: NotebookOptions;
|
||||||
#editorMemento: IEditorMemento<InteractiveEditorViewState>;
|
#editorMemento: IEditorMemento<InteractiveEditorViewState>;
|
||||||
#groupListener = this._register(new DisposableStore());
|
#groupListener = this._register(new DisposableStore());
|
||||||
@@ -123,7 +127,7 @@ export class InteractiveEditor extends EditorPane {
|
|||||||
@INotebookKernelService notebookKernelService: INotebookKernelService,
|
@INotebookKernelService notebookKernelService: INotebookKernelService,
|
||||||
@ILanguageService languageService: ILanguageService,
|
@ILanguageService languageService: ILanguageService,
|
||||||
@IKeybindingService keybindingService: IKeybindingService,
|
@IKeybindingService keybindingService: IKeybindingService,
|
||||||
@IConfigurationService private configurationService: IConfigurationService,
|
@IConfigurationService configurationService: IConfigurationService,
|
||||||
@IMenuService menuService: IMenuService,
|
@IMenuService menuService: IMenuService,
|
||||||
@IContextMenuService contextMenuService: IContextMenuService,
|
@IContextMenuService contextMenuService: IContextMenuService,
|
||||||
@IEditorGroupsService editorGroupService: IEditorGroupsService,
|
@IEditorGroupsService editorGroupService: IEditorGroupsService,
|
||||||
@@ -140,6 +144,7 @@ export class InteractiveEditor extends EditorPane {
|
|||||||
this.#instantiationService = instantiationService;
|
this.#instantiationService = instantiationService;
|
||||||
this.#notebookWidgetService = notebookWidgetService;
|
this.#notebookWidgetService = notebookWidgetService;
|
||||||
this.#contextKeyService = contextKeyService;
|
this.#contextKeyService = contextKeyService;
|
||||||
|
this.#configurationService = configurationService;
|
||||||
this.#notebookKernelService = notebookKernelService;
|
this.#notebookKernelService = notebookKernelService;
|
||||||
this.#languageService = languageService;
|
this.#languageService = languageService;
|
||||||
this.#keybindingService = keybindingService;
|
this.#keybindingService = keybindingService;
|
||||||
@@ -149,6 +154,12 @@ export class InteractiveEditor extends EditorPane {
|
|||||||
this.#notebookExecutionStateService = notebookExecutionStateService;
|
this.#notebookExecutionStateService = notebookExecutionStateService;
|
||||||
this.#extensionService = extensionService;
|
this.#extensionService = extensionService;
|
||||||
|
|
||||||
|
this.#editorOptions = this.#computeEditorOptions();
|
||||||
|
this._register(this.#configurationService.onDidChangeConfiguration(e => {
|
||||||
|
if (e.affectsConfiguration('editor') || e.affectsConfiguration('notebook')) {
|
||||||
|
this.#editorOptions = this.#computeEditorOptions();
|
||||||
|
}
|
||||||
|
}));
|
||||||
this.#notebookOptions = new NotebookOptions(configurationService, notebookExecutionStateService, true, { cellToolbarInteraction: 'hover', globalToolbar: true, dragAndDropEnabled: false });
|
this.#notebookOptions = new NotebookOptions(configurationService, notebookExecutionStateService, true, { cellToolbarInteraction: 'hover', globalToolbar: true, dragAndDropEnabled: false });
|
||||||
this.#editorMemento = this.getEditorMemento<InteractiveEditorViewState>(editorGroupService, textResourceConfigurationService, INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY);
|
this.#editorMemento = this.getEditorMemento<InteractiveEditorViewState>(editorGroupService, textResourceConfigurationService, INTERACTIVE_EDITOR_VIEW_STATE_PREFERENCE_KEY);
|
||||||
|
|
||||||
@@ -259,6 +270,31 @@ export class InteractiveEditor extends EditorPane {
|
|||||||
this.#styleElement.textContent = styleSheets.join('\n');
|
this.#styleElement.textContent = styleSheets.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#computeEditorOptions(): IEditorOptions {
|
||||||
|
let overrideIdentifier: string | undefined = undefined;
|
||||||
|
if (this.#codeEditorWidget) {
|
||||||
|
overrideIdentifier = this.#codeEditorWidget.getModel()?.getLanguageId();
|
||||||
|
}
|
||||||
|
const editorOptions = deepClone(this.#configurationService.getValue<IEditorOptions>('editor', { overrideIdentifier }));
|
||||||
|
const editorOptionsOverride = getSimpleEditorOptions();
|
||||||
|
const computed = Object.freeze({
|
||||||
|
...editorOptions,
|
||||||
|
...editorOptionsOverride,
|
||||||
|
...{
|
||||||
|
glyphMargin: true,
|
||||||
|
padding: {
|
||||||
|
top: INPUT_EDITOR_PADDING,
|
||||||
|
bottom: INPUT_EDITOR_PADDING
|
||||||
|
},
|
||||||
|
hover: {
|
||||||
|
enabled: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return computed;
|
||||||
|
}
|
||||||
|
|
||||||
protected override saveState(): void {
|
protected override saveState(): void {
|
||||||
this.#saveEditorViewState(this.input);
|
this.#saveEditorViewState(this.input);
|
||||||
super.saveState();
|
super.saveState();
|
||||||
@@ -350,19 +386,7 @@ export class InteractiveEditor extends EditorPane {
|
|||||||
options: this.#notebookOptions
|
options: this.#notebookOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
this.#codeEditorWidget = this.#instantiationService.createInstance(CodeEditorWidget, this.#inputEditorContainer, {
|
this.#codeEditorWidget = this.#instantiationService.createInstance(CodeEditorWidget, this.#inputEditorContainer, this.#editorOptions, {
|
||||||
...getSimpleEditorOptions(),
|
|
||||||
...{
|
|
||||||
glyphMargin: true,
|
|
||||||
padding: {
|
|
||||||
top: INPUT_EDITOR_PADDING,
|
|
||||||
bottom: INPUT_EDITOR_PADDING
|
|
||||||
},
|
|
||||||
hover: {
|
|
||||||
enabled: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
...{
|
...{
|
||||||
isSimpleWidget: false,
|
isSimpleWidget: false,
|
||||||
contributions: EditorExtensionsRegistry.getSomeEditorContributions([
|
contributions: EditorExtensionsRegistry.getSomeEditorContributions([
|
||||||
@@ -438,6 +462,8 @@ export class InteractiveEditor extends EditorPane {
|
|||||||
if (viewState?.input) {
|
if (viewState?.input) {
|
||||||
this.#codeEditorWidget.restoreViewState(viewState.input);
|
this.#codeEditorWidget.restoreViewState(viewState.input);
|
||||||
}
|
}
|
||||||
|
this.#editorOptions = this.#computeEditorOptions();
|
||||||
|
this.#codeEditorWidget.updateOptions(this.#editorOptions);
|
||||||
|
|
||||||
this.#widgetDisposableStore.add(this.#codeEditorWidget.onDidFocusEditorWidget(() => this.#onDidFocusWidget.fire()));
|
this.#widgetDisposableStore.add(this.#codeEditorWidget.onDidFocusEditorWidget(() => this.#onDidFocusWidget.fire()));
|
||||||
this.#widgetDisposableStore.add(this.#codeEditorWidget.onDidContentSizeChange(e => {
|
this.#widgetDisposableStore.add(this.#codeEditorWidget.onDidContentSizeChange(e => {
|
||||||
@@ -536,7 +562,7 @@ export class InteractiveEditor extends EditorPane {
|
|||||||
const index = this.#notebookWidget.value!.getCellIndex(cvm);
|
const index = this.#notebookWidget.value!.getCellIndex(cvm);
|
||||||
if (index === this.#notebookWidget.value!.getLength() - 1) {
|
if (index === this.#notebookWidget.value!.getLength() - 1) {
|
||||||
// If we're already at the bottom or auto scroll is enabled, scroll to the bottom
|
// If we're already at the bottom or auto scroll is enabled, scroll to the bottom
|
||||||
if (this.configurationService.getValue<boolean>(InteractiveWindowSetting.interactiveWindowAlwaysScrollOnNewCell) || this.#cellAtBottom(cvm)) {
|
if (this.#configurationService.getValue<boolean>(InteractiveWindowSetting.interactiveWindowAlwaysScrollOnNewCell) || this.#cellAtBottom(cvm)) {
|
||||||
this.#notebookWidget.value!.scrollToBottom();
|
this.#notebookWidget.value!.scrollToBottom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user