Skip to content

Commit

Permalink
refactor: split modelEditor service override
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Jun 5, 2023
1 parent 242bd01 commit 3e6c5ec
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ await initialize({
})
```

Additionally, this library exposes 14 modules that include the vscode version of some services (with some glue to make it work with monaco):
Additionally, this library exposes 15 modules that include the vscode version of some services (with some glue to make it work with monaco):

- Notifications: `vscode/service-override/notifications`
- Dialogs: `vscode/service-override/dialogs`
- Model / Editor: `vscode/service-override/modelEditor`
- Model: `vscode/service-override/model`
- Editor: `vscode/service-override/editor`
- Configuration: `vscode/service-override/configuration`
- Keybindings: `vscode/service-override/keybindings`
- Languages: `vscode/service-override/languages`
Expand All @@ -77,7 +78,7 @@ Usage:

```typescript
import { initialize } from 'vscode/services'
import getModelEditorServiceOverride from 'vscode/service-override/modelEditor'
import getEditorServiceOverride from 'vscode/service-override/editor'
import getConfigurationServiceOverride, { updateUserConfiguration, configurationRegistry } from 'vscode/service-override/configuration'

await initialize({
Expand Down
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@
"types": "./dist/service-override/dialogs.d.ts",
"default": "./dist/service-override/dialogs.js"
},
"./service-override/modelEditor": {
"types": "./dist/service-override/modelEditor.d.ts",
"default": "./dist/service-override/modelEditor.js"
"./service-override/model": {
"types": "./dist/service-override/model.d.ts",
"default": "./dist/service-override/model.js"
},
"./service-override/editor": {
"types": "./dist/service-override/editor.d.ts",
"default": "./dist/service-override/editor.js"
},
"./service-override/files": {
"types": "./dist/service-override/files.d.ts",
Expand Down Expand Up @@ -114,8 +118,11 @@
"service-override/dialogs": [
"./dist/service-override/dialogs.d.ts"
],
"service-override/modelEditor": [
"./dist/service-override/modelEditor.d.ts"
"service-override/model": [
"./dist/service-override/model.d.ts"
],
"service-override/editor": [
"./dist/service-override/editor.d.ts"
],
"service-override/files": [
"./dist/service-override/files.d.ts"
Expand Down
3 changes: 2 additions & 1 deletion rollup/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ const input = {
services: './src/services.ts',
'service-override/notifications': './src/service-override/notifications.ts',
'service-override/dialogs': './src/service-override/dialogs.ts',
'service-override/modelEditor': './src/service-override/modelEditor.ts',
'service-override/model': './src/service-override/model.ts',
'service-override/editor': './src/service-override/editor.ts',
'service-override/files': './src/service-override/files.ts',
'service-override/configuration': './src/service-override/configuration.ts',
'service-override/keybindings': './src/service-override/keybindings.ts',
Expand Down
3 changes: 2 additions & 1 deletion rollup/rollup.types.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default rollup.defineConfig({
'./dist/types/src/extensions.d.ts',
'./dist/types/src/service-override/notifications.d.ts',
'./dist/types/src/service-override/dialogs.d.ts',
'./dist/types/src/service-override/modelEditor.d.ts',
'./dist/types/src/service-override/model.d.ts',
'./dist/types/src/service-override/editor.d.ts',
'./dist/types/src/service-override/files.d.ts',
'./dist/types/src/service-override/configuration.d.ts',
'./dist/types/src/service-override/keybindings.d.ts',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import '../vscode-services/missing-services'
import { IEditorOverrideServices, StandaloneServices } from 'vs/editor/standalone/browser/standaloneServices'
import { IResolvedTextEditorModel, ITextModelService } from 'vs/editor/common/services/resolverService'
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService'
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'
import { CodeEditorService } from 'vs/workbench/services/editor/browser/codeEditorService'
import { IEditorService, isPreferredGroup, PreferredGroup, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'
Expand Down Expand Up @@ -161,7 +160,6 @@ class EditorService extends Disposable implements IEditorService {

export default function getServiceOverride (openEditor: OpenEditor): IEditorOverrideServices {
return {
[ITextModelService.toString()]: new SyncDescriptor(TextModelResolverService, undefined, true),
[ICodeEditorService.toString()]: new SyncDescriptor(CodeEditorService, undefined, true),
[IEditorService.toString()]: new SyncDescriptor(EditorService, [openEditor]),
[ITextEditorService.toString()]: new SyncDescriptor(TextEditorService)
Expand Down
11 changes: 11 additions & 0 deletions src/service-override/model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import '../vscode-services/missing-services'
import { IEditorOverrideServices } from 'vs/editor/standalone/browser/standaloneServices'
import { ITextModelService } from 'vs/editor/common/services/resolverService'
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService'
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'

export default function getServiceOverride (): IEditorOverrideServices {
return {
[ITextModelService.toString()]: new SyncDescriptor(TextModelResolverService, undefined, true)
}
}
3 changes: 2 additions & 1 deletion tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"src/extensions.ts",
"src/service-override/notifications.ts",
"src/service-override/dialogs.ts",
"src/service-override/modelEditor.ts",
"src/service-override/model.ts",
"src/service-override/editor.ts",
"src/service-override/files.ts",
"src/service-override/configuration.ts",
"src/service-override/keybindings.ts",
Expand Down

0 comments on commit 3e6c5ec

Please sign in to comment.