Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ad601533
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ad601533
编写于
9月 24, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
setting to ignore during sync
上级
a2862cf9
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
111 addition
and
67 deletion
+111
-67
src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
.../code/electron-browser/sharedProcess/sharedProcessMain.ts
+8
-6
src/vs/platform/userDataSync/common/extensionsSync.ts
src/vs/platform/userDataSync/common/extensionsSync.ts
+1
-2
src/vs/platform/userDataSync/common/settingsSync.ts
src/vs/platform/userDataSync/common/settingsSync.ts
+21
-22
src/vs/platform/userDataSync/common/settingsSyncIpc.ts
src/vs/platform/userDataSync/common/settingsSyncIpc.ts
+9
-3
src/vs/platform/userDataSync/common/userDataSync.ts
src/vs/platform/userDataSync/common/userDataSync.ts
+49
-1
src/vs/platform/userDataSync/common/userDataSyncService.ts
src/vs/platform/userDataSync/common/userDataSyncService.ts
+1
-2
src/vs/workbench/contrib/userDataSync/browser/userDataSync.contribution.ts
...contrib/userDataSync/browser/userDataSync.contribution.ts
+2
-23
src/vs/workbench/services/userDataSync/common/settingsMergeService.ts
...ench/services/userDataSync/common/settingsMergeService.ts
+20
-8
未找到文件。
src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
浏览文件 @
ad601533
...
@@ -51,7 +51,7 @@ import { IFileService } from 'vs/platform/files/common/files';
...
@@ -51,7 +51,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import
{
DiskFileSystemProvider
}
from
'
vs/platform/files/electron-browser/diskFileSystemProvider
'
;
import
{
DiskFileSystemProvider
}
from
'
vs/platform/files/electron-browser/diskFileSystemProvider
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/productService
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/productService
'
;
import
{
IUserDataSyncService
,
IUserDataSyncStoreService
,
ISettingsMergeService
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
IUserDataSyncService
,
IUserDataSyncStoreService
,
ISettingsMergeService
,
registerConfiguration
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
UserDataSyncService
,
UserDataAutoSync
}
from
'
vs/platform/userDataSync/common/userDataSyncService
'
;
import
{
UserDataSyncService
,
UserDataAutoSync
}
from
'
vs/platform/userDataSync/common/userDataSyncService
'
;
import
{
UserDataSyncStoreService
}
from
'
vs/platform/userDataSync/common/userDataSyncStoreService
'
;
import
{
UserDataSyncStoreService
}
from
'
vs/platform/userDataSync/common/userDataSyncStoreService
'
;
import
{
UserDataSyncChannel
}
from
'
vs/platform/userDataSync/common/userDataSyncIpc
'
;
import
{
UserDataSyncChannel
}
from
'
vs/platform/userDataSync/common/userDataSyncIpc
'
;
...
@@ -122,11 +122,6 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
...
@@ -122,11 +122,6 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
const
windowsService
=
new
WindowsService
(
mainProcessService
);
const
windowsService
=
new
WindowsService
(
mainProcessService
);
services
.
set
(
IWindowsService
,
windowsService
);
services
.
set
(
IWindowsService
,
windowsService
);
const
activeWindowManager
=
new
ActiveWindowManager
(
windowsService
);
const
activeWindowRouter
=
new
StaticRouter
(
ctx
=>
activeWindowManager
.
getActiveClientId
().
then
(
id
=>
ctx
===
id
));
const
settingsMergeChannel
=
server
.
getChannel
(
'
settingsMerge
'
,
activeWindowRouter
);
services
.
set
(
ISettingsMergeService
,
new
SettingsMergeChannelClient
(
settingsMergeChannel
));
// Files
// Files
const
fileService
=
new
FileService
(
logService
);
const
fileService
=
new
FileService
(
logService
);
services
.
set
(
IFileService
,
fileService
);
services
.
set
(
IFileService
,
fileService
);
...
@@ -173,8 +168,15 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
...
@@ -173,8 +168,15 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
services
.
set
(
IExtensionGalleryService
,
new
SyncDescriptor
(
ExtensionGalleryService
));
services
.
set
(
IExtensionGalleryService
,
new
SyncDescriptor
(
ExtensionGalleryService
));
services
.
set
(
ILocalizationsService
,
new
SyncDescriptor
(
LocalizationsService
));
services
.
set
(
ILocalizationsService
,
new
SyncDescriptor
(
LocalizationsService
));
services
.
set
(
IDiagnosticsService
,
new
SyncDescriptor
(
DiagnosticsService
));
services
.
set
(
IDiagnosticsService
,
new
SyncDescriptor
(
DiagnosticsService
));
// User Data Sync Contributions
const
activeWindowManager
=
new
ActiveWindowManager
(
windowsService
);
const
activeWindowRouter
=
new
StaticRouter
(
ctx
=>
activeWindowManager
.
getActiveClientId
().
then
(
id
=>
ctx
===
id
));
const
settingsMergeChannel
=
server
.
getChannel
(
'
settingsMerge
'
,
activeWindowRouter
);
services
.
set
(
ISettingsMergeService
,
new
SettingsMergeChannelClient
(
settingsMergeChannel
));
services
.
set
(
IUserDataSyncStoreService
,
new
SyncDescriptor
(
UserDataSyncStoreService
));
services
.
set
(
IUserDataSyncStoreService
,
new
SyncDescriptor
(
UserDataSyncStoreService
));
services
.
set
(
IUserDataSyncService
,
new
SyncDescriptor
(
UserDataSyncService
));
services
.
set
(
IUserDataSyncService
,
new
SyncDescriptor
(
UserDataSyncService
));
registerConfiguration
();
const
instantiationService2
=
instantiationService
.
createChild
(
services
);
const
instantiationService2
=
instantiationService
.
createChild
(
services
);
...
...
src/vs/platform/userDataSync/common/extensionsSync.ts
浏览文件 @
ad601533
...
@@ -70,8 +70,7 @@ export class ExtensionsSynchroniser extends Disposable implements ISynchroniser
...
@@ -70,8 +70,7 @@ export class ExtensionsSynchroniser extends Disposable implements ISynchroniser
}
}
async
sync
():
Promise
<
boolean
>
{
async
sync
():
Promise
<
boolean
>
{
const
syncExtensions
=
this
.
configurationService
.
getValue
<
boolean
>
(
'
userConfiguration.syncExtensions
'
);
if
(
!
this
.
configurationService
.
getValue
<
boolean
>
(
'
userConfiguration.syncExtensions
'
))
{
if
(
syncExtensions
===
false
)
{
return
false
;
return
false
;
}
}
...
...
src/vs/platform/userDataSync/common/settingsSync.ts
浏览文件 @
ad601533
...
@@ -15,6 +15,8 @@ import { CancelablePromise, createCancelablePromise, ThrottledDelayer } from 'vs
...
@@ -15,6 +15,8 @@ import { CancelablePromise, createCancelablePromise, ThrottledDelayer } from 'vs
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
joinPath
}
from
'
vs/base/common/resources
'
;
import
{
joinPath
}
from
'
vs/base/common/resources
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
interface
ISyncPreviewResult
{
interface
ISyncPreviewResult
{
readonly
fileContent
:
IFileContent
|
null
;
readonly
fileContent
:
IFileContent
|
null
;
...
@@ -47,6 +49,7 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser {
...
@@ -47,6 +49,7 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser {
@
IUserDataSyncStoreService
private
readonly
userDataSyncStoreService
:
IUserDataSyncStoreService
,
@
IUserDataSyncStoreService
private
readonly
userDataSyncStoreService
:
IUserDataSyncStoreService
,
@
ISettingsMergeService
private
readonly
settingsMergeService
:
ISettingsMergeService
,
@
ISettingsMergeService
private
readonly
settingsMergeService
:
ISettingsMergeService
,
@
ILogService
private
readonly
logService
:
ILogService
,
@
ILogService
private
readonly
logService
:
ILogService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
,
)
{
)
{
super
();
super
();
this
.
lastSyncSettingsResource
=
joinPath
(
this
.
environmentService
.
userRoamingDataHome
,
'
.lastSyncSettings.json
'
);
this
.
lastSyncSettingsResource
=
joinPath
(
this
.
environmentService
.
userRoamingDataHome
,
'
.lastSyncSettings.json
'
);
...
@@ -135,7 +138,8 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser {
...
@@ -135,7 +138,8 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser {
let
{
fileContent
,
remoteUserData
,
hasLocalChanged
,
hasRemoteChanged
}
=
await
this
.
syncPreviewResultPromise
;
let
{
fileContent
,
remoteUserData
,
hasLocalChanged
,
hasRemoteChanged
}
=
await
this
.
syncPreviewResultPromise
;
if
(
hasRemoteChanged
)
{
if
(
hasRemoteChanged
)
{
const
ref
=
await
this
.
writeToRemote
(
content
,
remoteUserData
.
ref
);
const
remoteContent
=
remoteUserData
.
content
?
await
this
.
settingsMergeService
.
computeRemoteContent
(
content
,
remoteUserData
.
content
,
this
.
getIgnoredSettings
())
:
content
;
const
ref
=
await
this
.
writeToRemote
(
remoteContent
,
remoteUserData
.
ref
);
remoteUserData
=
{
ref
,
content
};
remoteUserData
=
{
ref
,
content
};
}
}
if
(
hasLocalChanged
)
{
if
(
hasLocalChanged
)
{
...
@@ -176,45 +180,40 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser {
...
@@ -176,45 +180,40 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser {
let
hasRemoteChanged
:
boolean
=
false
;
let
hasRemoteChanged
:
boolean
=
false
;
let
hasConflicts
:
boolean
=
false
;
let
hasConflicts
:
boolean
=
false
;
// First time sync to remote
if
(
remoteContent
)
{
if
(
fileContent
&&
!
remoteContent
)
{
const
localContent
:
string
=
fileContent
?
fileContent
.
value
.
toString
()
:
'
{}
'
;
this
.
logService
.
trace
(
'
Settings Sync: Remote contents does not exist. So sync with settings file.
'
);
hasRemoteChanged
=
true
;
await
this
.
fileService
.
writeFile
(
this
.
environmentService
.
settingsSyncPreviewResource
,
VSBuffer
.
fromString
(
fileContent
.
value
.
toString
()));
return
{
fileContent
,
remoteUserData
,
hasLocalChanged
,
hasRemoteChanged
,
hasConflicts
};
}
// Settings file does not exist, so sync with remote contents.
if
(
remoteContent
&&
!
fileContent
)
{
this
.
logService
.
trace
(
'
Settings Sync: Settings file does not exist. So sync with remote contents
'
);
hasLocalChanged
=
true
;
await
this
.
fileService
.
writeFile
(
this
.
environmentService
.
settingsSyncPreviewResource
,
VSBuffer
.
fromString
(
remoteContent
));
return
{
fileContent
,
remoteUserData
,
hasLocalChanged
,
hasRemoteChanged
,
hasConflicts
};
}
if
(
fileContent
&&
remoteContent
)
{
const
localContent
:
string
=
fileContent
.
value
.
toString
();
if
(
!
lastSyncData
// First time sync
if
(
!
lastSyncData
// First time sync
||
lastSyncData
.
content
!==
localContent
// Local has moved forwarded
||
lastSyncData
.
content
!==
localContent
// Local has moved forwarded
||
lastSyncData
.
content
!==
remoteContent
// Remote has moved forwarded
||
lastSyncData
.
content
!==
remoteContent
// Remote has moved forwarded
)
{
)
{
this
.
logService
.
trace
(
'
Settings Sync: Merging remote contents with settings file.
'
);
this
.
logService
.
trace
(
'
Settings Sync: Merging remote contents with settings file.
'
);
const
result
=
await
this
.
settingsMergeService
.
merge
(
localContent
,
remoteContent
,
lastSyncData
?
lastSyncData
.
content
:
null
);
const
result
=
await
this
.
settingsMergeService
.
merge
(
localContent
,
remoteContent
,
lastSyncData
?
lastSyncData
.
content
:
null
,
this
.
getIgnoredSettings
()
);
// Sync only if there are changes
// Sync only if there are changes
if
(
result
.
hasChanges
)
{
if
(
result
.
hasChanges
)
{
hasLocalChanged
=
result
.
mergeContent
!==
localContent
;
hasLocalChanged
=
result
.
mergeContent
!==
localContent
;
hasRemoteChanged
=
result
.
mergeContent
!==
remoteContent
;
hasRemoteChanged
=
result
.
mergeContent
!==
remoteContent
;
hasConflicts
=
result
.
hasConflicts
;
hasConflicts
=
result
.
hasConflicts
;
await
this
.
fileService
.
writeFile
(
this
.
environmentService
.
settingsSyncPreviewResource
,
VSBuffer
.
fromString
(
result
.
mergeContent
));
await
this
.
fileService
.
writeFile
(
this
.
environmentService
.
settingsSyncPreviewResource
,
VSBuffer
.
fromString
(
result
.
mergeContent
));
return
{
fileContent
,
remoteUserData
,
hasLocalChanged
,
hasRemoteChanged
,
hasConflicts
};
}
}
}
}
return
{
fileContent
,
remoteUserData
,
hasLocalChanged
,
hasRemoteChanged
,
hasConflicts
};
}
// First time sync to remote
if
(
fileContent
)
{
this
.
logService
.
trace
(
'
Settings Sync: Remote contents does not exist. So sync with settings file.
'
);
hasRemoteChanged
=
true
;
await
this
.
fileService
.
writeFile
(
this
.
environmentService
.
settingsSyncPreviewResource
,
VSBuffer
.
fromString
(
fileContent
.
value
.
toString
()));
return
{
fileContent
,
remoteUserData
,
hasLocalChanged
,
hasRemoteChanged
,
hasConflicts
};
}
}
this
.
logService
.
trace
(
'
Settings Sync: No changes.
'
);
return
{
fileContent
,
remoteUserData
,
hasLocalChanged
,
hasRemoteChanged
,
hasConflicts
};
return
{
fileContent
,
remoteUserData
,
hasLocalChanged
,
hasRemoteChanged
,
hasConflicts
};
}
}
private
getIgnoredSettings
():
IStringDictionary
<
boolean
>
{
return
this
.
configurationService
.
getValue
<
IStringDictionary
<
boolean
>>
(
'
userConfiguration.ignoreSettings
'
);
}
private
async
getLastSyncUserData
():
Promise
<
IUserData
|
null
>
{
private
async
getLastSyncUserData
():
Promise
<
IUserData
|
null
>
{
try
{
try
{
const
content
=
await
this
.
fileService
.
readFile
(
this
.
lastSyncSettingsResource
);
const
content
=
await
this
.
fileService
.
readFile
(
this
.
lastSyncSettingsResource
);
...
...
src/vs/platform/userDataSync/common/settingsSyncIpc.ts
浏览文件 @
ad601533
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
import
{
IChannel
,
IServerChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
IChannel
,
IServerChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
ISettingsMergeService
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
ISettingsMergeService
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
export
class
SettingsMergeChannel
implements
IServerChannel
{
export
class
SettingsMergeChannel
implements
IServerChannel
{
...
@@ -17,7 +18,8 @@ export class SettingsMergeChannel implements IServerChannel {
...
@@ -17,7 +18,8 @@ export class SettingsMergeChannel implements IServerChannel {
call
(
context
:
any
,
command
:
string
,
args
?:
any
):
Promise
<
any
>
{
call
(
context
:
any
,
command
:
string
,
args
?:
any
):
Promise
<
any
>
{
switch
(
command
)
{
switch
(
command
)
{
case
'
merge
'
:
return
this
.
service
.
merge
(
args
[
0
],
args
[
1
],
args
[
2
]);
case
'
merge
'
:
return
this
.
service
.
merge
(
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
]);
case
'
computeRemoteContent
'
:
return
this
.
service
.
computeRemoteContent
(
args
[
0
],
args
[
1
],
args
[
2
]);
}
}
throw
new
Error
(
'
Invalid call
'
);
throw
new
Error
(
'
Invalid call
'
);
}
}
...
@@ -30,8 +32,12 @@ export class SettingsMergeChannelClient implements ISettingsMergeService {
...
@@ -30,8 +32,12 @@ export class SettingsMergeChannelClient implements ISettingsMergeService {
constructor
(
private
readonly
channel
:
IChannel
)
{
constructor
(
private
readonly
channel
:
IChannel
)
{
}
}
merge
(
localContent
:
string
,
remoteContent
:
string
,
baseContent
:
string
|
null
):
Promise
<
{
mergeContent
:
string
,
hasChanges
:
boolean
,
hasConflicts
:
boolean
}
>
{
merge
(
localContent
:
string
,
remoteContent
:
string
,
baseContent
:
string
|
null
,
ignoredSettings
:
IStringDictionary
<
boolean
>
):
Promise
<
{
mergeContent
:
string
,
hasChanges
:
boolean
,
hasConflicts
:
boolean
}
>
{
return
this
.
channel
.
call
(
'
merge
'
,
[
localContent
,
remoteContent
,
baseContent
]);
return
this
.
channel
.
call
(
'
merge
'
,
[
localContent
,
remoteContent
,
baseContent
,
ignoredSettings
]);
}
computeRemoteContent
(
localContent
:
string
,
remoteContent
:
string
,
ignoredSettings
:
IStringDictionary
<
boolean
>
):
Promise
<
string
>
{
return
this
.
channel
.
call
(
'
computeRemoteContent
'
,
[
localContent
,
remoteContent
,
ignoredSettings
]);
}
}
}
}
src/vs/platform/userDataSync/common/userDataSync.ts
浏览文件 @
ad601533
...
@@ -7,6 +7,52 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
...
@@ -7,6 +7,52 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IExtensionIdentifier
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
IExtensionIdentifier
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IConfigurationRegistry
,
Extensions
as
ConfigurationExtensions
,
ConfigurationScope
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
localize
}
from
'
vs/nls
'
;
export
function
registerConfiguration
()
{
Registry
.
as
<
IConfigurationRegistry
>
(
ConfigurationExtensions
.
Configuration
)
.
registerConfiguration
({
id
:
'
userConfiguration
'
,
order
:
30
,
title
:
localize
(
'
userConfiguration
'
,
"
User Configuration
"
),
type
:
'
object
'
,
properties
:
{
'
userConfiguration.enableSync
'
:
{
type
:
'
boolean
'
,
description
:
localize
(
'
userConfiguration.enableSync
'
,
"
When enabled, synchronises User Configuration: Settings, Keybindings, Extensions & Snippets.
"
),
default
:
true
,
scope
:
ConfigurationScope
.
APPLICATION
},
'
userConfiguration.syncExtensions
'
:
{
type
:
'
boolean
'
,
description
:
localize
(
'
userConfiguration.syncExtensions
'
,
"
When enabled extensions are synchronised while synchronising user configuration.
"
),
default
:
true
,
scope
:
ConfigurationScope
.
APPLICATION
,
},
'
userConfiguration.ignoreSettings
'
:
{
'
type
'
:
'
object
'
,
description
:
localize
(
'
userConfiguration.ignoreSettings
'
,
"
Configure settings to be ignored while syncing
"
),
'
default
'
:
{
'
userConfiguration.enableSync
'
:
true
,
'
userConfiguration.syncExtensions
'
:
true
,
'
userConfiguration.ignoreSettings
'
:
true
},
'
scope
'
:
ConfigurationScope
.
APPLICATION
,
'
additionalProperties
'
:
{
'
anyOf
'
:
[
{
'
type
'
:
'
boolean
'
,
'
description
'
:
localize
(
'
ignoredSetting
'
,
"
Id of the stting to be ignored. Set to true or false to enable or disable.
"
),
}
]
}
}
}
});
}
export
interface
IUserData
{
export
interface
IUserData
{
ref
:
string
;
ref
:
string
;
...
@@ -85,7 +131,9 @@ export interface ISettingsMergeService {
...
@@ -85,7 +131,9 @@ export interface ISettingsMergeService {
_serviceBrand
:
undefined
;
_serviceBrand
:
undefined
;
merge
(
localContent
:
string
,
remoteContent
:
string
,
baseContent
:
string
|
null
):
Promise
<
{
mergeContent
:
string
,
hasChanges
:
boolean
,
hasConflicts
:
boolean
}
>
;
merge
(
localContent
:
string
,
remoteContent
:
string
,
baseContent
:
string
|
null
,
ignoredSettings
:
IStringDictionary
<
boolean
>
):
Promise
<
{
mergeContent
:
string
,
hasChanges
:
boolean
,
hasConflicts
:
boolean
}
>
;
computeRemoteContent
(
localContent
:
string
,
remoteContent
:
string
,
ignoredSettings
:
IStringDictionary
<
boolean
>
):
Promise
<
string
>
;
}
}
...
...
src/vs/platform/userDataSync/common/userDataSyncService.ts
浏览文件 @
ad601533
...
@@ -134,8 +134,7 @@ export class UserDataAutoSync extends Disposable {
...
@@ -134,8 +134,7 @@ export class UserDataAutoSync extends Disposable {
}
}
private
isSyncEnabled
():
boolean
{
private
isSyncEnabled
():
boolean
{
const
{
user
:
userLocal
}
=
this
.
configurationService
.
inspect
<
boolean
>
(
'
userConfiguration.enableSync
'
);
return
this
.
configurationService
.
getValue
<
boolean
>
(
'
userConfiguration.enableSync
'
);
return
userLocal
===
undefined
||
userLocal
;
}
}
}
}
src/vs/workbench/contrib/userDataSync/browser/userDataSync.contribution.ts
浏览文件 @
ad601533
...
@@ -4,13 +4,12 @@
...
@@ -4,13 +4,12 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
,
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
,
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IUserDataSyncService
,
SyncStatus
,
SyncSource
,
CONTEXT_SYNC_STATE
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
IUserDataSyncService
,
SyncStatus
,
SyncSource
,
CONTEXT_SYNC_STATE
,
registerConfiguration
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
Disposable
,
MutableDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
MutableDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IConfigurationRegistry
,
Extensions
as
ConfigurationExtensions
,
ConfigurationScope
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
MenuRegistry
,
MenuId
,
IMenuItem
}
from
'
vs/platform/actions/common/actions
'
;
import
{
MenuRegistry
,
MenuId
,
IMenuItem
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IContextKeyService
,
IContextKey
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKeyService
,
IContextKey
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
@@ -37,27 +36,7 @@ class UserDataSyncConfigurationContribution implements IWorkbenchContribution {
...
@@ -37,27 +36,7 @@ class UserDataSyncConfigurationContribution implements IWorkbenchContribution {
@
IProductService
productService
:
IProductService
@
IProductService
productService
:
IProductService
)
{
)
{
if
(
productService
.
settingsSyncStoreUrl
)
{
if
(
productService
.
settingsSyncStoreUrl
)
{
Registry
.
as
<
IConfigurationRegistry
>
(
ConfigurationExtensions
.
Configuration
)
registerConfiguration
();
.
registerConfiguration
({
id
:
'
userConfiguration
'
,
order
:
30
,
title
:
localize
(
'
userConfiguration
'
,
"
User Configuration
"
),
type
:
'
object
'
,
properties
:
{
'
userConfiguration.enableSync
'
:
{
type
:
'
boolean
'
,
description
:
localize
(
'
userConfiguration.enableSync
'
,
"
When enabled, synchronises User Configuration: Settings, Keybindings, Extensions & Snippets.
"
),
default
:
true
,
scope
:
ConfigurationScope
.
APPLICATION
},
'
userConfiguration.syncExtensions
'
:
{
type
:
'
boolean
'
,
description
:
localize
(
'
userConfiguration.syncExtensions
'
,
"
When enabled extensions are synchronised while synchronising user configuration.
"
),
default
:
true
,
scope
:
ConfigurationScope
.
APPLICATION
}
}
});
}
}
}
}
}
}
...
...
src/vs/workbench/services/userDataSync/common/settingsMergeService.ts
浏览文件 @
ad601533
...
@@ -24,23 +24,23 @@ class SettingsMergeService implements ISettingsMergeService {
...
@@ -24,23 +24,23 @@ class SettingsMergeService implements ISettingsMergeService {
constructor
(
constructor
(
@
IModelService
private
readonly
modelService
:
IModelService
,
@
IModelService
private
readonly
modelService
:
IModelService
,
@
IModeService
private
readonly
modeService
:
IModeService
@
IModeService
private
readonly
modeService
:
IModeService
,
)
{
}
)
{
}
async
merge
(
localContent
:
string
,
remoteContent
:
string
,
baseContent
:
string
|
null
):
Promise
<
{
mergeContent
:
string
,
hasChanges
:
boolean
,
hasConflicts
:
boolean
}
>
{
async
merge
(
localContent
:
string
,
remoteContent
:
string
,
baseContent
:
string
|
null
,
ignoredSettings
:
IStringDictionary
<
boolean
>
):
Promise
<
{
mergeContent
:
string
,
hasChanges
:
boolean
,
hasConflicts
:
boolean
}
>
{
const
local
=
parse
(
localContent
);
const
local
=
parse
(
localContent
);
const
remote
=
parse
(
remoteContent
);
const
remote
=
parse
(
remoteContent
);
const
base
=
baseContent
?
parse
(
baseContent
)
:
null
;
const
base
=
baseContent
?
parse
(
baseContent
)
:
null
;
const
localToRemote
=
this
.
compare
(
local
,
remote
);
const
localToRemote
=
this
.
compare
(
local
,
remote
,
ignoredSettings
);
if
(
localToRemote
.
added
.
size
===
0
&&
localToRemote
.
removed
.
size
===
0
&&
localToRemote
.
updated
.
size
===
0
)
{
if
(
localToRemote
.
added
.
size
===
0
&&
localToRemote
.
removed
.
size
===
0
&&
localToRemote
.
updated
.
size
===
0
)
{
// No changes found between local and remote.
// No changes found between local and remote.
return
{
mergeContent
:
localContent
,
hasChanges
:
false
,
hasConflicts
:
false
};
return
{
mergeContent
:
localContent
,
hasChanges
:
false
,
hasConflicts
:
false
};
}
}
const
conflicts
:
Set
<
string
>
=
new
Set
<
string
>
();
const
conflicts
:
Set
<
string
>
=
new
Set
<
string
>
();
const
baseToLocal
=
base
?
this
.
compare
(
base
,
local
)
:
{
added
:
Object
.
keys
(
local
).
reduce
((
r
,
k
)
=>
{
r
.
add
(
k
);
return
r
;
},
new
Set
<
string
>
()),
removed
:
new
Set
<
string
>
(),
updated
:
new
Set
<
string
>
()
};
const
baseToLocal
=
base
?
this
.
compare
(
base
,
local
,
ignoredSettings
)
:
{
added
:
Object
.
keys
(
local
).
reduce
((
r
,
k
)
=>
{
r
.
add
(
k
);
return
r
;
},
new
Set
<
string
>
()),
removed
:
new
Set
<
string
>
(),
updated
:
new
Set
<
string
>
()
};
const
baseToRemote
=
base
?
this
.
compare
(
base
,
remote
)
:
{
added
:
Object
.
keys
(
remote
).
reduce
((
r
,
k
)
=>
{
r
.
add
(
k
);
return
r
;
},
new
Set
<
string
>
()),
removed
:
new
Set
<
string
>
(),
updated
:
new
Set
<
string
>
()
};
const
baseToRemote
=
base
?
this
.
compare
(
base
,
remote
,
ignoredSettings
)
:
{
added
:
Object
.
keys
(
remote
).
reduce
((
r
,
k
)
=>
{
r
.
add
(
k
);
return
r
;
},
new
Set
<
string
>
()),
removed
:
new
Set
<
string
>
(),
updated
:
new
Set
<
string
>
()
};
const
settingsPreviewModel
=
this
.
modelService
.
createModel
(
localContent
,
this
.
modeService
.
create
(
'
jsonc
'
));
const
settingsPreviewModel
=
this
.
modelService
.
createModel
(
localContent
,
this
.
modeService
.
create
(
'
jsonc
'
));
// Removed settings in Local
// Removed settings in Local
...
@@ -151,6 +151,18 @@ class SettingsMergeService implements ISettingsMergeService {
...
@@ -151,6 +151,18 @@ class SettingsMergeService implements ISettingsMergeService {
return
{
mergeContent
:
settingsPreviewModel
.
getValue
(),
hasChanges
:
true
,
hasConflicts
:
conflicts
.
size
>
0
};
return
{
mergeContent
:
settingsPreviewModel
.
getValue
(),
hasChanges
:
true
,
hasConflicts
:
conflicts
.
size
>
0
};
}
}
async
computeRemoteContent
(
localContent
:
string
,
remoteContent
:
string
,
ignoredSettings
:
IStringDictionary
<
boolean
>
):
Promise
<
string
>
{
const
remote
=
parse
(
remoteContent
);
const
remoteModel
=
this
.
modelService
.
createModel
(
localContent
,
this
.
modeService
.
create
(
'
jsonc
'
));
for
(
const
key
of
Object
.
keys
(
ignoredSettings
))
{
if
(
ignoredSettings
[
key
])
{
this
.
editSetting
(
remoteModel
,
key
,
undefined
);
this
.
editSetting
(
remoteModel
,
key
,
remote
[
key
]);
}
}
return
remoteModel
.
getValue
();
}
private
editSetting
(
model
:
ITextModel
,
key
:
string
,
value
:
any
|
undefined
):
void
{
private
editSetting
(
model
:
ITextModel
,
key
:
string
,
value
:
any
|
undefined
):
void
{
const
insertSpaces
=
false
;
const
insertSpaces
=
false
;
const
tabSize
=
4
;
const
tabSize
=
4
;
...
@@ -168,9 +180,9 @@ class SettingsMergeService implements ISettingsMergeService {
...
@@ -168,9 +180,9 @@ class SettingsMergeService implements ISettingsMergeService {
}
}
}
}
private
compare
(
from
:
IStringDictionary
<
any
>
,
to
:
IStringDictionary
<
any
>
):
{
added
:
Set
<
string
>
,
removed
:
Set
<
string
>
,
updated
:
Set
<
string
>
}
{
private
compare
(
from
:
IStringDictionary
<
any
>
,
to
:
IStringDictionary
<
any
>
,
ignored
:
IStringDictionary
<
boolean
>
):
{
added
:
Set
<
string
>
,
removed
:
Set
<
string
>
,
updated
:
Set
<
string
>
}
{
const
fromKeys
=
Object
.
keys
(
from
);
const
fromKeys
=
Object
.
keys
(
from
)
.
filter
(
key
=>
!
ignored
[
key
])
;
const
toKeys
=
Object
.
keys
(
to
);
const
toKeys
=
Object
.
keys
(
to
)
.
filter
(
key
=>
!
ignored
[
key
])
;
const
added
=
toKeys
.
filter
(
key
=>
fromKeys
.
indexOf
(
key
)
===
-
1
).
reduce
((
r
,
key
)
=>
{
r
.
add
(
key
);
return
r
;
},
new
Set
<
string
>
());
const
added
=
toKeys
.
filter
(
key
=>
fromKeys
.
indexOf
(
key
)
===
-
1
).
reduce
((
r
,
key
)
=>
{
r
.
add
(
key
);
return
r
;
},
new
Set
<
string
>
());
const
removed
=
fromKeys
.
filter
(
key
=>
toKeys
.
indexOf
(
key
)
===
-
1
).
reduce
((
r
,
key
)
=>
{
r
.
add
(
key
);
return
r
;
},
new
Set
<
string
>
());
const
removed
=
fromKeys
.
filter
(
key
=>
toKeys
.
indexOf
(
key
)
===
-
1
).
reduce
((
r
,
key
)
=>
{
r
.
add
(
key
);
return
r
;
},
new
Set
<
string
>
());
const
updated
:
Set
<
string
>
=
new
Set
<
string
>
();
const
updated
:
Set
<
string
>
=
new
Set
<
string
>
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录