Skip to content

Commit

Permalink
Make Notebook preferences registration substitutable (#13926)
Browse files Browse the repository at this point in the history
Implement the commonly employed pattern for preference contribution
registration to enable substitution of the Notebook preference schema.

Fixes #13913

Signed-off-by: Christian W. Damus <cdamus.ext@eclipsesource.com>
  • Loading branch information
cdamus committed Jul 16, 2024
1 parent 8ad18ea commit 7f928f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
*--------------------------------------------------------------------------------------------*/

import { nls } from '@theia/core';
import { PreferenceSchema } from '@theia/core/lib/browser';
import { interfaces } from '@theia/core/shared/inversify';
import { PreferenceContribution, PreferenceSchema } from '@theia/core/lib/browser';

export namespace NotebookPreferences {
export const NOTEBOOK_LINE_NUMBERS = 'notebook.lineNumbers';
Expand Down Expand Up @@ -81,3 +82,11 @@ export const notebookPreferenceSchema: PreferenceSchema = {

}
};

export const NotebookPreferenceContribution = Symbol('NotebookPreferenceContribution');

export function bindNotebookPreferences(bind: interfaces.Bind): void {
// We don't need a NotebookPreferenceConfiguration class, so there's no preference proxy to bind
bind(NotebookPreferenceContribution).toConstantValue({ schema: notebookPreferenceSchema });
bind(PreferenceContribution).toService(NotebookPreferenceContribution);
}
6 changes: 3 additions & 3 deletions packages/notebook/src/browser/notebook-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import '../../src/browser/style/index.css';

import { ContainerModule } from '@theia/core/shared/inversify';
import { FrontendApplicationContribution, KeybindingContribution, LabelProviderContribution, OpenHandler, PreferenceContribution, WidgetFactory } from '@theia/core/lib/browser';
import { FrontendApplicationContribution, KeybindingContribution, LabelProviderContribution, OpenHandler, WidgetFactory } from '@theia/core/lib/browser';
import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution';
import { NotebookOpenHandler } from './notebook-open-handler';
import { CommandContribution, MenuContribution, ResourceResolver, } from '@theia/core';
Expand Down Expand Up @@ -44,7 +44,7 @@ import { NotebookOutlineContribution } from './contributions/notebook-outline-co
import { NotebookLabelProviderContribution } from './contributions/notebook-label-provider-contribution';
import { NotebookOutputActionContribution } from './contributions/notebook-output-action-contribution';
import { NotebookClipboardService } from './service/notebook-clipboard-service';
import { notebookPreferenceSchema } from './contributions/notebook-preferences';
import { bindNotebookPreferences } from './contributions/notebook-preferences';
import { NotebookOptionsService } from './service/notebook-options';

export default new ContainerModule((bind, unbind, isBound, rebind) => {
Expand Down Expand Up @@ -106,6 +106,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(NotebookLabelProviderContribution).toSelf().inSingletonScope();
bind(LabelProviderContribution).toService(NotebookLabelProviderContribution);

bind(PreferenceContribution).toConstantValue({ schema: notebookPreferenceSchema });
bindNotebookPreferences(bind);
bind(NotebookOptionsService).toSelf().inSingletonScope();
});

0 comments on commit 7f928f2

Please sign in to comment.