mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
Merge pull request #181949 from r3m0t/interactive-window-compact-b
Interactive window- don't leave space for insert toolbar
This commit is contained in:
@@ -148,7 +148,7 @@ export class InteractiveEditor extends EditorPane {
|
||||
this.#notebookExecutionStateService = notebookExecutionStateService;
|
||||
this.#extensionService = extensionService;
|
||||
|
||||
this.#notebookOptions = new NotebookOptions(configurationService, notebookExecutionStateService, { 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);
|
||||
|
||||
codeEditorService.registerDecorationType('interactive-decoration', DECORATION_KEY, {});
|
||||
|
||||
@@ -151,7 +151,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
|
||||
@INotebookExecutionStateService notebookExecutionStateService: INotebookExecutionStateService,
|
||||
) {
|
||||
super(NotebookTextDiffEditor.ID, telemetryService, themeService, storageService);
|
||||
this._notebookOptions = new NotebookOptions(this.configurationService, notebookExecutionStateService);
|
||||
this._notebookOptions = new NotebookOptions(this.configurationService, notebookExecutionStateService, false);
|
||||
this._register(this._notebookOptions);
|
||||
const editorOptions = this.configurationService.getValue<ICodeEditorOptions>('editor');
|
||||
this._fontInfo = FontMeasurements.readFontInfo(BareFontInfo.createFromRawSettings(editorOptions, PixelRatio.value));
|
||||
|
||||
@@ -292,7 +292,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
|
||||
this.isEmbedded = creationOptions.isEmbedded ?? false;
|
||||
this._readOnly = creationOptions.isReadOnly ?? false;
|
||||
|
||||
this._notebookOptions = creationOptions.options ?? new NotebookOptions(this.configurationService, notebookExecutionStateService);
|
||||
this._notebookOptions = creationOptions.options ?? new NotebookOptions(this.configurationService, notebookExecutionStateService, this._readOnly);
|
||||
this._register(this._notebookOptions);
|
||||
this._viewContext = new ViewContext(
|
||||
this._notebookOptions,
|
||||
@@ -1176,6 +1176,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
|
||||
}
|
||||
|
||||
this.viewModel.updateOptions({ isReadOnly: this._readOnly });
|
||||
this.notebookOptions.updateOptions(this._readOnly);
|
||||
|
||||
// reveal cell if editor options tell to do so
|
||||
const cellOptions = options?.cellOptions ?? this._parseIndexedCellOptions(options);
|
||||
@@ -1364,6 +1365,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
|
||||
|
||||
this.viewModel = this.instantiationService.createInstance(NotebookViewModel, textModel.viewType, textModel, this._viewContext, this.getLayoutInfo(), { isReadOnly: this._readOnly });
|
||||
this._viewContext.eventDispatcher.emit([new NotebookLayoutChangedEvent({ width: true, fontInfo: true }, this.getLayoutInfo())]);
|
||||
this.notebookOptions.updateOptions(this._readOnly);
|
||||
|
||||
this._updateForOptions();
|
||||
this._updateForNotebookConfiguration();
|
||||
|
||||
@@ -133,6 +133,7 @@ export class NotebookOptions extends Disposable {
|
||||
constructor(
|
||||
private readonly configurationService: IConfigurationService,
|
||||
private readonly notebookExecutionStateService: INotebookExecutionStateService,
|
||||
private isReadonly: boolean,
|
||||
private readonly overrides?: { cellToolbarInteraction: string; globalToolbar: boolean; dragAndDropEnabled: boolean }
|
||||
) {
|
||||
super();
|
||||
@@ -145,7 +146,7 @@ export class NotebookOptions extends Disposable {
|
||||
const cellToolbarInteraction = overrides?.cellToolbarInteraction ?? this.configurationService.getValue<string>(NotebookSetting.cellToolbarVisibility);
|
||||
const compactView = this.configurationService.getValue<boolean | undefined>(NotebookSetting.compactView) ?? true;
|
||||
const focusIndicator = this._computeFocusIndicatorOption();
|
||||
const insertToolbarPosition = this._computeInsertToolbarPositionOption();
|
||||
const insertToolbarPosition = this._computeInsertToolbarPositionOption(this.isReadonly);
|
||||
const insertToolbarAlignment = this._computeInsertToolbarAlignmentOption();
|
||||
const showFoldingControls = this._computeShowFoldingControlsOption();
|
||||
// const { bottomToolbarGap, bottomToolbarHeight } = this._computeBottomToolbarDimensions(compactView, insertToolbarPosition, insertToolbarAlignment);
|
||||
@@ -248,6 +249,22 @@ export class NotebookOptions extends Disposable {
|
||||
}));
|
||||
}
|
||||
|
||||
updateOptions(isReadonly: boolean) {
|
||||
if (this.isReadonly !== isReadonly) {
|
||||
this.isReadonly = isReadonly;
|
||||
|
||||
this._updateConfiguration({
|
||||
affectsConfiguration(configuration: string): boolean {
|
||||
return configuration === NotebookSetting.insertToolbarLocation;
|
||||
},
|
||||
source: ConfigurationTarget.DEFAULT,
|
||||
affectedKeys: new Set([NotebookSetting.insertToolbarLocation]),
|
||||
change: { keys: [NotebookSetting.insertToolbarLocation], overrides: [] },
|
||||
sourceConfig: undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private _migrateDeprecatedSetting(deprecatedKey: string, key: string): void {
|
||||
const deprecatedSetting = this.configurationService.inspect(deprecatedKey);
|
||||
|
||||
@@ -390,7 +407,7 @@ export class NotebookOptions extends Disposable {
|
||||
}
|
||||
|
||||
if (insertToolbarPosition) {
|
||||
configuration.insertToolbarPosition = this._computeInsertToolbarPositionOption();
|
||||
configuration.insertToolbarPosition = this._computeInsertToolbarPositionOption(this.isReadonly);
|
||||
}
|
||||
|
||||
if (globalToolbar && this.overrides?.globalToolbar === undefined) {
|
||||
@@ -479,8 +496,8 @@ export class NotebookOptions extends Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
private _computeInsertToolbarPositionOption() {
|
||||
return this.configurationService.getValue<'betweenCells' | 'notebookToolbar' | 'both' | 'hidden'>(NotebookSetting.insertToolbarLocation) ?? 'both';
|
||||
private _computeInsertToolbarPositionOption(isReadOnly: boolean) {
|
||||
return isReadOnly ? 'hidden' : this.configurationService.getValue<'betweenCells' | 'notebookToolbar' | 'both' | 'hidden'>(NotebookSetting.insertToolbarLocation) ?? 'both';
|
||||
}
|
||||
|
||||
private _computeInsertToolbarAlignmentOption() {
|
||||
|
||||
@@ -202,7 +202,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
|
||||
// recompute
|
||||
this._ensureOutputsTop();
|
||||
const notebookLayoutConfiguration = this.viewContext.notebookOptions.getLayoutConfiguration();
|
||||
const bottomToolbarDimensions = this.viewContext.notebookOptions.computeBottomToolbarDimensions();
|
||||
const bottomToolbarDimensions = this.viewContext.notebookOptions.computeBottomToolbarDimensions(this.viewType);
|
||||
const outputShowMoreContainerHeight = state.outputShowMoreContainerHeight ? state.outputShowMoreContainerHeight : this._layoutInfo.outputShowMoreContainerHeight;
|
||||
const outputTotalHeight = Math.max(this._outputMinHeight, this.isOutputCollapsed ? notebookLayoutConfiguration.collapsedIndicatorHeight : this._outputsTop!.getTotalSum());
|
||||
const commentHeight = state.commentHeight ? this._commentHeight : this._layoutInfo.commentHeight;
|
||||
|
||||
@@ -21,7 +21,7 @@ suite('NotebookCellList', () => {
|
||||
suiteSetup(() => {
|
||||
disposables = new DisposableStore();
|
||||
instantiationService = setupInstantiationService(disposables);
|
||||
notebookDefaultOptions = new NotebookOptions(instantiationService.get(IConfigurationService), instantiationService.get(INotebookExecutionStateService));
|
||||
notebookDefaultOptions = new NotebookOptions(instantiationService.get(IConfigurationService), instantiationService.get(INotebookExecutionStateService), false);
|
||||
topInsertToolbarHeight = notebookDefaultOptions.computeTopInsertToolbarHeight();
|
||||
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ suite('NotebookViewModel', () => {
|
||||
test('ctor', function () {
|
||||
const notebook = new NotebookTextModel('notebook', URI.parse('test'), [], {}, { transientCellMetadata: {}, transientDocumentMetadata: {}, transientOutputs: false, cellContentMetadata: {} }, undoRedoService, modelService, languageService);
|
||||
const model = new NotebookEditorTestModel(notebook);
|
||||
const viewContext = new ViewContext(new NotebookOptions(instantiationService.get(IConfigurationService), instantiationService.get(INotebookExecutionStateService)), new NotebookEventDispatcher(), () => ({} as IBaseCellEditorOptions));
|
||||
const viewContext = new ViewContext(new NotebookOptions(instantiationService.get(IConfigurationService), instantiationService.get(INotebookExecutionStateService), false), new NotebookEventDispatcher(), () => ({} as IBaseCellEditorOptions));
|
||||
const viewModel = new NotebookViewModel('notebook', model.notebook, viewContext, null, { isReadOnly: false }, instantiationService, bulkEditService, undoRedoService, textModelService, notebookExecutionStateService);
|
||||
assert.strictEqual(viewModel.viewType, 'notebook');
|
||||
});
|
||||
|
||||
@@ -201,7 +201,7 @@ function _createTestNotebookEditor(instantiationService: TestInstantiationServic
|
||||
}), {}, { transientCellMetadata: {}, transientDocumentMetadata: {}, cellContentMetadata: {}, transientOutputs: false });
|
||||
|
||||
const model = new NotebookEditorTestModel(notebook);
|
||||
const notebookOptions = new NotebookOptions(instantiationService.get(IConfigurationService), instantiationService.get(INotebookExecutionStateService));
|
||||
const notebookOptions = new NotebookOptions(instantiationService.get(IConfigurationService), instantiationService.get(INotebookExecutionStateService), false);
|
||||
const viewContext = new ViewContext(notebookOptions, new NotebookEventDispatcher(), () => ({} as IBaseCellEditorOptions));
|
||||
const viewModel: NotebookViewModel = instantiationService.createInstance(NotebookViewModel, viewType, model.notebook, viewContext, null, { isReadOnly: false });
|
||||
|
||||
@@ -374,7 +374,7 @@ export function createNotebookCellList(instantiationService: TestInstantiationSe
|
||||
NotebookCellList,
|
||||
'NotebookCellList',
|
||||
DOM.$('container'),
|
||||
viewContext ?? new ViewContext(new NotebookOptions(instantiationService.get(IConfigurationService), instantiationService.get(INotebookExecutionStateService)), new NotebookEventDispatcher(), () => ({} as IBaseCellEditorOptions)),
|
||||
viewContext ?? new ViewContext(new NotebookOptions(instantiationService.get(IConfigurationService), instantiationService.get(INotebookExecutionStateService), false), new NotebookEventDispatcher(), () => ({} as IBaseCellEditorOptions)),
|
||||
delegate,
|
||||
[renderer],
|
||||
instantiationService.get<IContextKeyService>(IContextKeyService),
|
||||
|
||||
Reference in New Issue
Block a user