Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
467c9990
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,发现更多精彩内容 >>
提交
467c9990
编写于
1月 26, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #86297
上级
f4b952c9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
33 deletion
+51
-33
src/vs/platform/userDataSync/common/userDataSyncService.ts
src/vs/platform/userDataSync/common/userDataSyncService.ts
+18
-5
src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts
...vs/workbench/contrib/userDataSync/browser/userDataSync.ts
+33
-28
未找到文件。
src/vs/platform/userDataSync/common/userDataSyncService.ts
浏览文件 @
467c9990
...
...
@@ -14,6 +14,11 @@ import { KeybindingsSynchroniser } from 'vs/platform/userDataSync/common/keybind
import
{
GlobalStateSynchroniser
}
from
'
vs/platform/userDataSync/common/globalStateSync
'
;
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
type
SyncConflictsClassification
=
{
source
?:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
FeatureInsight
'
,
isMeasurement
:
true
};
};
export
class
UserDataSyncService
extends
Disposable
implements
IUserDataSyncService
{
...
...
@@ -41,6 +46,7 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
@
ISettingsSyncService
private
readonly
settingsSynchroniser
:
ISettingsSyncService
,
@
IUserDataSyncLogService
private
readonly
logService
:
IUserDataSyncLogService
,
@
IUserDataAuthTokenService
private
readonly
userDataAuthTokenService
:
IUserDataAuthTokenService
,
@
ITelemetryService
private
readonly
telemetryService
:
ITelemetryService
,
)
{
super
();
this
.
keybindingsSynchroniser
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
KeybindingsSynchroniser
));
...
...
@@ -252,13 +258,20 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
}
private
updateStatus
():
void
{
this
.
_conflictsSource
=
this
.
computeConflictsSource
();
this
.
setStatus
(
this
.
computeStatus
());
}
private
setStatus
(
status
:
SyncStatus
):
void
{
const
status
=
this
.
computeStatus
();
if
(
this
.
_status
!==
status
)
{
const
oldStatus
=
this
.
_status
;
const
oldConflictsSource
=
this
.
_conflictsSource
;
this
.
_conflictsSource
=
this
.
computeConflictsSource
();
this
.
_status
=
status
;
if
(
status
===
SyncStatus
.
HasConflicts
)
{
// Log to telemetry when there is a sync conflict
this
.
telemetryService
.
publicLog2
<
{
source
:
string
},
SyncConflictsClassification
>
(
'
sync/conflictsDetected
'
,
{
source
:
this
.
_conflictsSource
!
});
}
if
(
oldStatus
===
SyncStatus
.
HasConflicts
&&
status
===
SyncStatus
.
Idle
)
{
// Log to telemetry when conflicts are resolved
this
.
telemetryService
.
publicLog2
<
{
source
:
string
},
SyncConflictsClassification
>
(
'
sync/conflictsResolved
'
,
{
source
:
oldConflictsSource
!
});
}
this
.
_onDidChangeStatus
.
fire
(
status
);
}
}
...
...
src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts
浏览文件 @
467c9990
...
...
@@ -41,11 +41,10 @@ import type { IEditorContribution } from 'vs/editor/common/editorCommon';
import
type
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
FloatingClickWidget
}
from
'
vs/workbench/browser/parts/editor/editorWidgets
'
;
import
{
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
areSame
}
from
'
vs/platform/userDataSync/common/settingsMerge
'
;
import
{
getIgnoredSettings
}
from
'
vs/platform/userDataSync/common/settingsSync
'
;
import
type
{
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
IPreferencesService
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
const
enum
AuthStatus
{
Initializing
=
'
Initializing
'
,
...
...
@@ -65,6 +64,14 @@ function getSyncAreaLabel(source: SyncSource): string {
}
}
type
FirstTimeSyncClassification
=
{
action
:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
FeatureInsight
'
,
isMeasurement
:
true
};
};
type
SyncErrorClassification
=
{
source
:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
FeatureInsight
'
,
isMeasurement
:
true
};
};
export
class
UserDataSyncWorkbenchContribution
extends
Disposable
implements
IWorkbenchContribution
{
private
static
readonly
ENABLEMENT_SETTING
=
'
sync.enable
'
;
...
...
@@ -92,8 +99,9 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
@
IOutputService
private
readonly
outputService
:
IOutputService
,
@
IUserDataAuthTokenService
private
readonly
userDataAuthTokenService
:
IUserDataAuthTokenService
,
@
IUserDataAutoSyncService
userDataAutoSyncService
:
IUserDataAutoSyncService
,
@
ITextModelService
private
readonly
textModelResolverService
:
ITextModelService
,
@
ITextModelService
textModelResolverService
:
ITextModelService
,
@
IPreferencesService
private
readonly
preferencesService
:
IPreferencesService
,
@
ITelemetryService
private
readonly
telemetryService
:
ITelemetryService
,
)
{
super
();
this
.
userDataSyncStore
=
getUserDataSyncStore
(
configurationService
);
...
...
@@ -253,6 +261,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
private
onAutoSyncError
(
code
:
UserDataSyncErrorCode
,
source
?:
SyncSource
):
void
{
switch
(
code
)
{
case
UserDataSyncErrorCode
.
TooManyFailures
:
this
.
telemetryService
.
publicLog2
(
'
sync/errorTooMany
'
);
this
.
disableSync
();
this
.
notificationService
.
notify
({
severity
:
Severity
.
Error
,
...
...
@@ -263,6 +272,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
});
return
;
case
UserDataSyncErrorCode
.
TooLarge
:
this
.
telemetryService
.
publicLog2
<
{
source
:
string
},
SyncErrorClassification
>
(
'
sync/errorTooLarge
'
,
{
source
:
source
!
});
if
(
source
===
SyncSource
.
Keybindings
||
source
===
SyncSource
.
Settings
)
{
const
sourceArea
=
getSyncAreaLabel
(
source
);
this
.
disableSync
();
...
...
@@ -418,9 +428,17 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
);
switch
(
result
.
choice
)
{
case
0
:
await
this
.
userDataSyncService
.
sync
();
break
;
case
1
:
throw
canceled
();
case
2
:
await
this
.
userDataSyncService
.
pull
();
break
;
case
0
:
this
.
telemetryService
.
publicLog2
<
{
action
:
string
},
FirstTimeSyncClassification
>
(
'
sync/firstTimeSync
'
,
{
action
:
'
merge
'
});
await
this
.
userDataSyncService
.
sync
();
break
;
case
1
:
this
.
telemetryService
.
publicLog2
<
{
action
:
string
},
FirstTimeSyncClassification
>
(
'
sync/firstTimeSync
'
,
{
action
:
'
cancelled
'
});
throw
canceled
();
case
2
:
this
.
telemetryService
.
publicLog2
<
{
action
:
string
},
FirstTimeSyncClassification
>
(
'
sync/firstTimeSync
'
,
{
action
:
'
replace-local
'
});
await
this
.
userDataSyncService
.
pull
();
break
;
}
}
...
...
@@ -441,6 +459,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
if
(
result
.
confirmed
)
{
await
this
.
disableSync
();
if
(
result
.
checkboxChecked
)
{
this
.
telemetryService
.
publicLog2
(
'
sync/turnOffEveryWhere
'
);
await
this
.
userDataSyncService
.
reset
();
}
}
...
...
@@ -492,7 +511,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
if
(
previewResource
)
{
const
remoteContentResource
=
toRemoteContentResource
(
this
.
userDataSyncService
.
conflictsSource
!
);
const
editor
=
await
this
.
editorService
.
openEditor
({
await
this
.
editorService
.
openEditor
({
leftResource
:
remoteContentResource
,
rightResource
:
previewResource
,
label
,
...
...
@@ -502,27 +521,6 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
revealIfVisible
:
true
,
},
});
if
(
editor
?.
input
)
{
const
disposable
=
editor
.
input
.
onDispose
(
async
()
=>
{
disposable
.
dispose
();
const
source
=
getSyncSourceFromRemoteContentResource
(
remoteContentResource
);
if
(
source
===
undefined
||
this
.
userDataSyncService
.
conflictsSource
!==
source
)
{
return
;
}
const
remoteModelRef
=
await
this
.
textModelResolverService
.
createModelReference
(
remoteContentResource
);
const
previewModelRef
=
await
this
.
textModelResolverService
.
createModelReference
(
previewResource
!
);
const
remoteModelContent
=
remoteModelRef
.
object
.
textEditorModel
.
getValue
();
const
preivewContent
=
previewModelRef
.
object
.
textEditorModel
.
getValue
();
remoteModelRef
.
dispose
();
previewModelRef
.
dispose
();
if
(
remoteModelContent
!==
preivewContent
||
(
source
===
SyncSource
.
Settings
&&
!
areSame
(
remoteModelContent
,
preivewContent
,
getIgnoredSettings
(
this
.
configurationService
))))
{
return
;
}
await
this
.
userDataSyncService
.
resolveConflictsAndContinueSync
(
preivewContent
);
});
}
}
}
...
...
@@ -682,6 +680,11 @@ class UserDataRemoteContentProvider implements ITextModelContentProvider {
}
}
type
SyncConflictsClassification
=
{
source
:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
FeatureInsight
'
,
isMeasurement
:
true
};
action
:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
FeatureInsight
'
,
isMeasurement
:
true
};
};
class
AcceptChangesContribution
extends
Disposable
implements
IEditorContribution
{
static
get
(
editor
:
ICodeEditor
):
AcceptChangesContribution
{
...
...
@@ -700,6 +703,7 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
@
INotificationService
private
readonly
notificationService
:
INotificationService
,
@
IDialogService
private
readonly
dialogService
:
IDialogService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
,
@
ITelemetryService
private
readonly
telemetryService
:
ITelemetryService
)
{
super
();
...
...
@@ -760,6 +764,7 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
if
(
model
)
{
const
conflictsSource
=
this
.
userDataSyncService
.
conflictsSource
;
const
syncSource
=
getSyncSourceFromRemoteContentResource
(
model
.
uri
);
this
.
telemetryService
.
publicLog2
<
{
source
:
string
,
action
:
string
},
SyncConflictsClassification
>
(
'
sync/handleConflicts
'
,
{
source
:
conflictsSource
!
,
action
:
syncSource
!==
undefined
?
'
replaceLocal
'
:
'
apply
'
});
if
(
syncSource
!==
undefined
)
{
const
syncAreaLabel
=
getSyncAreaLabel
(
syncSource
);
const
result
=
await
this
.
dialogService
.
confirm
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录