Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use same paths as vscode for settings #230

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ diagnostics.set(modelRef.object.textEditorModel!.uri, [{
code: 42
}])

const settingsModelReference = await createModelReference(monaco.Uri.from({ scheme: 'user', path: '/settings.json' }), `{
const settingsModelReference = await createModelReference(monaco.Uri.from({ scheme: 'user-store', path: '/User/settings.json' }), `{
"workbench.colorTheme": "Default Dark+",
"workbench.iconTheme": "vs-seti",
"editor.autoClosingBrackets": "languageDefined",
Expand Down Expand Up @@ -134,7 +134,7 @@ settingEditor.addAction({
contextMenuGroupId: 'custom'
})

const keybindingsModelReference = await createModelReference(monaco.Uri.from({ scheme: 'user', path: '/keybindings.json' }), `[
const keybindingsModelReference = await createModelReference(monaco.Uri.from({ scheme: 'user-store', path: '/User/keybindings.json' }), `[
CGNonofr marked this conversation as resolved.
Show resolved Hide resolved
{
"key": "ctrl+d",
"command": "editor.action.deleteLines",
Expand Down
51 changes: 27 additions & 24 deletions src/missing-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { IPreferencesService } from 'vs/workbench/services/preferences/common/pr
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'
import { StandaloneServices } from 'vs/editor/standalone/browser/standaloneServices'
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'
import { IUserDataProfile, IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile'
import { IUserDataProfilesService, toUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile'
import { IPolicyService } from 'vs/platform/policy/common/policy'
import { IUserDataProfileImportExportService, IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile'
import { UserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfileService'
Expand Down Expand Up @@ -172,6 +172,7 @@ import { BrowserHostService } from 'vs/workbench/services/host/browser/browserHo
import { IBannerService } from 'vs/workbench/services/banner/browser/bannerService'
import { ITitleService } from 'vs/workbench/services/title/common/titleService'
import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents'
import { joinPath } from 'vs/base/common/resources'
import { unsupported } from './tools'
import { getBuiltInExtensionTranslationsUris } from './l10n'

Expand Down Expand Up @@ -504,9 +505,11 @@ registerSingleton(IUserDataInitializationService, class NullUserDataInitializati

registerSingleton(IHostColorSchemeService, BrowserHostColorSchemeService, InstantiationType.Eager)

registerSingleton(IPreferencesService, class PreferencesService implements IPreferencesService {
class PreferencesService implements IPreferencesService {
constructor (@IUserDataProfileService protected readonly profileService: IUserDataProfileService) {}

_serviceBrand: undefined
userSettingsResource = profile.settingsResource
userSettingsResource = this.profileService.currentProfile.settingsResource
workspaceSettingsResource = null
getFolderSettingsResource = unsupported
createPreferencesEditorModel = unsupported
Expand All @@ -524,7 +527,9 @@ registerSingleton(IPreferencesService, class PreferencesService implements IPref
createSplitJsonEditorInput = unsupported
openApplicationSettings = unsupported
openLanguageSpecificSettings = unsupported
}, InstantiationType.Eager)
}

registerSingleton(IPreferencesService, PreferencesService, InstantiationType.Eager)

registerSingleton(ITextMateTokenizationService, class NullTextMateService implements ITextMateTokenizationService {
_serviceBrand: undefined
Expand All @@ -534,21 +539,9 @@ registerSingleton(ITextMateTokenizationService, class NullTextMateService implem
createTokenizer = unsupported
}, InstantiationType.Eager)

const profile: IUserDataProfile = {
id: 'default',
isDefault: true,
name: 'default',
location: URI.from({ scheme: 'user', path: '/profile.json' }),
globalStorageHome: URI.from({ scheme: 'user', path: '/globalStorage' }),
settingsResource: URI.from({ scheme: 'user', path: '/settings.json' }),
keybindingsResource: URI.from({ scheme: 'user', path: '/keybindings.json' }),
tasksResource: URI.from({ scheme: 'user', path: '/tasks.json' }),
snippetsHome: URI.from({ scheme: 'user', path: '/snippets' }),
extensionsResource: URI.from({ scheme: 'user', path: '/extensions.json' }),
cacheHome: URI.from({ scheme: 'cache', path: '/' })
}
class UserDataProfilesService implements IUserDataProfilesService {
constructor (@IUserDataProfileService protected readonly profileService: IUserDataProfileService) {}

registerSingleton(IUserDataProfilesService, class UserDataProfilesService implements IUserDataProfilesService {
_serviceBrand: undefined
onDidResetWorkspaces = Event.None
isEnabled = () => false
Expand All @@ -558,18 +551,28 @@ registerSingleton(IUserDataProfilesService, class UserDataProfilesService implem
cleanUp = unsupported
cleanUpTransientProfiles = unsupported
get profilesHome () { return unsupported() }
defaultProfile = profile
defaultProfile = this.profileService.currentProfile
onDidChangeProfiles = Event.None
profiles = [profile]
profiles = [this.profileService.currentProfile]
createProfile = unsupported
updateProfile = unsupported
setProfileForWorkspace = unsupported
getProfile = () => profile
getProfile = () => this.profileService.currentProfile
removeProfile = unsupported
}, InstantiationType.Eager)
}

registerSingleton(IUserDataProfilesService, UserDataProfilesService, InstantiationType.Eager)
class InjectedUserDataProfileService extends UserDataProfileService {
constructor () {
super(profile)
constructor (@IEnvironmentService environmentService: IEnvironmentService) {
super({
...toUserDataProfile(
'__default__profile__',
'Default',
environmentService.userRoamingDataHome,
joinPath(environmentService.cacheHome, 'CachedProfilesData')
),
isDefault: true
})
}
}
registerSingleton(IUserDataProfileService, InjectedUserDataProfileService, InstantiationType.Eager)
Expand Down
2 changes: 0 additions & 2 deletions src/service-override/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,7 @@ fileSystemProvider.register(0, new MkdirpOnWriteInMemoryFileSystemProvider())
const extensionFileSystemProvider = new RegisteredFileSystemProvider(true)

const providers: Record<string, IFileSystemProvider> = {
user: new InMemoryFileSystemProvider(),
extension: extensionFileSystemProvider,
cache: new InMemoryFileSystemProvider(),
logs: new InMemoryFileSystemProvider(),
[Schemas.vscodeUserData]: new InMemoryFileSystemProvider(),
[Schemas.tmp]: new InMemoryFileSystemProvider(),
Expand Down