Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
238617a8
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,发现更多精彩内容 >>
提交
238617a8
编写于
1月 13, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - drop TextFileModelChangeEvent
上级
9918d87c
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
85 addition
and
105 deletion
+85
-105
src/vs/workbench/api/browser/mainThreadDocuments.ts
src/vs/workbench/api/browser/mainThreadDocuments.ts
+12
-12
src/vs/workbench/browser/parts/editor/editorStatus.ts
src/vs/workbench/browser/parts/editor/editorStatus.ts
+1
-1
src/vs/workbench/contrib/experiments/common/experimentService.ts
...workbench/contrib/experiments/common/experimentService.ts
+6
-7
src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts
...kbench/contrib/files/browser/editors/fileEditorTracker.ts
+3
-3
src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.ts
...contrib/files/browser/editors/textFileSaveErrorHandler.ts
+2
-2
src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts
...workbench/contrib/files/common/editors/fileEditorInput.ts
+10
-10
src/vs/workbench/contrib/surveys/browser/languageSurveys.contribution.ts
...h/contrib/surveys/browser/languageSurveys.contribution.ts
+9
-11
src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts
...bench/contrib/telemetry/browser/telemetry.contribution.ts
+9
-9
src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts
...ch/services/textfile/common/textFileEditorModelManager.ts
+16
-17
src/vs/workbench/services/textfile/common/textfiles.ts
src/vs/workbench/services/textfile/common/textfiles.ts
+7
-23
src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts
...services/textfile/test/textFileEditorModelManager.test.ts
+10
-10
未找到文件。
src/vs/workbench/api/browser/mainThreadDocuments.ts
浏览文件 @
238617a8
...
...
@@ -15,7 +15,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import
{
MainThreadDocumentsAndEditors
}
from
'
vs/workbench/api/browser/mainThreadDocumentsAndEditors
'
;
import
{
ExtHostContext
,
ExtHostDocumentsShape
,
IExtHostContext
,
MainThreadDocumentsShape
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ITextEditorModel
}
from
'
vs/workbench/common/editor
'
;
import
{
ITextFileService
,
TextFileModelChangeEvent
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IUntitledTextEditorService
}
from
'
vs/workbench/services/untitled/common/untitledTextEditorService
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
toLocalResource
}
from
'
vs/base/common/resources
'
;
...
...
@@ -104,19 +104,19 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
this
.
_toDispose
.
add
(
this
.
_modelReferenceCollection
);
this
.
_toDispose
.
add
(
modelService
.
onModelModeChanged
(
this
.
_onModelModeChanged
,
this
));
this
.
_toDispose
.
add
(
textFileService
.
models
.
onModelSaved
(
e
=>
{
if
(
this
.
_shouldHandleFileEvent
(
e
))
{
this
.
_proxy
.
$acceptModelSaved
(
e
.
resource
);
this
.
_toDispose
.
add
(
textFileService
.
models
.
onModelSaved
(
m
=>
{
if
(
this
.
_shouldHandleFileEvent
(
m
.
resourc
e
))
{
this
.
_proxy
.
$acceptModelSaved
(
m
.
resource
);
}
}));
this
.
_toDispose
.
add
(
textFileService
.
models
.
onModelReverted
(
e
=>
{
if
(
this
.
_shouldHandleFileEvent
(
e
))
{
this
.
_proxy
.
$acceptDirtyStateChanged
(
e
.
resource
,
false
);
this
.
_toDispose
.
add
(
textFileService
.
models
.
onModelReverted
(
m
=>
{
if
(
this
.
_shouldHandleFileEvent
(
m
.
resourc
e
))
{
this
.
_proxy
.
$acceptDirtyStateChanged
(
m
.
resource
,
false
);
}
}));
this
.
_toDispose
.
add
(
textFileService
.
models
.
onModelDirty
(
e
=>
{
if
(
this
.
_shouldHandleFileEvent
(
e
))
{
this
.
_proxy
.
$acceptDirtyStateChanged
(
e
.
resource
,
true
);
this
.
_toDispose
.
add
(
textFileService
.
models
.
onModelDirty
(
m
=>
{
if
(
this
.
_shouldHandleFileEvent
(
m
.
resourc
e
))
{
this
.
_proxy
.
$acceptDirtyStateChanged
(
m
.
resource
,
true
);
}
}));
...
...
@@ -131,8 +131,8 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
this
.
_toDispose
.
dispose
();
}
private
_shouldHandleFileEvent
(
e
:
TextFileModelChangeEvent
):
boolean
{
const
model
=
this
.
_modelService
.
getModel
(
e
.
resource
);
private
_shouldHandleFileEvent
(
resource
:
URI
):
boolean
{
const
model
=
this
.
_modelService
.
getModel
(
resource
);
return
!!
model
&&
shouldSynchronizeModel
(
model
);
}
...
...
src/vs/workbench/browser/parts/editor/editorStatus.ts
浏览文件 @
238617a8
...
...
@@ -314,7 +314,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
private
registerListeners
():
void
{
this
.
_register
(
this
.
editorService
.
onDidActiveEditorChange
(()
=>
this
.
updateStatusBar
()));
this
.
_register
(
this
.
untitledTextEditorService
.
onDidChangeEncoding
(
r
=>
this
.
onResourceEncodingChange
(
r
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelEncodingChanged
(
e
=>
this
.
onResourceEncodingChange
((
e
.
resource
))));
this
.
_register
(
this
.
textFileService
.
models
.
onModelEncodingChanged
(
m
=>
this
.
onResourceEncodingChange
((
m
.
resource
))));
this
.
_register
(
TabFocus
.
onDidChangeTabFocus
(
e
=>
this
.
onTabFocusModeChange
()));
}
...
...
src/vs/workbench/contrib/experiments/common/experimentService.ts
浏览文件 @
238617a8
...
...
@@ -14,7 +14,7 @@ import { language } from 'vs/base/common/platform';
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
match
}
from
'
vs/base/common/glob
'
;
import
{
IRequestService
,
asJson
}
from
'
vs/platform/request/common/request
'
;
import
{
ITextFileService
,
StateChange
,
TextFileModelChangeEvent
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
,
ITextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
ExtensionType
}
from
'
vs/platform/extensions/common/extensions
'
;
...
...
@@ -404,7 +404,7 @@ export class ExperimentService extends Disposable implements IExperimentService
}
// Process model-save event every 250ms to reduce load
const
onModelsSavedWorker
=
this
.
_register
(
new
RunOnceWorker
<
TextFileModelChangeEvent
>
(
e
=>
{
const
onModelsSavedWorker
=
this
.
_register
(
new
RunOnceWorker
<
ITextFileEditorModel
>
(
models
=>
{
const
date
=
new
Date
().
toDateString
();
const
latestExperimentState
:
IExperimentStorageState
=
safeParse
(
this
.
storageService
.
get
(
storageKey
,
StorageScope
.
GLOBAL
),
{});
if
(
latestExperimentState
.
state
!==
ExperimentState
.
Evaluating
)
{
...
...
@@ -412,9 +412,8 @@ export class ExperimentService extends Disposable implements IExperimentService
onModelsSavedWorker
.
dispose
();
return
;
}
e
.
forEach
(
async
event
=>
{
if
(
event
.
kind
!==
StateChange
.
SAVED
||
latestExperimentState
.
state
!==
ExperimentState
.
Evaluating
models
.
forEach
(
async
model
=>
{
if
(
latestExperimentState
.
state
!==
ExperimentState
.
Evaluating
||
date
===
latestExperimentState
.
lastEditedDate
||
(
typeof
latestExperimentState
.
editCount
===
'
number
'
&&
latestExperimentState
.
editCount
>=
fileEdits
.
minEditCount
)
)
{
...
...
@@ -424,7 +423,7 @@ export class ExperimentService extends Disposable implements IExperimentService
let
workspaceCheck
=
true
;
if
(
typeof
fileEdits
.
filePathPattern
===
'
string
'
)
{
filePathCheck
=
match
(
fileEdits
.
filePathPattern
,
event
.
resource
.
fsPath
);
filePathCheck
=
match
(
fileEdits
.
filePathPattern
,
model
.
resource
.
fsPath
);
}
if
(
Array
.
isArray
(
fileEdits
.
workspaceIncludes
)
&&
fileEdits
.
workspaceIncludes
.
length
)
{
const
tags
=
await
this
.
workspaceTagsService
.
getTags
();
...
...
@@ -449,7 +448,7 @@ export class ExperimentService extends Disposable implements IExperimentService
}
},
250
));
const
onSaveHandler
=
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaved
(
e
=>
onModelsSavedWorker
.
work
(
e
)));
const
onSaveHandler
=
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaved
(
m
=>
onModelsSavedWorker
.
work
(
m
)));
return
ExperimentState
.
Evaluating
;
});
}
...
...
src/vs/workbench/contrib/files/browser/editors/fileEditorTracker.ts
浏览文件 @
238617a8
...
...
@@ -61,9 +61,9 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
this
.
_register
(
this
.
fileService
.
onFileChanges
(
e
=>
this
.
onFileChanges
(
e
)));
// Ensure dirty text file and untitled models are always opened as editors
this
.
_register
(
this
.
textFileService
.
models
.
onModelDirty
(
e
=>
this
.
ensureDirtyFilesAreOpenedWorker
.
work
(
e
.
resource
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaveError
(
e
=>
this
.
ensureDirtyFilesAreOpenedWorker
.
work
(
e
.
resource
)));
this
.
_register
(
this
.
untitledTextEditorService
.
onDidChangeDirty
(
e
=>
this
.
ensureDirtyFilesAreOpenedWorker
.
work
(
e
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelDirty
(
m
=>
this
.
ensureDirtyFilesAreOpenedWorker
.
work
(
m
.
resource
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaveError
(
m
=>
this
.
ensureDirtyFilesAreOpenedWorker
.
work
(
m
.
resource
)));
this
.
_register
(
this
.
untitledTextEditorService
.
onDidChangeDirty
(
r
=>
this
.
ensureDirtyFilesAreOpenedWorker
.
work
(
r
)));
// Out of workspace file watchers
this
.
_register
(
this
.
editorService
.
onDidVisibleEditorsChange
(()
=>
this
.
onDidVisibleEditorsChange
()));
...
...
src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.ts
浏览文件 @
238617a8
...
...
@@ -71,8 +71,8 @@ export class TextFileSaveErrorHandler extends Disposable implements ISaveErrorHa
}
private
registerListeners
():
void
{
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaved
(
e
=>
this
.
onFileSavedOrReverted
(
e
.
resource
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelReverted
(
e
=>
this
.
onFileSavedOrReverted
(
e
.
resource
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaved
(
m
=>
this
.
onFileSavedOrReverted
(
m
.
resource
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelReverted
(
m
=>
this
.
onFileSavedOrReverted
(
m
.
resource
)));
this
.
_register
(
this
.
editorService
.
onDidActiveEditorChange
(()
=>
this
.
onActiveEditorChanged
()));
}
...
...
src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts
浏览文件 @
238617a8
...
...
@@ -11,7 +11,7 @@ import { EncodingMode, IFileEditorInput, ITextEditorModel, Verbosity, TextEditor
import
{
TextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textFileEditorModel
'
;
import
{
BinaryEditorModel
}
from
'
vs/workbench/common/editor/binaryEditorModel
'
;
import
{
FileOperationError
,
FileOperationResult
,
IFileService
,
FileSystemProviderCapabilities
}
from
'
vs/platform/files/common/files
'
;
import
{
ITextFileService
,
ModelState
,
TextFileModelChangeEvent
,
LoadReason
,
TextFileOperationError
,
TextFileOperationResult
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
,
ModelState
,
LoadReason
,
TextFileOperationError
,
TextFileOperationResult
,
ITextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IReference
}
from
'
vs/base/common/lifecycle
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
...
...
@@ -70,25 +70,25 @@ export class FileEditorInput extends TextEditorInput implements IFileEditorInput
private
registerListeners
():
void
{
// Dirty changes
this
.
_register
(
this
.
textFileService
.
models
.
onModelDirty
(
e
=>
this
.
onDirtyStateChange
(
e
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaveError
(
e
=>
this
.
onDirtyStateChange
(
e
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaved
(
e
=>
this
.
onDirtyStateChange
(
e
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelReverted
(
e
=>
this
.
onDirtyStateChange
(
e
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelDirty
(
m
=>
this
.
onDirtyStateChange
(
m
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaveError
(
m
=>
this
.
onDirtyStateChange
(
m
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelSaved
(
m
=>
this
.
onDirtyStateChange
(
m
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelReverted
(
m
=>
this
.
onDirtyStateChange
(
m
)));
// Label changes
this
.
_register
(
this
.
labelService
.
onDidChangeFormatters
(()
=>
FileEditorInput
.
MEMOIZER
.
clear
()));
this
.
_register
(
this
.
fileService
.
onDidChangeFileSystemProviderRegistrations
(()
=>
FileEditorInput
.
MEMOIZER
.
clear
()));
this
.
_register
(
this
.
textFileService
.
models
.
onModelOrphanedChanged
(
e
=>
this
.
onModelOrphanedChanged
(
e
)));
this
.
_register
(
this
.
textFileService
.
models
.
onModelOrphanedChanged
(
model
=>
this
.
onModelOrphanedChanged
(
model
)));
}
private
onDirtyStateChange
(
e
:
TextFileModelChangeEvent
):
void
{
if
(
e
.
resource
.
toString
()
===
this
.
resource
.
toString
())
{
private
onDirtyStateChange
(
model
:
ITextFileEditorModel
):
void
{
if
(
model
.
resource
.
toString
()
===
this
.
resource
.
toString
())
{
this
.
_onDidChangeDirty
.
fire
();
}
}
private
onModelOrphanedChanged
(
e
:
TextFileModelChangeEvent
):
void
{
if
(
e
.
resource
.
toString
()
===
this
.
resource
.
toString
())
{
private
onModelOrphanedChanged
(
model
:
ITextFileEditorModel
):
void
{
if
(
model
.
resource
.
toString
()
===
this
.
resource
.
toString
())
{
FileEditorInput
.
MEMOIZER
.
clear
();
this
.
_onDidChangeLabel
.
fire
();
}
...
...
src/vs/workbench/contrib/surveys/browser/languageSurveys.contribution.ts
浏览文件 @
238617a8
...
...
@@ -13,7 +13,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
import
{
ISurveyData
,
IProductService
}
from
'
vs/platform/product/common/productService
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
Severity
,
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
ITextFileService
,
StateChange
,
TextFileModelChangeEvent
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
,
ITextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
platform
}
from
'
vs/base/common/process
'
;
...
...
@@ -51,20 +51,18 @@ class LanguageSurvey extends Disposable {
if
(
storageService
.
getNumber
(
EDITED_LANGUAGE_COUNT_KEY
,
StorageScope
.
GLOBAL
,
0
)
<
data
.
editCount
)
{
// Process model-save event every 250ms to reduce load
const
onModelsSavedWorker
=
this
.
_register
(
new
RunOnceWorker
<
TextFileModelChangeEvent
>
(
e
=>
{
e
.
forEach
(
event
=>
{
if
(
event
.
kind
===
StateChange
.
SAVED
)
{
const
model
=
modelService
.
getModel
(
event
.
resource
);
if
(
model
&&
model
.
getModeId
()
===
data
.
languageId
&&
date
!==
storageService
.
get
(
EDITED_LANGUAGE_DATE_KEY
,
StorageScope
.
GLOBAL
))
{
const
editedCount
=
storageService
.
getNumber
(
EDITED_LANGUAGE_COUNT_KEY
,
StorageScope
.
GLOBAL
,
0
)
+
1
;
storageService
.
store
(
EDITED_LANGUAGE_COUNT_KEY
,
editedCount
,
StorageScope
.
GLOBAL
);
storageService
.
store
(
EDITED_LANGUAGE_DATE_KEY
,
date
,
StorageScope
.
GLOBAL
);
}
const
onModelsSavedWorker
=
this
.
_register
(
new
RunOnceWorker
<
ITextFileEditorModel
>
(
models
=>
{
models
.
forEach
(
m
=>
{
const
model
=
modelService
.
getModel
(
m
.
resource
);
if
(
model
&&
model
.
getModeId
()
===
data
.
languageId
&&
date
!==
storageService
.
get
(
EDITED_LANGUAGE_DATE_KEY
,
StorageScope
.
GLOBAL
))
{
const
editedCount
=
storageService
.
getNumber
(
EDITED_LANGUAGE_COUNT_KEY
,
StorageScope
.
GLOBAL
,
0
)
+
1
;
storageService
.
store
(
EDITED_LANGUAGE_COUNT_KEY
,
editedCount
,
StorageScope
.
GLOBAL
);
storageService
.
store
(
EDITED_LANGUAGE_DATE_KEY
,
date
,
StorageScope
.
GLOBAL
);
}
});
},
250
));
this
.
_register
(
textFileService
.
models
.
onModelSaved
(
e
=>
onModelsSavedWorker
.
work
(
e
)));
this
.
_register
(
textFileService
.
models
.
onModelSaved
(
m
=>
onModelsSavedWorker
.
work
(
m
)));
}
const
lastSessionDate
=
storageService
.
get
(
LAST_SESSION_DATE_KEY
,
StorageScope
.
GLOBAL
,
new
Date
(
0
).
toDateString
());
...
...
src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts
浏览文件 @
238617a8
...
...
@@ -19,7 +19,7 @@ import ErrorTelemetry from 'vs/platform/telemetry/browser/errorTelemetry';
import
{
configurationTelemetry
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
ITextFileService
,
TextFileModelChangeEvent
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
,
ITextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
extname
,
basename
,
isEqual
,
isEqualOrParent
,
joinPath
}
from
'
vs/base/common/resources
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
...
...
@@ -124,15 +124,15 @@ export class TelemetryContribution extends Disposable implements IWorkbenchContr
this
.
_register
(
configurationTelemetry
(
telemetryService
,
configurationService
));
// Files Telemetry
this
.
_register
(
textFileService
.
models
.
onModelLoaded
(
e
=>
this
.
onTextFileModelLoaded
(
e
)));
this
.
_register
(
textFileService
.
models
.
onModelSaved
(
e
=>
this
.
onTextFileModelSaved
(
e
)));
this
.
_register
(
textFileService
.
models
.
onModelLoaded
(
m
=>
this
.
onTextFileModelLoaded
(
m
)));
this
.
_register
(
textFileService
.
models
.
onModelSaved
(
m
=>
this
.
onTextFileModelSaved
(
m
)));
// Lifecycle
this
.
_register
(
lifecycleService
.
onShutdown
(()
=>
this
.
dispose
()));
}
private
onTextFileModelLoaded
(
event
:
TextFileModelChangeEvent
):
void
{
const
settingsType
=
this
.
getTypeIfSettings
(
event
.
resource
);
private
onTextFileModelLoaded
(
model
:
ITextFileEditorModel
):
void
{
const
settingsType
=
this
.
getTypeIfSettings
(
model
.
resource
);
if
(
settingsType
)
{
type
SettingsReadClassification
=
{
settingsType
:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
FeatureInsight
'
};
...
...
@@ -142,12 +142,12 @@ export class TelemetryContribution extends Disposable implements IWorkbenchContr
}
else
{
type
FileGetClassification
=
{}
&
FileTelemetryDataFragment
;
this
.
telemetryService
.
publicLog2
<
TelemetryData
,
FileGetClassification
>
(
'
fileGet
'
,
this
.
getTelemetryData
(
event
.
resource
));
this
.
telemetryService
.
publicLog2
<
TelemetryData
,
FileGetClassification
>
(
'
fileGet
'
,
this
.
getTelemetryData
(
model
.
resource
));
}
}
private
onTextFileModelSaved
(
event
:
TextFileModelChangeEvent
):
void
{
const
settingsType
=
this
.
getTypeIfSettings
(
event
.
resource
);
private
onTextFileModelSaved
(
model
:
ITextFileEditorModel
):
void
{
const
settingsType
=
this
.
getTypeIfSettings
(
model
.
resource
);
if
(
settingsType
)
{
type
SettingsWrittenClassification
=
{
settingsType
:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
FeatureInsight
'
};
...
...
@@ -155,7 +155,7 @@ export class TelemetryContribution extends Disposable implements IWorkbenchContr
this
.
telemetryService
.
publicLog2
<
{
settingsType
:
string
},
SettingsWrittenClassification
>
(
'
settingsWritten
'
,
{
settingsType
});
// Do not log write to user settings.json and .vscode folder as a filePUT event as it ruins our JSON usage data
}
else
{
type
FilePutClassfication
=
{}
&
FileTelemetryDataFragment
;
this
.
telemetryService
.
publicLog2
<
TelemetryData
,
FilePutClassfication
>
(
'
filePUT
'
,
this
.
getTelemetryData
(
event
.
resource
));
this
.
telemetryService
.
publicLog2
<
TelemetryData
,
FilePutClassfication
>
(
'
filePUT
'
,
this
.
getTelemetryData
(
model
.
resource
));
}
}
...
...
src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts
浏览文件 @
238617a8
...
...
@@ -7,7 +7,7 @@ import { Emitter } from 'vs/base/common/event';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
TextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textFileEditorModel
'
;
import
{
dispose
,
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ITextFileEditorModel
,
ITextFileEditorModelManager
,
TextFileModelChangeEvent
,
StateChange
,
IModelLoadOrCreateOptions
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileEditorModel
,
ITextFileEditorModelManager
,
StateChange
,
IModelLoadOrCreateOptions
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
...
...
@@ -18,25 +18,25 @@ import { onUnexpectedError } from 'vs/base/common/errors';
export
class
TextFileEditorModelManager
extends
Disposable
implements
ITextFileEditorModelManager
{
private
readonly
_onModelLoaded
=
this
.
_register
(
new
Emitter
<
TextFileModelChangeEvent
>
());
private
readonly
_onModelLoaded
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onModelLoaded
=
this
.
_onModelLoaded
.
event
;
private
readonly
_onModelDirty
=
this
.
_register
(
new
Emitter
<
TextFileModelChangeEvent
>
());
private
readonly
_onModelDirty
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onModelDirty
=
this
.
_onModelDirty
.
event
;
private
readonly
_onModelSaveError
=
this
.
_register
(
new
Emitter
<
TextFileModelChangeEvent
>
());
private
readonly
_onModelSaveError
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onModelSaveError
=
this
.
_onModelSaveError
.
event
;
private
readonly
_onModelSaved
=
this
.
_register
(
new
Emitter
<
TextFileModelChangeEvent
>
());
private
readonly
_onModelSaved
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onModelSaved
=
this
.
_onModelSaved
.
event
;
private
readonly
_onModelReverted
=
this
.
_register
(
new
Emitter
<
TextFileModelChangeEvent
>
());
private
readonly
_onModelReverted
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onModelReverted
=
this
.
_onModelReverted
.
event
;
private
readonly
_onModelEncodingChanged
=
this
.
_register
(
new
Emitter
<
TextFileModelChangeEvent
>
());
private
readonly
_onModelEncodingChanged
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onModelEncodingChanged
=
this
.
_onModelEncodingChanged
.
event
;
private
readonly
_onModelOrphanedChanged
=
this
.
_register
(
new
Emitter
<
TextFileModelChangeEvent
>
());
private
readonly
_onModelOrphanedChanged
=
this
.
_register
(
new
Emitter
<
ITextFileEditorModel
>
());
readonly
onModelOrphanedChanged
=
this
.
_onModelOrphanedChanged
.
event
;
private
readonly
mapResourceToDisposeListener
=
new
ResourceMap
<
IDisposable
>
();
...
...
@@ -130,28 +130,27 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
// Install state change listener
this
.
mapResourceToStateChangeListener
.
set
(
resource
,
model
.
onDidChangeState
(
state
=>
{
const
event
=
new
TextFileModelChangeEvent
(
newModel
,
state
);
switch
(
state
)
{
case
StateChange
.
LOADED
:
this
.
_onModelLoaded
.
fire
(
event
);
this
.
_onModelLoaded
.
fire
(
newModel
);
break
;
case
StateChange
.
DIRTY
:
this
.
_onModelDirty
.
fire
(
event
);
this
.
_onModelDirty
.
fire
(
newModel
);
break
;
case
StateChange
.
SAVE_ERROR
:
this
.
_onModelSaveError
.
fire
(
event
);
this
.
_onModelSaveError
.
fire
(
newModel
);
break
;
case
StateChange
.
SAVED
:
this
.
_onModelSaved
.
fire
(
event
);
this
.
_onModelSaved
.
fire
(
newModel
);
break
;
case
StateChange
.
REVERTED
:
this
.
_onModelReverted
.
fire
(
event
);
this
.
_onModelReverted
.
fire
(
newModel
);
break
;
case
StateChange
.
ENCODING
:
this
.
_onModelEncodingChanged
.
fire
(
event
);
this
.
_onModelEncodingChanged
.
fire
(
newModel
);
break
;
case
StateChange
.
ORPHANED_CHANGE
:
this
.
_onModelOrphanedChanged
.
fire
(
event
);
this
.
_onModelOrphanedChanged
.
fire
(
newModel
);
break
;
}
}));
...
...
@@ -168,7 +167,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
// Model can be dirty if a backup was restored, so we make sure to have this event delivered
if
(
resolvedModel
.
isDirty
())
{
this
.
_onModelDirty
.
fire
(
new
TextFileModelChangeEvent
(
resolvedModel
,
StateChange
.
DIRTY
)
);
this
.
_onModelDirty
.
fire
(
resolvedModel
);
}
// Remove from pending loads
...
...
src/vs/workbench/services/textfile/common/textfiles.ts
浏览文件 @
238617a8
...
...
@@ -285,22 +285,6 @@ export const enum StateChange {
ORPHANED_CHANGE
}
export
class
TextFileModelChangeEvent
{
private
_resource
:
URI
;
constructor
(
model
:
ITextFileEditorModel
,
private
_kind
:
StateChange
)
{
this
.
_resource
=
model
.
resource
;
}
get
resource
():
URI
{
return
this
.
_resource
;
}
get
kind
():
StateChange
{
return
this
.
_kind
;
}
}
export
interface
ITextFileOperationResult
{
results
:
IResult
[];
}
...
...
@@ -378,14 +362,14 @@ export interface IModelLoadOrCreateOptions {
export
interface
ITextFileEditorModelManager
{
readonly
onModelEncodingChanged
:
Event
<
TextFileModelChangeEvent
>
;
readonly
onModelOrphanedChanged
:
Event
<
TextFileModelChangeEvent
>
;
readonly
onModelEncodingChanged
:
Event
<
ITextFileEditorModel
>
;
readonly
onModelOrphanedChanged
:
Event
<
ITextFileEditorModel
>
;
readonly
onModelLoaded
:
Event
<
TextFileModelChangeEvent
>
;
readonly
onModelDirty
:
Event
<
TextFileModelChangeEvent
>
;
readonly
onModelSaveError
:
Event
<
TextFileModelChangeEvent
>
;
readonly
onModelSaved
:
Event
<
TextFileModelChangeEvent
>
;
readonly
onModelReverted
:
Event
<
TextFileModelChangeEvent
>
;
readonly
onModelLoaded
:
Event
<
ITextFileEditorModel
>
;
readonly
onModelDirty
:
Event
<
ITextFileEditorModel
>
;
readonly
onModelSaveError
:
Event
<
ITextFileEditorModel
>
;
readonly
onModelSaved
:
Event
<
ITextFileEditorModel
>
;
readonly
onModelReverted
:
Event
<
ITextFileEditorModel
>
;
get
(
resource
:
URI
):
ITextFileEditorModel
|
undefined
;
...
...
src/vs/workbench/services/textfile/test/textFileEditorModelManager.test.ts
浏览文件 @
238617a8
...
...
@@ -139,32 +139,32 @@ suite('Files - TextFileEditorModelManager', () => {
let
savedCounter
=
0
;
let
encodingCounter
=
0
;
manager
.
onModelLoaded
(
e
=>
{
if
(
e
.
resource
.
toString
()
===
resource1
.
toString
())
{
manager
.
onModelLoaded
(
model
=>
{
if
(
model
.
resource
.
toString
()
===
resource1
.
toString
())
{
loadedCounter
++
;
}
});
manager
.
onModelDirty
(
e
=>
{
if
(
e
.
resource
.
toString
()
===
resource1
.
toString
())
{
manager
.
onModelDirty
(
model
=>
{
if
(
model
.
resource
.
toString
()
===
resource1
.
toString
())
{
dirtyCounter
++
;
}
});
manager
.
onModelReverted
(
e
=>
{
if
(
e
.
resource
.
toString
()
===
resource1
.
toString
())
{
manager
.
onModelReverted
(
model
=>
{
if
(
model
.
resource
.
toString
()
===
resource1
.
toString
())
{
revertedCounter
++
;
}
});
manager
.
onModelSaved
(
e
=>
{
if
(
e
.
resource
.
toString
()
===
resource1
.
toString
())
{
manager
.
onModelSaved
(
model
=>
{
if
(
model
.
resource
.
toString
()
===
resource1
.
toString
())
{
savedCounter
++
;
}
});
manager
.
onModelEncodingChanged
(
e
=>
{
if
(
e
.
resource
.
toString
()
===
resource1
.
toString
())
{
manager
.
onModelEncodingChanged
(
model
=>
{
if
(
model
.
resource
.
toString
()
===
resource1
.
toString
())
{
encodingCounter
++
;
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录