Skip to content

Commit

Permalink
fix: add empty implementation
Browse files Browse the repository at this point in the history
to prevent crashes
  • Loading branch information
Loïc Mangeonjean committed Dec 11, 2023
1 parent ba507e0 commit abae48a
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 28 deletions.
73 changes: 57 additions & 16 deletions src/missing-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'
import { IFileService } from 'vs/platform/files/common/files'
import { GroupOrientation, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'
import { GroupOrientation, IEditorGroup, IEditorGroupsService, IEditorPart } from 'vs/workbench/services/editor/common/editorGroupsService'
import { IWorkingCopyFileService, WorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService'
import { IPathService } from 'vs/workbench/services/path/common/pathService'
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'
Expand Down Expand Up @@ -161,7 +161,7 @@ import { IChatVariablesService } from 'vs/workbench/contrib/chat/common/chatVari
import { IAiRelatedInformationService } from 'vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation'
import { IAiEmbeddingVectorService } from 'vs/workbench/services/aiEmbeddingVector/common/aiEmbeddingVectorService'
import { ResourceSet } from 'vs/base/common/map'
import { IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor'
import { DEFAULT_EDITOR_PART_OPTIONS, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor'
import { IMessage, ISignService } from 'vs/platform/sign/common/sign'
import { BrowserHostService } from 'vs/workbench/services/host/browser/browserHostService'
import { IBannerService } from 'vs/workbench/services/banner/browser/bannerService'
Expand Down Expand Up @@ -376,26 +376,67 @@ class EmptyEditorGroup implements IEditorGroup, IEditorGroupView {
}

const fakeActiveGroup = new EmptyEditorGroup()
class EmptyEditorGroupsService implements IEditorGroupsService {
onDidCreateAuxiliaryEditorPart = Event.None
parts = []

get activePart () {
return this
}
class EmptyEditorPart implements IEditorPart {
onDidLayout = Event.None
onDidScroll = Event.None
get contentDimension (): never { return unsupported() }
isReady = true
whenReady = Promise.resolve()
whenRestored = Promise.resolve()
hasRestorableState = false
centerLayout = unsupported
isLayoutCentered = unsupported
enforcePartOptions = unsupported
onDidChangeActiveGroup = Event.None
onDidAddGroup = Event.None
onDidRemoveGroup = Event.None
onDidMoveGroup = Event.None
onDidActivateGroup = Event.None
onDidChangeGroupIndex = Event.None
onDidChangeGroupLocked = Event.None
onDidChangeGroupMaximized = Event.None
activeGroup = fakeActiveGroup
get sideGroup (): never { return unsupported() }
groups = [fakeActiveGroup]
count = 0
orientation = GroupOrientation.HORIZONTAL
getGroups = () => []
getGroup = () => undefined
activateGroup = unsupported
getSize = unsupported
setSize = unsupported
arrangeGroups = unsupported
toggleMaximizeGroup = unsupported
toggleExpandGroup = unsupported
applyLayout = unsupported
getLayout = unsupported
setGroupOrientation = unsupported
findGroup = () => undefined
addGroup = unsupported
removeGroup = unsupported
moveGroup = unsupported
mergeGroup = unsupported
mergeAllGroups = unsupported
copyGroup = unsupported
partOptions = DEFAULT_EDITOR_PART_OPTIONS

get mainPart () {
return this
}
onDidChangeEditorPartOptions = Event.None
createEditorDropTarget = unsupported
}

class EmptyEditorGroupsService implements IEditorGroupsService {
onDidCreateAuxiliaryEditorPart = Event.None
mainPart = new EmptyEditorPart()
activePart = this.mainPart
parts = [this.mainPart]

getPart = unsupported
createAuxiliaryEditorPart = unsupported
onDidChangeGroupMaximized = Event.None
toggleMaximizeGroup = unsupported
toggleExpandGroup = unsupported
get partOptions () {
return unsupported()
}
partOptions = DEFAULT_EDITOR_PART_OPTIONS

createEditorDropTarget = unsupported
readonly _serviceBrand = undefined
Expand Down Expand Up @@ -1888,8 +1929,8 @@ registerSingleton(ICustomEditorService, class CustomEditorService implements ICu
getAllCustomEditors = unsupported
getContributedCustomEditors = unsupported
getUserConfiguredCustomEditors = unsupported
registerCustomEditorCapabilities = unsupported
getCustomEditorCapabilities = unsupported
registerCustomEditorCapabilities = () => Disposable.None
getCustomEditorCapabilities = () => undefined
}, InstantiationType.Delayed)

registerSingleton(IWebviewService, class WebviewService implements IWebviewService {
Expand Down
66 changes: 54 additions & 12 deletions src/service-override/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { IReference } from 'vs/base/common/lifecycle'
import { ITextEditorService, TextEditorService } from 'vs/workbench/services/textfile/common/textEditorService'
import { Registry } from 'vs/platform/registry/common/platform'
import { FILE_EDITOR_INPUT_ID } from 'vs/workbench/contrib/files/common/files'
import { GroupOrientation, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'
import { GroupOrientation, IEditorGroup, IEditorGroupsService, IEditorPart } from 'vs/workbench/services/editor/common/editorGroupsService'
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'
import { IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor'
import { DEFAULT_EDITOR_PART_OPTIONS, IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor'
import { MonacoDelegateEditorGroupsService, MonacoEditorService, OpenEditor } from './tools/editor'
import { unsupported } from '../tools'
import 'vs/workbench/browser/parts/editor/editor.contribution'
Expand Down Expand Up @@ -103,25 +103,67 @@ class EmptyEditorGroup implements IEditorGroup, IEditorGroupView {

const fakeActiveGroup = new EmptyEditorGroup()

class EmptyEditorPart implements IEditorPart {
onDidLayout = Event.None
onDidScroll = Event.None
get contentDimension (): never { return unsupported() }
isReady = true
whenReady = Promise.resolve()
whenRestored = Promise.resolve()
hasRestorableState = false
centerLayout = unsupported
isLayoutCentered = unsupported
enforcePartOptions = unsupported
onDidChangeActiveGroup = Event.None
onDidAddGroup = Event.None
onDidRemoveGroup = Event.None
onDidMoveGroup = Event.None
onDidActivateGroup = Event.None
onDidChangeGroupIndex = Event.None
onDidChangeGroupLocked = Event.None
onDidChangeGroupMaximized = Event.None
activeGroup = fakeActiveGroup
get sideGroup (): never { return unsupported() }
groups = [fakeActiveGroup]
count = 0
orientation = GroupOrientation.HORIZONTAL
getGroups = () => []
getGroup = () => undefined
activateGroup = unsupported
getSize = unsupported
setSize = unsupported
arrangeGroups = unsupported
toggleMaximizeGroup = unsupported
toggleExpandGroup = unsupported
applyLayout = unsupported
getLayout = unsupported
setGroupOrientation = unsupported
findGroup = () => undefined
addGroup = unsupported
removeGroup = unsupported
moveGroup = unsupported
mergeGroup = unsupported
mergeAllGroups = unsupported
copyGroup = unsupported
partOptions = DEFAULT_EDITOR_PART_OPTIONS

onDidChangeEditorPartOptions = Event.None
createEditorDropTarget = unsupported
}

class EmptyEditorGroupsService implements IEditorGroupsService {
onDidCreateAuxiliaryEditorPart = Event.None
parts = []
get activePart () {
return unsupported()
}

get mainPart () {
return unsupported()
}
mainPart = new EmptyEditorPart()
activePart = this.mainPart
parts = [this.mainPart]

getPart = unsupported
createAuxiliaryEditorPart = unsupported
onDidChangeGroupMaximized = Event.None
toggleMaximizeGroup = unsupported
toggleExpandGroup = unsupported
get partOptions () {
return unsupported()
}
partOptions = DEFAULT_EDITOR_PART_OPTIONS

createEditorDropTarget = unsupported
readonly _serviceBrand = undefined
Expand Down

0 comments on commit abae48a

Please sign in to comment.