Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3670914e
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,发现更多精彩内容 >>
提交
3670914e
编写于
4月 27, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #93904
上级
a915df17
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
91 addition
and
40 deletion
+91
-40
src/vs/platform/userDataSync/common/userDataSync.ts
src/vs/platform/userDataSync/common/userDataSync.ts
+0
-13
src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts
...vs/workbench/contrib/userDataSync/browser/userDataSync.ts
+91
-27
未找到文件。
src/vs/platform/userDataSync/common/userDataSync.ts
浏览文件 @
3670914e
...
...
@@ -26,19 +26,6 @@ import { isArray, isString, isObject } from 'vs/base/common/types';
export
const
CONFIGURATION_SYNC_STORE_KEY
=
'
configurationSync.store
'
;
export
interface
ISyncConfiguration
{
sync
:
{
enable
:
boolean
,
enableSettings
:
boolean
,
enableKeybindings
:
boolean
,
enableUIState
:
boolean
,
enableExtensions
:
boolean
,
keybindingsPerPlatform
:
boolean
,
ignoredExtensions
:
string
[],
ignoredSettings
:
string
[]
}
}
export
function
getDisallowedIgnoredSettings
():
string
[]
{
const
allSettings
=
Registry
.
as
<
IConfigurationRegistry
>
(
ConfigurationExtensions
.
Configuration
).
getConfigurationProperties
();
return
Object
.
keys
(
allSettings
).
filter
(
setting
=>
!!
allSettings
[
setting
].
disallowSyncIgnore
);
...
...
src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts
浏览文件 @
3670914e
...
...
@@ -29,7 +29,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
import
{
IQuickInputService
,
IQuickPickItem
,
IQuickPickSeparator
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
CONTEXT_SYNC_STATE
,
I
SyncConfiguration
,
I
UserDataAutoSyncService
,
IUserDataSyncService
,
registerConfiguration
,
CONTEXT_SYNC_STATE
,
IUserDataAutoSyncService
,
IUserDataSyncService
,
registerConfiguration
,
SyncResource
,
SyncStatus
,
UserDataSyncError
,
UserDataSyncErrorCode
,
USER_DATA_SYNC_SCHEME
,
IUserDataSyncEnablementService
,
CONTEXT_SYNC_ENABLEMENT
,
SyncResourceConflicts
,
Conflict
,
getSyncResourceFromLocalPreview
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
...
...
@@ -101,10 +101,14 @@ const showSyncActivityCommand = {
};
const
showSyncSettingsCommand
=
{
id
:
'
workbench.userData.actions.syncSettings
'
,
title
:
localize
(
'
sync settings
'
,
"
Preferences Sync: Show Settings
"
),
};
const
CONTEXT_TURNING_ON_STATE
=
new
RawContextKey
<
false
>
(
'
userDataSyncTurningOn
'
,
false
);
const
CONTEXT_ACCOUNT_STATE
=
new
RawContextKey
<
string
>
(
'
userDataSyncAccountStatus
'
,
AccountStatus
.
Uninitialized
);
export
class
UserDataSyncWorkbenchContribution
extends
Disposable
implements
IWorkbenchContribution
{
private
static
TURNING_ON_SYNC_KEY
=
'
userDataSync.turningOn
'
;
private
readonly
turningOnSyncContext
:
IContextKey
<
boolean
>
;
private
readonly
syncEnablementContext
:
IContextKey
<
boolean
>
;
private
readonly
syncStatusContext
:
IContextKey
<
string
>
;
private
readonly
accountStatusContext
:
IContextKey
<
string
>
;
...
...
@@ -137,6 +141,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
)
{
super
();
this
.
turningOnSyncContext
=
CONTEXT_TURNING_ON_STATE
.
bindTo
(
contextKeyService
);
this
.
syncEnablementContext
=
CONTEXT_SYNC_ENABLEMENT
.
bindTo
(
contextKeyService
);
this
.
syncStatusContext
=
CONTEXT_SYNC_STATE
.
bindTo
(
contextKeyService
);
this
.
accountStatusContext
=
CONTEXT_ACCOUNT_STATE
.
bindTo
(
contextKeyService
);
...
...
@@ -147,11 +152,13 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
if
(
this
.
userDataSyncAccounts
.
authenticationProviders
.
length
)
{
registerConfiguration
();
this
.
onDidChangeTurningOnState
();
this
.
onDidChangeSyncStatus
(
this
.
userDataSyncService
.
status
);
this
.
onDidChangeConflicts
(
this
.
userDataSyncService
.
conflicts
);
this
.
onDidChangeEnablement
(
this
.
userDataSyncEnablementService
.
isEnabled
());
this
.
onDidChangeAccountStatus
(
this
.
userDataSyncAccounts
.
status
);
this
.
_register
(
Event
.
filter
(
storageService
.
onDidChangeStorage
,
e
=>
e
.
scope
===
StorageScope
.
GLOBAL
&&
e
.
key
===
UserDataSyncWorkbenchContribution
.
TURNING_ON_SYNC_KEY
)(()
=>
this
.
onDidChangeTurningOnState
()));
this
.
_register
(
Event
.
debounce
(
userDataSyncService
.
onDidChangeStatus
,
()
=>
undefined
,
500
)(()
=>
this
.
onDidChangeSyncStatus
(
this
.
userDataSyncService
.
status
)));
this
.
_register
(
userDataSyncService
.
onDidChangeConflicts
(()
=>
this
.
onDidChangeConflicts
(
this
.
userDataSyncService
.
conflicts
)));
this
.
_register
(
userDataSyncService
.
onSyncErrors
(
errors
=>
this
.
onSyncErrors
(
errors
)));
...
...
@@ -170,6 +177,10 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
}
private
onDidChangeTurningOnState
():
void
{
this
.
turningOnSyncContext
.
set
(
this
.
storageService
.
getBoolean
(
UserDataSyncWorkbenchContribution
.
TURNING_ON_SYNC_KEY
,
StorageScope
.
GLOBAL
,
false
));
}
private
onDidChangeAccountStatus
(
status
:
AccountStatus
):
void
{
this
.
accountStatusContext
.
set
(
status
);
this
.
updateBadge
();
...
...
@@ -398,7 +409,25 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
private
async
turnOn
():
Promise
<
void
>
{
this
.
storageService
.
store
(
UserDataSyncWorkbenchContribution
.
TURNING_ON_SYNC_KEY
,
true
,
StorageScope
.
GLOBAL
);
try
{
if
(
!
this
.
storageService
.
getBoolean
(
'
sync.donotAskPreviewConfirmation
'
,
StorageScope
.
GLOBAL
,
false
))
{
if
(
!
await
this
.
askForConfirmation
())
{
return
;
}
}
const
turnOn
=
await
this
.
askToConfigure
();
if
(
!
turnOn
)
{
return
;
}
await
this
.
doTurnOn
();
this
.
storageService
.
store
(
'
sync.donotAskPreviewConfirmation
'
,
true
,
StorageScope
.
GLOBAL
);
}
finally
{
this
.
storageService
.
store
(
UserDataSyncWorkbenchContribution
.
TURNING_ON_SYNC_KEY
,
false
,
StorageScope
.
GLOBAL
);
}
}
private
async
askForConfirmation
():
Promise
<
boolean
>
{
const
result
=
await
this
.
dialogService
.
show
(
Severity
.
Info
,
localize
(
'
sync preview message
'
,
"
Synchronizing your preferences is a preview feature, please read the documentation before turning it on.
"
),
...
...
@@ -412,12 +441,14 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
);
switch
(
result
.
choice
)
{
case
0
:
this
.
openerService
.
open
(
URI
.
parse
(
'
https://aka.ms/vscode-settings-sync-help
'
));
return
;
case
2
:
return
;
case
0
:
this
.
openerService
.
open
(
URI
.
parse
(
'
https://aka.ms/vscode-settings-sync-help
'
));
return
false
;
case
2
:
return
false
;
}
return
true
;
}
return
new
Promise
((
c
,
e
)
=>
{
private
async
askToConfigure
():
Promise
<
boolean
>
{
return
new
Promise
<
boolean
>
((
c
,
e
)
=>
{
const
disposables
:
DisposableStore
=
new
DisposableStore
();
const
quickPick
=
this
.
quickInputService
.
createQuickPick
<
ConfigureSyncQuickPickItem
>
();
disposables
.
add
(
quickPick
);
...
...
@@ -440,14 +471,23 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
const
items
=
this
.
getConfigureSyncQuickPickItems
();
quickPick
.
items
=
items
;
quickPick
.
selectedItems
=
items
.
filter
(
item
=>
this
.
userDataSyncEnablementService
.
isResourceEnabled
(
item
.
id
));
disposables
.
add
(
Event
.
any
(
quickPick
.
onDidAccept
,
quickPick
.
onDidCustom
)(
async
()
=>
{
if
(
quickPick
.
selectedItems
.
length
)
{
this
.
updateConfiguration
(
items
,
quickPick
.
selectedItems
);
this
.
doTurnOn
().
then
(
c
,
e
);
let
accepted
:
boolean
=
false
;
disposables
.
add
(
Event
.
any
(
quickPick
.
onDidAccept
,
quickPick
.
onDidCustom
)(()
=>
{
accepted
=
true
;
quickPick
.
hide
();
}));
disposables
.
add
(
quickPick
.
onDidHide
(()
=>
{
try
{
if
(
accepted
)
{
this
.
updateConfiguration
(
items
,
quickPick
.
selectedItems
);
}
c
(
accepted
);
}
catch
(
error
)
{
e
(
error
);
}
finally
{
disposables
.
dispose
();
}
}));
disposables
.
add
(
quickPick
.
onDidHide
(()
=>
disposables
.
dispose
()));
quickPick
.
show
();
});
}
...
...
@@ -466,7 +506,6 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
await
this
.
handleFirstTimeSync
();
this
.
userDataSyncEnablementService
.
setEnablement
(
true
);
this
.
notificationService
.
info
(
localize
(
'
sync turned on
'
,
"
Preferences sync is turned on
"
));
this
.
storageService
.
store
(
'
sync.donotAskPreviewConfirmation
'
,
true
,
StorageScope
.
GLOBAL
);
}
private
getConfigureSyncQuickPickItems
():
ConfigureSyncQuickPickItem
[]
{
...
...
@@ -498,7 +537,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
}
private
async
configureSyncOptions
():
Promise
<
ISyncConfiguration
>
{
private
async
configureSyncOptions
():
Promise
<
void
>
{
return
new
Promise
((
c
,
e
)
=>
{
const
disposables
:
DisposableStore
=
new
DisposableStore
();
const
quickPick
=
this
.
quickInputService
.
createQuickPick
<
ConfigureSyncQuickPickItem
>
();
...
...
@@ -513,7 +552,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
quickPick
.
selectedItems
=
items
.
filter
(
item
=>
this
.
userDataSyncEnablementService
.
isResourceEnabled
(
item
.
id
));
disposables
.
add
(
quickPick
.
onDidAccept
(
async
()
=>
{
if
(
quickPick
.
selectedItems
.
length
)
{
await
this
.
updateConfiguration
(
items
,
quickPick
.
selectedItems
);
this
.
updateConfiguration
(
items
,
quickPick
.
selectedItems
);
quickPick
.
hide
();
}
}));
...
...
@@ -655,6 +694,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
this
.
registerTurnOnSyncAction
();
this
.
registerTurnOffSyncAction
();
}
this
.
registerTurninOnSyncAction
();
this
.
registerSignInAction
();
// When Sync is turned on from CLI
this
.
registerShowSettingsConflictsAction
();
this
.
registerShowKeybindingsConflictsAction
();
...
...
@@ -667,7 +707,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
private
registerTurnOnSyncAction
():
void
{
const
turnOnSyncWhenContext
=
ContextKeyExpr
.
and
(
CONTEXT_SYNC_STATE
.
notEqualsTo
(
SyncStatus
.
Uninitialized
),
CONTEXT_SYNC_ENABLEMENT
.
toNegated
(),
CONTEXT_ACCOUNT_STATE
.
notEqualsTo
(
AccountStatus
.
Uninitialized
));
const
turnOnSyncWhenContext
=
ContextKeyExpr
.
and
(
CONTEXT_SYNC_STATE
.
notEqualsTo
(
SyncStatus
.
Uninitialized
),
CONTEXT_SYNC_ENABLEMENT
.
toNegated
(),
CONTEXT_ACCOUNT_STATE
.
notEqualsTo
(
AccountStatus
.
Uninitialized
)
,
CONTEXT_TURNING_ON_STATE
.
negate
()
);
CommandsRegistry
.
registerCommand
(
turnOnSyncCommand
.
id
,
async
()
=>
{
try
{
await
this
.
turnOn
();
...
...
@@ -708,6 +748,30 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
});
}
private
registerTurninOnSyncAction
():
void
{
const
when
=
ContextKeyExpr
.
and
(
CONTEXT_SYNC_STATE
.
notEqualsTo
(
SyncStatus
.
Uninitialized
),
CONTEXT_SYNC_ENABLEMENT
.
toNegated
(),
CONTEXT_ACCOUNT_STATE
.
notEqualsTo
(
AccountStatus
.
Uninitialized
),
CONTEXT_TURNING_ON_STATE
);
this
.
_register
(
registerAction2
(
class
TurningOnSyncAction
extends
Action2
{
constructor
()
{
super
({
id
:
'
workbench.userData.actions.turningOn
'
,
title
:
localize
(
'
turnin on sync
'
,
"
Turning on Preferences Sync...
"
),
precondition
:
ContextKeyExpr
.
false
(),
menu
:
[{
group
:
'
5_sync
'
,
id
:
MenuId
.
GlobalActivity
,
when
,
order
:
2
},
{
group
:
'
1_sync
'
,
id
:
MenuId
.
AccountsContext
,
when
,
}]
});
}
async
run
():
Promise
<
any
>
{
}
}));
}
private
registerSignInAction
():
void
{
const
that
=
this
;
const
id
=
'
workbench.userData.actions.signin
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录