Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
88bf57b3
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,发现更多精彩内容 >>
提交
88bf57b3
编写于
9月 12, 2019
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement start and stop sync commands
上级
fcffabad
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
6 deletion
+56
-6
src/vs/workbench/contrib/userData/browser/userData.contribution.ts
...rkbench/contrib/userData/browser/userData.contribution.ts
+34
-4
src/vs/workbench/services/userData/common/settingsSync.ts
src/vs/workbench/services/userData/common/settingsSync.ts
+12
-2
src/vs/workbench/services/userData/common/userData.ts
src/vs/workbench/services/userData/common/userData.ts
+1
-0
src/vs/workbench/services/userData/common/userDataSyncService.ts
...workbench/services/userData/common/userDataSyncService.ts
+9
-0
未找到文件。
src/vs/workbench/contrib/userData/browser/userData.contribution.ts
浏览文件 @
88bf57b3
...
...
@@ -6,7 +6,7 @@
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
,
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IUserDataSyncService
,
SyncStatus
}
from
'
vs/workbench/services/userData/common/userData
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
Disposable
,
MutableDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
MutableDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
...
...
@@ -20,6 +20,7 @@ import { GLOBAL_ACTIVITY_ID } from 'vs/workbench/common/activity';
import
{
timeout
}
from
'
vs/base/common/async
'
;
import
{
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
AcceptChangesController
}
from
'
vs/workbench/contrib/userData/browser/userDataPreviewEditorContribution
'
;
import
{
INotificationService
,
Severity
}
from
'
vs/platform/notification/common/notification
'
;
const
CONTEXT_SYNC_STATE
=
new
RawContextKey
<
string
>
(
'
syncStatus
'
,
SyncStatus
.
Uninitialized
);
...
...
@@ -74,11 +75,13 @@ class SyncContribution extends Disposable implements IWorkbenchContribution {
private
readonly
syncEnablementContext
:
IContextKey
<
string
>
;
private
readonly
badgeDisposable
=
this
.
_register
(
new
MutableDisposable
());
private
readonly
conflictsWarningDisposable
=
this
.
_register
(
new
MutableDisposable
());
constructor
(
@
IUserDataSyncService
userDataSyncService
:
IUserDataSyncService
,
@
IUserDataSyncService
private
readonly
userDataSyncService
:
IUserDataSyncService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IActivityService
private
readonly
activityService
:
IActivityService
@
IActivityService
private
readonly
activityService
:
IActivityService
,
@
INotificationService
private
readonly
notificationService
:
INotificationService
)
{
super
();
this
.
syncEnablementContext
=
CONTEXT_SYNC_STATE
.
bindTo
(
contextKeyService
);
...
...
@@ -105,6 +108,24 @@ class SyncContribution extends Disposable implements IWorkbenchContribution {
if
(
badge
)
{
this
.
badgeDisposable
.
value
=
this
.
activityService
.
showActivity
(
GLOBAL_ACTIVITY_ID
,
badge
,
clazz
);
}
if
(
status
!==
SyncStatus
.
HasConflicts
)
{
this
.
conflictsWarningDisposable
.
clear
();
}
}
private
async
sync
():
Promise
<
void
>
{
await
this
.
userDataSyncService
.
sync
();
if
(
this
.
userDataSyncService
.
status
===
SyncStatus
.
HasConflicts
)
{
const
handle
=
this
.
notificationService
.
prompt
(
Severity
.
Warning
,
localize
(
'
conflicts detected
'
,
"
Unable to sync due to conflicts. Please resolve them to continue.
"
),
[
{
label
:
localize
(
'
resolve
'
,
"
Resolve Conflicts
"
),
run
:
()
=>
this
.
userDataSyncService
.
handleConflicts
()
}
]);
this
.
conflictsWarningDisposable
.
value
=
toDisposable
(()
=>
handle
.
close
());
}
}
private
registerActions
():
void
{
...
...
@@ -154,7 +175,7 @@ class SyncContribution extends Disposable implements IWorkbenchContribution {
// Command Pallette Actions
CommandsRegistry
.
registerCommand
(
'
workbench.userData.actions.startSync
'
,
serviceAccessor
=>
serviceAccessor
.
get
(
IUserDataSyncService
)
.
sync
());
CommandsRegistry
.
registerCommand
(
'
workbench.userData.actions.startSync
'
,
()
=>
this
.
sync
());
MenuRegistry
.
appendMenuItem
(
MenuId
.
CommandPalette
,
{
command
:
{
id
:
'
workbench.userData.actions.startSync
'
,
...
...
@@ -163,6 +184,15 @@ class SyncContribution extends Disposable implements IWorkbenchContribution {
when
:
ContextKeyExpr
.
and
(
CONTEXT_SYNC_STATE
.
isEqualTo
(
SyncStatus
.
Idle
),
ContextKeyExpr
.
not
(
'
config.userConfiguration.autoSync
'
)),
});
CommandsRegistry
.
registerCommand
(
'
workbench.userData.actions.stopSync
'
,
serviceAccessor
=>
serviceAccessor
.
get
(
IUserDataSyncService
).
stopSync
());
MenuRegistry
.
appendMenuItem
(
MenuId
.
CommandPalette
,
{
command
:
{
id
:
'
workbench.userData.actions.stopSync
'
,
title
:
localize
(
'
stop sync
'
,
"
Sync: Stop
"
)
},
when
:
ContextKeyExpr
.
and
(
CONTEXT_SYNC_STATE
.
isEqualTo
(
SyncStatus
.
HasConflicts
),
ContextKeyExpr
.
not
(
'
config.userConfiguration.autoSync
'
)),
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
CommandPalette
,
{
command
:
{
id
:
'
sync.resolveConflicts
'
,
...
...
src/vs/workbench/services/userData/common/settingsSync.ts
浏览文件 @
88bf57b3
...
...
@@ -26,6 +26,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
isEqual
}
from
'
vs/base/common/resources
'
;
import
{
CancelablePromise
,
createCancelablePromise
}
from
'
vs/base/common/async
'
;
interface
ISyncPreviewResult
{
readonly
fileContent
:
IFileContent
|
null
;
...
...
@@ -40,7 +41,7 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser {
private
static
LAST_SYNC_SETTINGS_STORAGE_KEY
:
string
=
'
LAST_SYNC_SETTINGS_CONTENTS
'
;
private
static
EXTERNAL_USER_DATA_SETTINGS_KEY
:
string
=
'
settings
'
;
private
syncPreviewResultPromise
:
Promise
<
ISyncPreviewResult
>
|
null
=
null
;
private
syncPreviewResultPromise
:
Cancelable
Promise
<
ISyncPreviewResult
>
|
null
=
null
;
private
_status
:
SyncStatus
=
SyncStatus
.
Idle
;
get
status
():
SyncStatus
{
return
this
.
_status
;
}
...
...
@@ -101,6 +102,15 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser {
}
}
async
stopSync
():
Promise
<
void
>
{
await
this
.
fileService
.
del
(
SETTINGS_PREVIEW_RESOURCE
);
if
(
this
.
syncPreviewResultPromise
)
{
this
.
syncPreviewResultPromise
.
cancel
();
this
.
syncPreviewResultPromise
=
null
;
this
.
setStatus
(
SyncStatus
.
Idle
);
}
}
handleConflicts
():
boolean
{
if
(
this
.
status
!==
SyncStatus
.
HasConflicts
)
{
return
false
;
...
...
@@ -152,7 +162,7 @@ export class SettingsSynchroniser extends Disposable implements ISynchroniser {
private
getPreview
():
Promise
<
ISyncPreviewResult
>
{
if
(
!
this
.
syncPreviewResultPromise
)
{
this
.
syncPreviewResultPromise
=
this
.
generatePreview
(
);
this
.
syncPreviewResultPromise
=
createCancelablePromise
(
token
=>
this
.
generatePreview
()
);
}
return
this
.
syncPreviewResultPromise
;
}
...
...
src/vs/workbench/services/userData/common/userData.ts
浏览文件 @
88bf57b3
...
...
@@ -101,6 +101,7 @@ export interface ISynchroniser {
readonly
status
:
SyncStatus
;
readonly
onDidChangeStatus
:
Event
<
SyncStatus
>
;
sync
():
Promise
<
boolean
>
;
stopSync
():
Promise
<
void
>
;
handleConflicts
():
boolean
;
apply
(
previewResource
:
URI
):
Promise
<
boolean
>
;
}
...
...
src/vs/workbench/services/userData/common/userDataSyncService.ts
浏览文件 @
88bf57b3
...
...
@@ -50,6 +50,15 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
return
true
;
}
async
stopSync
():
Promise
<
void
>
{
if
(
!
this
.
remoteUserDataService
.
isEnabled
())
{
throw
new
Error
(
'
Not enabled
'
);
}
for
(
const
synchroniser
of
this
.
synchronisers
)
{
await
synchroniser
.
stopSync
();
}
}
async
apply
(
previewResource
:
URI
):
Promise
<
boolean
>
{
if
(
!
this
.
remoteUserDataService
.
isEnabled
())
{
throw
new
Error
(
'
Not enabled
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录