From 959f7db0ee6dd89cb07e7547239a7728012c2639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Thu, 9 Nov 2023 14:57:09 +0100 Subject: [PATCH] fix(demo): initialize config and keybindings --- demo/src/main.ts | 6 +++-- demo/src/setup.ts | 68 +++++++++++++++++++++++------------------------ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/demo/src/main.ts b/demo/src/main.ts index 291f7905..58019148 100644 --- a/demo/src/main.ts +++ b/demo/src/main.ts @@ -5,6 +5,8 @@ import { registerFileSystemOverlay, HTMLFileSystemProvider } from '@codingame/mo import * as vscode from 'vscode' import { ILogService, StandaloneServices, IPreferencesService, IEditorService, IDialogService, getService } from 'vscode/services' import { ConfirmResult, Parts, isPartVisibile, setPartVisibility } from '@codingame/monaco-vscode-views-service-override' +import { defaultUserConfigurationFile } from '@codingame/monaco-vscode-configuration-service-override' +import { defaultUserKeybindindsFile } from '@codingame/monaco-vscode-keybindings-service-override' import { clearStorage, remoteAuthority } from './setup' import { CustomEditorInput } from './features/customView' import './features/debugger' @@ -94,7 +96,7 @@ diagnostics.set(modelRef.object.textEditorModel!.uri, [{ source: 'Demo', code: 42 }]) -const settingsModelReference = await createModelReference(monaco.Uri.from({ scheme: 'user-store', path: '/User/settings.json' })) +const settingsModelReference = await createModelReference(defaultUserConfigurationFile) const settingEditor = createConfiguredEditor(document.getElementById('settings-editor')!, { model: settingsModelReference.object.textEditorModel, automaticLayout: true @@ -112,7 +114,7 @@ settingEditor.addAction({ contextMenuGroupId: 'custom' }) -const keybindingsModelReference = await createModelReference(monaco.Uri.from({ scheme: 'user-store', path: '/User/keybindings.json' })) +const keybindingsModelReference = await createModelReference(defaultUserKeybindindsFile) createConfiguredEditor(document.getElementById('keybindings-editor')!, { model: keybindingsModelReference.object.textEditorModel, automaticLayout: true diff --git a/demo/src/setup.ts b/demo/src/setup.ts index be706a59..6b268ec0 100644 --- a/demo/src/setup.ts +++ b/demo/src/setup.ts @@ -3,8 +3,8 @@ import { initialize as initializeVscodeExtensions } from 'vscode/extensions' import getModelServiceOverride from '@codingame/monaco-vscode-model-service-override' import getNotificationServiceOverride from '@codingame/monaco-vscode-notifications-service-override' import getDialogsServiceOverride from '@codingame/monaco-vscode-dialogs-service-override' -import getConfigurationServiceOverride from '@codingame/monaco-vscode-configuration-service-override' -import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override' +import getConfigurationServiceOverride, { initUserConfiguration } from '@codingame/monaco-vscode-configuration-service-override' +import getKeybindingsServiceOverride, { initUserKeybindings } from '@codingame/monaco-vscode-keybindings-service-override' import getTextmateServiceOverride from '@codingame/monaco-vscode-textmate-service-override' import getThemeServiceOverride from '@codingame/monaco-vscode-theme-service-override' import getLanguagesServiceOverride from '@codingame/monaco-vscode-languages-service-override' @@ -35,7 +35,6 @@ import getRemoteAgentServiceOverride from '@codingame/monaco-vscode-remote-agent import getEnvironmentServiceOverride from '@codingame/monaco-vscode-environment-service-override' import getLifecycleServiceOverride from '@codingame/monaco-vscode-lifecycle-service-override' import getWorkspaceTrustOverride from '@codingame/monaco-vscode-workspace-trust-service-override' -import { registerCustomProvider, RegisteredFileSystemProvider, RegisteredMemoryFile } from '@codingame/monaco-vscode-files-service-override' import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker.js?worker' import TextMateWorker from '@codingame/monaco-vscode-textmate-service-override/worker?worker' import OutputLinkComputerWorker from '@codingame/monaco-vscode-output-service-override/worker?worker' @@ -70,38 +69,37 @@ const connectionToken = params.get('connectionToken') ?? undefined const remotePath = remoteAuthority != null ? params.get('remotePath') ?? undefined : undefined // Set configuration before initializing service so it's directly available (especially for the theme, to prevent a flicker) -const userFileSystemProvider = new RegisteredFileSystemProvider(false) -registerCustomProvider('user', userFileSystemProvider) -userFileSystemProvider.registerFile(new RegisteredMemoryFile(monaco.Uri.from({ scheme: 'user-store', path: '/User/settings.json' }), `{ - "workbench.colorTheme": "Default Dark+", - "workbench.iconTheme": "vs-seti", - "editor.autoClosingBrackets": "languageDefined", - "editor.autoClosingQuotes": "languageDefined", - "editor.scrollBeyondLastLine": true, - "editor.mouseWheelZoom": true, - "editor.wordBasedSuggestions": false, - "editor.acceptSuggestionOnEnter": "on", - "editor.foldingHighlight": false, - "editor.semanticHighlighting.enabled": true, - "editor.bracketPairColorization.enabled": false, - "editor.fontSize": 12, - "audioCues.lineHasError": "on", - "audioCues.onDebugBreak": "on", - "files.autoSave": "afterDelay", - "files.autoSaveDelay": 1000, - "debug.toolBarLocation": "docked", - "editor.experimental.asyncTokenization": true, - "terminal.integrated.tabs.title": "\${sequence}", - "typescript.tsserver.log": "normal" -}`)) - -userFileSystemProvider.registerFile(new RegisteredMemoryFile(monaco.Uri.from({ scheme: 'user-store', path: '/User/keybindings.json' }), `[ - { - "key": "ctrl+d", - "command": "editor.action.deleteLines", - "when": "editorTextFocus" - } -]`)) +await Promise.all([ + initUserConfiguration(`{ + "workbench.colorTheme": "Default Dark+", + "workbench.iconTheme": "vs-seti", + "editor.autoClosingBrackets": "languageDefined", + "editor.autoClosingQuotes": "languageDefined", + "editor.scrollBeyondLastLine": true, + "editor.mouseWheelZoom": true, + "editor.wordBasedSuggestions": false, + "editor.acceptSuggestionOnEnter": "on", + "editor.foldingHighlight": false, + "editor.semanticHighlighting.enabled": true, + "editor.bracketPairColorization.enabled": false, + "editor.fontSize": 12, + "audioCues.lineHasError": "on", + "audioCues.onDebugBreak": "on", + "files.autoSave": "afterDelay", + "files.autoSaveDelay": 1000, + "debug.toolBarLocation": "docked", + "editor.experimental.asyncTokenization": true, + "terminal.integrated.tabs.title": "\${sequence}", + "typescript.tsserver.log": "normal" + }`), + initUserKeybindings(`[ + { + "key": "ctrl+d", + "command": "editor.action.deleteLines", + "when": "editorTextFocus" + } + ]`) +]) // Override services await initializeMonacoService({