Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
66c081aa
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
66c081aa
编写于
12月 23, 2015
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first cut introduce new setting to control auto save delay
上级
0444705b
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
153 addition
and
106 deletion
+153
-106
src/vs/platform/files/common/files.ts
src/vs/platform/files/common/files.ts
+1
-0
src/vs/workbench/parts/files/browser/editors/fileEditorInput.ts
.../workbench/parts/files/browser/editors/fileEditorInput.ts
+5
-4
src/vs/workbench/parts/files/browser/editors/textFileEditorModel.ts
...kbench/parts/files/browser/editors/textFileEditorModel.ts
+15
-24
src/vs/workbench/parts/files/browser/fileTracker.ts
src/vs/workbench/parts/files/browser/fileTracker.ts
+1
-3
src/vs/workbench/parts/files/browser/files.contribution.ts
src/vs/workbench/parts/files/browser/files.contribution.ts
+5
-0
src/vs/workbench/parts/files/browser/textFileServices.ts
src/vs/workbench/parts/files/browser/textFileServices.ts
+49
-16
src/vs/workbench/parts/files/browser/views/workingFilesView.ts
...s/workbench/parts/files/browser/views/workingFilesView.ts
+2
-8
src/vs/workbench/parts/files/browser/views/workingFilesViewer.ts
...workbench/parts/files/browser/views/workingFilesViewer.ts
+4
-4
src/vs/workbench/parts/files/browser/workingFilesModel.ts
src/vs/workbench/parts/files/browser/workingFilesModel.ts
+21
-20
src/vs/workbench/parts/files/common/files.ts
src/vs/workbench/parts/files/common/files.ts
+14
-0
src/vs/workbench/parts/files/electron-browser/electronFileTracker.ts
...bench/parts/files/electron-browser/electronFileTracker.ts
+1
-1
src/vs/workbench/parts/files/electron-browser/textFileServices.ts
...orkbench/parts/files/electron-browser/textFileServices.ts
+5
-11
src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts
...orkbench/parts/files/test/browser/fileEditorInput.test.ts
+12
-6
src/vs/workbench/parts/files/test/browser/fileEditorModel.test.ts
...orkbench/parts/files/test/browser/fileEditorModel.test.ts
+6
-2
src/vs/workbench/parts/files/test/browser/textFileEditor.test.ts
...workbench/parts/files/test/browser/textFileEditor.test.ts
+3
-3
src/vs/workbench/test/browser/services.test.ts
src/vs/workbench/test/browser/services.test.ts
+9
-4
未找到文件。
src/vs/platform/files/common/files.ts
浏览文件 @
66c081aa
...
...
@@ -417,5 +417,6 @@ export interface IFilesConfiguration {
exclude
:
glob
.
IExpression
;
encoding
:
string
;
trimTrailingWhitespace
:
boolean
;
autoSaveAfterDelay
:
number
;
};
}
\ No newline at end of file
src/vs/workbench/parts/files/browser/editors/fileEditorInput.ts
浏览文件 @
66c081aa
...
...
@@ -19,7 +19,7 @@ import {IEditorRegistry, Extensions, EditorDescriptor} from 'vs/workbench/browse
import
{
BinaryEditorModel
}
from
'
vs/workbench/browser/parts/editor/binaryEditorModel
'
;
import
{
IFileOperationResult
,
FileOperationResult
}
from
'
vs/platform/files/common/files
'
;
import
{
FileEditorDescriptor
}
from
'
vs/workbench/parts/files/browser/files
'
;
import
{
BINARY_FILE_EDITOR_ID
,
FILE_EDITOR_INPUT_ID
,
FileEditorInput
as
CommonFileEditorInput
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
ITextFileService
,
BINARY_FILE_EDITOR_ID
,
FILE_EDITOR_INPUT_ID
,
FileEditorInput
as
CommonFileEditorInput
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
CACHE
,
TextFileEditorModel
,
State
}
from
'
vs/workbench/parts/files/browser/editors/textFileEditorModel
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -63,7 +63,8 @@ export class FileEditorInput extends CommonFileEditorInput {
mime
:
string
,
preferredEncoding
:
string
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
ITextFileService
private
textFileService
:
ITextFileService
)
{
super
();
...
...
@@ -157,11 +158,11 @@ export class FileEditorInput extends CommonFileEditorInput {
}
case
State
.
DIRTY
:
{
return
{
state
:
'
dirty
'
,
decoration
:
!
this
.
context
Service
.
isAutoSaveEnabled
()
?
'
\
u25cf
'
:
''
,
displayText
:
FileEditorInput
.
nlsDirtyDisplay
,
description
:
FileEditorInput
.
nlsDirtyMeta
};
return
{
state
:
'
dirty
'
,
decoration
:
!
this
.
textFile
Service
.
isAutoSaveEnabled
()
?
'
\
u25cf
'
:
''
,
displayText
:
FileEditorInput
.
nlsDirtyDisplay
,
description
:
FileEditorInput
.
nlsDirtyMeta
};
}
case
State
.
PENDING_SAVE
:
return
{
state
:
'
saving
'
,
decoration
:
!
this
.
context
Service
.
isAutoSaveEnabled
()
?
'
\
u25cf
'
:
''
,
displayText
:
FileEditorInput
.
nlsPendingSaveDisplay
,
description
:
FileEditorInput
.
nlsPendingSaveMeta
};
return
{
state
:
'
saving
'
,
decoration
:
!
this
.
textFile
Service
.
isAutoSaveEnabled
()
?
'
\
u25cf
'
:
''
,
displayText
:
FileEditorInput
.
nlsPendingSaveDisplay
,
description
:
FileEditorInput
.
nlsPendingSaveMeta
};
case
State
.
ERROR
:
return
{
state
:
'
error
'
,
decoration
:
'
\
u25cf
'
,
displayText
:
FileEditorInput
.
nlsErrorDisplay
,
description
:
FileEditorInput
.
nlsErrorMeta
};
...
...
src/vs/workbench/parts/files/browser/editors/textFileEditorModel.ts
浏览文件 @
66c081aa
...
...
@@ -14,10 +14,9 @@ import types = require('vs/base/common/types');
import
{
IModelContentChangedEvent
,
EventType
as
EditorEventType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IMode
}
from
'
vs/editor/common/modes
'
;
import
{
EventType
as
WorkbenchEventType
,
ResourceEvent
}
from
'
vs/workbench/common/events
'
;
import
{
LocalFileChangeEvent
,
EventType
as
FileEventType
,
TextFileChangeEvent
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
LocalFileChangeEvent
,
EventType
as
FileEventType
,
TextFileChangeEvent
,
ITextFileService
,
IAutoSaveConfiguration
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
EncodingMode
,
EditorModel
,
IEncodingSupport
}
from
'
vs/workbench/common/editor
'
;
import
{
BaseTextEditorModel
}
from
'
vs/workbench/browser/parts/editor/textEditorModel
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
IFileService
,
IFileStat
,
IFileOperationResult
,
FileOperationResult
,
IContent
}
from
'
vs/platform/files/common/files
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -96,7 +95,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements IEncodin
private
bufferSavedVersionId
:
number
;
private
versionOnDiskStat
:
IFileStat
;
private
blockModelContentChange
:
boolean
;
private
autoSave
Delay
:
number
;
private
autoSave
AfterMillies
:
number
;
private
autoSaveEnabled
:
boolean
;
private
autoSavePromises
:
TPromise
<
void
>
[];
private
mapPendingSaveToVersionId
:
{
[
versionId
:
string
]:
TPromise
<
void
>
};
...
...
@@ -113,10 +112,10 @@ export class TextFileEditorModel extends BaseTextEditorModel implements IEncodin
@
IModeService
modeService
:
IModeService
,
@
IModelService
modelService
:
IModelService
,
@
IEventService
private
eventService
:
IEventService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IFileService
private
fileService
:
IFileService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
ITextFileService
private
textFileService
:
ITextFileService
)
{
super
(
modelService
,
modeService
);
...
...
@@ -133,20 +132,17 @@ export class TextFileEditorModel extends BaseTextEditorModel implements IEncodin
this
.
lastDirtyTime
=
0
;
this
.
mapPendingSaveToVersionId
=
{};
this
.
update
Options
(
);
this
.
update
AutoSaveConfiguration
(
textFileService
.
getAutoSaveConfiguration
()
);
}
public
updateOptions
():
void
{
// Check for Autosave Delay Configuration
let
options
=
this
.
contextService
.
getOptions
();
if
(
options
&&
types
.
isNumber
(
options
.
autoSaveDelay
))
{
this
.
autoSaveDelay
=
options
.
autoSaveDelay
;
public
updateAutoSaveConfiguration
(
config
:
IAutoSaveConfiguration
):
void
{
if
(
typeof
config
.
autoSaveAfterDelay
===
'
number
'
&&
config
.
autoSaveAfterDelay
>
0
)
{
this
.
autoSaveAfterMillies
=
config
.
autoSaveAfterDelay
*
1000
;
this
.
autoSaveEnabled
=
true
;
}
else
{
this
.
autoSaveDelay
=
TextFileEditorModel
.
DEFAULT_AUTO_SAVE_DELAY
;
this
.
autoSaveAfterMillies
=
void
0
;
this
.
autoSaveEnabled
=
false
;
}
this
.
autoSaveEnabled
=
(
this
.
autoSaveDelay
!==
-
1
);
}
/**
...
...
@@ -385,13 +381,8 @@ export class TextFileEditorModel extends BaseTextEditorModel implements IEncodin
// Cancel any currently running auto saves to make this the one that succeeds
this
.
cancelAutoSavePromises
();
// Support to save without delay if configured as such
if
(
this
.
autoSaveDelay
===
0
)
{
return
this
.
doSave
(
versionId
,
true
);
}
// Otherwise create new save promise and keep it
let
promise
:
TPromise
<
void
>
=
Promise
.
timeout
(
this
.
autoSaveDelay
).
then
(()
=>
{
// Create new save promise and keep it
let
promise
:
TPromise
<
void
>
=
Promise
.
timeout
(
this
.
autoSaveAfterMillies
).
then
(()
=>
{
// Only trigger save if the version id has not changed meanwhile
if
(
versionId
===
this
.
versionId
)
{
...
...
@@ -449,8 +440,8 @@ export class TextFileEditorModel extends BaseTextEditorModel implements IEncodin
if
(
this
.
isBusySaving
())
{
diag
(
'
doSave(
'
+
versionId
+
'
) - exit - because busy saving
'
,
this
.
resource
,
new
Date
());
// Avoid endless loop here and guard if auto
SaveDelay is 0 (used by tests only)
if
(
this
.
autoSave
Delay
>
0
)
{
// Avoid endless loop here and guard if auto
save is disabled
if
(
this
.
autoSave
Enabled
)
{
return
this
.
doAutoSave
(
versionId
);
}
}
...
...
src/vs/workbench/parts/files/browser/fileTracker.ts
浏览文件 @
66c081aa
...
...
@@ -25,7 +25,6 @@ import {IUntitledEditorService} from 'vs/workbench/services/untitled/common/unti
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IQuickOpenService
}
from
'
vs/workbench/services/quickopen/common/quickOpenService
'
;
import
{
IActivityService
,
NumberBadge
}
from
'
vs/workbench/services/activity/common/activityService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -43,7 +42,6 @@ export class FileTracker implements IWorkbenchContribution {
private
toUnbind
:
{
():
void
;
}[];
constructor
(
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IEventService
private
eventService
:
IEventService
,
@
IQuickOpenService
private
quickOpenService
:
IQuickOpenService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
...
...
@@ -86,7 +84,7 @@ export class FileTracker implements IWorkbenchContribution {
private
onTextFileDirty
(
e
:
LocalFileChangeEvent
):
void
{
this
.
emitInputStateChangeEvent
(
e
.
getAfter
().
resource
);
if
(
!
this
.
context
Service
.
isAutoSaveEnabled
())
{
if
(
!
this
.
textFile
Service
.
isAutoSaveEnabled
())
{
this
.
updateActivityBadge
();
// no indication needed when auto save is turned off and we didn't show dirty
}
}
...
...
src/vs/workbench/parts/files/browser/files.contribution.ts
浏览文件 @
66c081aa
...
...
@@ -218,6 +218,11 @@ configurationRegistry.registerConfiguration({
'
type
'
:
'
boolean
'
,
'
default
'
:
false
,
'
description
'
:
nls
.
localize
(
'
trimTrailingWhitespace
'
,
"
When enabled, will trim trailing whitespace when you save a file.
"
)
},
'
files.autoSaveAfterDelay
'
:
{
'
type
'
:
'
number
'
,
'
default
'
:
0
,
'
description
'
:
nls
.
localize
(
'
autoSaveAfterDelay
'
,
"
When set to a positive number, will automatically save dirty files after configured seconds.
"
)
}
}
});
...
...
src/vs/workbench/parts/files/browser/textFileServices.ts
浏览文件 @
66c081aa
...
...
@@ -6,16 +6,18 @@
import
{
TPromise
,
Promise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
{
ListenerUnbind
}
from
'
vs/base/common/eventEmitter
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/browser/editors/fileEditorInput
'
;
import
{
CACHE
,
TextFileEditorModel
}
from
'
vs/workbench/parts/files/browser/editors/textFileEditorModel
'
;
import
{
IResult
,
ITextFileOperationResult
,
ConfirmResult
,
ITextFileService
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IResult
,
ITextFileOperationResult
,
ConfirmResult
,
ITextFileService
,
IAutoSaveConfiguration
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
EventType
}
from
'
vs/workbench/common/events
'
;
import
{
WorkingFilesModel
}
from
'
vs/workbench/parts/files/browser/workingFilesModel
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
IFileOperationResult
,
FileOperationResult
}
from
'
vs/platform/files/common/files
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IFilesConfiguration
,
IFileOperationResult
,
FileOperationResult
}
from
'
vs/platform/files/common/files
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IConfigurationService
,
IConfigurationServiceEvent
,
ConfigurationServiceEventTypes
}
from
'
vs/platform/configuration/common/configuration
'
;
/**
* The workbench file service implementation implements the raw file service spec and adds additional methods on top.
...
...
@@ -25,30 +27,49 @@ import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
export
abstract
class
TextFileService
implements
ITextFileService
{
public
serviceId
=
ITextFileService
;
private
listenerToUnbind
:
()
=>
void
;
private
workingFilesModel
:
WorkingFilesModel
;
private
listenerToUnbind
:
ListenerUnbind
[];
private
_workingFilesModel
:
WorkingFilesModel
;
private
configuredAutoSaveDelay
:
number
;
constructor
(
@
IEventService
private
eventService
:
IEventService
,
@
IWorkspaceContextService
protected
contextService
:
IWorkspaceContextService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
)
{
this
.
workingFilesModel
=
instantiationService
.
createInstance
(
WorkingFilesModel
)
;
this
.
listenerToUnbind
=
[]
;
this
.
registerListeners
();
this
.
loadConfiguration
();
}
private
get
workingFilesModel
():
WorkingFilesModel
{
if
(
!
this
.
_workingFilesModel
)
{
this
.
_workingFilesModel
=
this
.
instantiationService
.
createInstance
(
WorkingFilesModel
);
}
return
this
.
_workingFilesModel
;
}
private
registerListeners
():
void
{
this
.
listenerToUnbind
=
this
.
eventService
.
addListener
(
EventType
.
WORKBENCH_OPTIONS_CHANGED
,
()
=>
this
.
onOptionsChanged
());
if
(
this
.
lifecycleService
)
{
this
.
lifecycleService
.
addBeforeShutdownParticipant
(
this
);
this
.
lifecycleService
.
onShutdown
(
this
.
dispose
,
this
);
this
.
listenerToUnbind
.
push
(
this
.
configurationService
.
addListener
(
ConfigurationServiceEventTypes
.
UPDATED
,
(
e
:
IConfigurationServiceEvent
)
=>
this
.
onConfigurationChange
(
e
.
config
)));
}
private
loadConfiguration
():
void
{
this
.
configurationService
.
loadConfiguration
().
done
((
configuration
:
IFilesConfiguration
)
=>
{
this
.
onConfigurationChange
(
configuration
);
},
errors
.
onUnexpectedError
);
}
protected
onOptionsChanged
():
void
{
CACHE
.
getAll
().
forEach
((
model
)
=>
model
.
updateOptions
());
private
onConfigurationChange
(
configuration
:
IFilesConfiguration
):
void
{
this
.
configuredAutoSaveDelay
=
configuration
&&
configuration
.
files
&&
configuration
.
files
.
autoSaveAfterDelay
;
const
autoSaveConfig
=
this
.
getAutoSaveConfiguration
();
CACHE
.
getAll
().
forEach
((
model
)
=>
model
.
updateAutoSaveConfiguration
(
autoSaveConfig
));
}
public
getDirty
(
resource
?:
URI
):
URI
[]
{
...
...
@@ -172,8 +193,20 @@ export abstract class TextFileService implements ITextFileService {
return
this
.
workingFilesModel
;
}
public
isAutoSaveEnabled
():
boolean
{
return
this
.
configuredAutoSaveDelay
&&
this
.
configuredAutoSaveDelay
>
0
;
}
public
getAutoSaveConfiguration
():
IAutoSaveConfiguration
{
return
{
autoSaveAfterDelay
:
this
.
configuredAutoSaveDelay
&&
this
.
configuredAutoSaveDelay
>
0
?
this
.
configuredAutoSaveDelay
:
void
0
}
}
public
dispose
():
void
{
this
.
listenerToUnbind
();
while
(
this
.
listenerToUnbind
.
length
)
{
this
.
listenerToUnbind
.
pop
()();
}
this
.
workingFilesModel
.
dispose
();
...
...
src/vs/workbench/parts/files/browser/views/workingFilesView.ts
浏览文件 @
66c081aa
...
...
@@ -22,7 +22,6 @@ import {CloseWorkingFileAction, SaveAllAction} from 'vs/workbench/parts/files/br
import
{
WorkingFileEntry
}
from
'
vs/workbench/parts/files/browser/workingFilesModel
'
;
import
{
WorkingFilesDragAndDrop
,
WorkingFilesSorter
,
WorkingFilesController
,
WorkingFilesDataSource
,
WorkingFilesRenderer
,
WorkingFilesActionProvider
}
from
'
vs/workbench/parts/files/browser/views/workingFilesViewer
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
IConfigurationService
,
IConfigurationServiceEvent
,
ConfigurationServiceEventTypes
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
...
...
@@ -37,8 +36,6 @@ export class WorkingFilesView extends AdaptiveCollapsibleViewletView {
private
static
DEFAULT_MAX_VISIBLE_FILES
=
9
;
private
static
DEFAULT_DYNAMIC_HEIGHT
=
true
;
private
textFileService
:
ITextFileService
;
private
settings
:
any
;
private
maxVisibleWorkingFiles
:
number
;
private
dynamicHeight
:
boolean
;
...
...
@@ -51,18 +48,15 @@ export class WorkingFilesView extends AdaptiveCollapsibleViewletView {
constructor
(
actionRunner
:
IActionRunner
,
settings
:
any
,
@
IEventService
private
eventService
:
IEventService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IMessageService
messageService
:
IMessageService
,
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
@
ITextFileService
textFileService
:
ITextFileService
,
@
ITextFileService
private
textFileService
:
ITextFileService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
)
{
super
(
actionRunner
,
WorkingFilesView
.
computeExpandedBodySize
(
textFileService
.
getWorkingFilesModel
()),
!!
settings
[
WorkingFilesView
.
MEMENTO_COLLAPSED
],
'
workingFilesView
'
,
messageService
,
contextMenuService
);
this
.
textFileService
=
textFileService
;
this
.
settings
=
settings
;
this
.
model
=
this
.
textFileService
.
getWorkingFilesModel
();
this
.
lastDirtyCount
=
0
;
...
...
@@ -154,7 +148,7 @@ export class WorkingFilesView extends AdaptiveCollapsibleViewletView {
}
private
onTextFileDirty
(
e
:
LocalFileChangeEvent
):
void
{
if
(
!
this
.
context
Service
.
isAutoSaveEnabled
())
{
if
(
!
this
.
textFile
Service
.
isAutoSaveEnabled
())
{
this
.
updateDirtyIndicator
();
// no indication needed when auto save is turned off and we didn't show dirty
}
}
...
...
src/vs/workbench/parts/files/browser/views/workingFilesViewer.ts
浏览文件 @
66c081aa
...
...
@@ -22,7 +22,7 @@ import actions = require('vs/base/common/actions');
import
{
ActionsRenderer
}
from
'
vs/base/parts/tree/browser/actionsRenderer
'
;
import
{
ContributableActionProvider
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
keybindingForAction
,
CloseWorkingFileAction
,
SelectResourceForCompareAction
,
CompareResourcesAction
,
SaveFileAsAction
,
SaveFileAction
,
RevertFileAction
,
OpenToSideAction
}
from
'
vs/workbench/parts/files/browser/fileActions
'
;
import
{
asFileResource
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
asFileResource
,
ITextFileService
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
WorkingFileEntry
,
WorkingFilesModel
}
from
'
vs/workbench/parts/files/browser/workingFilesModel
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
@@ -119,8 +119,8 @@ export class WorkingFilesActionProvider extends ContributableActionProvider {
constructor
(
model
:
WorkingFilesModel
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
I
WorkspaceContextService
private
contextService
:
IWorkspaceContext
Service
,
@
I
UntitledEditorService
private
untitledEditorService
:
IUntitledEditor
Service
@
I
UntitledEditorService
private
untitledEditorService
:
IUntitledEditor
Service
,
@
I
TextFileService
private
textFileService
:
ITextFile
Service
)
{
super
();
...
...
@@ -155,7 +155,7 @@ export class WorkingFilesActionProvider extends ContributableActionProvider {
actions
.
unshift
(
openToSideAction
);
// be on top
// Files: Save / Revert
let
autoSaveEnabled
=
this
.
context
Service
.
isAutoSaveEnabled
();
let
autoSaveEnabled
=
this
.
textFile
Service
.
isAutoSaveEnabled
();
if
((
!
autoSaveEnabled
||
element
.
dirty
)
&&
element
.
isFile
)
{
actions
.
push
(
new
Separator
());
...
...
src/vs/workbench/parts/files/browser/workingFilesModel.ts
浏览文件 @
66c081aa
...
...
@@ -11,7 +11,7 @@ import paths = require('vs/base/common/paths');
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
labels
=
require
(
'
vs/base/common/labels
'
);
import
{
disposeAll
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
filesCommon
=
require
(
'
vs/workbench/parts/files/common/files
'
)
;
import
{
ITextFileService
,
IWorkingFilesModel
,
IWorkingFileModelChangeEvent
,
IWorkingFileEntry
,
EventType
,
LocalFileChangeEvent
,
WORKING_FILES_MODEL_ENTRY_CLASS_ID
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFileStat
,
FileChangeType
,
FileChangesEvent
,
EventType
as
FileEventType
}
from
'
vs/platform/files/common/files
'
;
import
{
UntitledEditorEvent
,
EventType
as
WorkbenchEventType
,
EditorEvent
}
from
'
vs/workbench/common/events
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
...
...
@@ -22,14 +22,14 @@ import {asFileEditorInput} from 'vs/workbench/common/editor';
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
export
class
WorkingFilesModel
implements
filesCommon
.
IWorkingFilesModel
{
export
class
WorkingFilesModel
implements
IWorkingFilesModel
{
private
static
STORAGE_KEY
=
'
workingFiles.model.entries
'
;
private
entries
:
WorkingFileEntry
[];
private
pathLabelProvider
:
labels
.
PathLabelProvider
;
private
mapEntryToResource
:
{
[
resource
:
string
]:
WorkingFileEntry
;
};
private
_onModelChange
:
Emitter
<
filesCommon
.
IWorkingFileModelChangeEvent
>
;
private
_onModelChange
:
Emitter
<
IWorkingFileModelChangeEvent
>
;
private
_onWorkingFileChange
:
Emitter
<
WorkingFileEntry
>
;
private
toDispose
:
IDisposable
[];
...
...
@@ -39,13 +39,14 @@ export class WorkingFilesModel implements filesCommon.IWorkingFilesModel {
@
IPartService
private
partService
:
IPartService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
ITextFileService
private
textFileService
:
ITextFileService
)
{
this
.
pathLabelProvider
=
new
labels
.
PathLabelProvider
(
this
.
contextService
);
this
.
entries
=
[];
this
.
toDispose
=
[];
this
.
mapEntryToResource
=
Object
.
create
(
null
);
this
.
_onModelChange
=
new
Emitter
<
filesCommon
.
IWorkingFileModelChangeEvent
>
();
this
.
_onModelChange
=
new
Emitter
<
IWorkingFileModelChangeEvent
>
();
this
.
_onWorkingFileChange
=
new
Emitter
<
WorkingFileEntry
>
();
this
.
load
();
...
...
@@ -55,7 +56,7 @@ export class WorkingFilesModel implements filesCommon.IWorkingFilesModel {
private
registerListeners
():
void
{
// listen to global file changes to clean up model
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
'
files.internal:fileChanged
'
,
(
e
:
filesCommon
.
LocalFileChangeEvent
)
=>
this
.
onLocalFileChange
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
'
files.internal:fileChanged
'
,
(
e
:
LocalFileChangeEvent
)
=>
this
.
onLocalFileChange
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
FileEventType
.
FILE_CHANGES
,
(
e
)
=>
this
.
onFileChanges
(
e
)));
// listen to untitled
...
...
@@ -63,10 +64,10 @@ export class WorkingFilesModel implements filesCommon.IWorkingFilesModel {
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_DELETED
,
(
e
)
=>
this
.
onUntitledFileDeleted
(
e
)));
// listen to files being changed locally
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
filesCommon
.
EventType
.
FILE_DIRTY
,
(
e
:
filesCommon
.
LocalFileChangeEvent
)
=>
this
.
onTextFileDirty
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
filesCommon
.
EventType
.
FILE_SAVE_ERROR
,
(
e
:
filesCommon
.
LocalFileChangeEvent
)
=>
this
.
onTextFileSaveError
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
filesCommon
.
EventType
.
FILE_SAVED
,
(
e
:
filesCommon
.
LocalFileChangeEvent
)
=>
this
.
onTextFileSaved
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
filesCommon
.
EventType
.
FILE_REVERTED
,
(
e
:
filesCommon
.
LocalFileChangeEvent
)
=>
this
.
onTextFileReverted
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
FILE_DIRTY
,
(
e
:
LocalFileChangeEvent
)
=>
this
.
onTextFileDirty
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
FILE_SAVE_ERROR
,
(
e
:
LocalFileChangeEvent
)
=>
this
.
onTextFileSaveError
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
FILE_SAVED
,
(
e
:
LocalFileChangeEvent
)
=>
this
.
onTextFileSaved
(
e
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
FILE_REVERTED
,
(
e
:
LocalFileChangeEvent
)
=>
this
.
onTextFileReverted
(
e
)));
// clean up model on set input error
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
EDITOR_SET_INPUT_ERROR
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputSetError
(
e
)));
...
...
@@ -83,23 +84,23 @@ export class WorkingFilesModel implements filesCommon.IWorkingFilesModel {
}
}
private
onTextFileDirty
(
e
:
filesCommon
.
LocalFileChangeEvent
):
void
{
if
(
!
this
.
context
Service
.
isAutoSaveEnabled
())
{
private
onTextFileDirty
(
e
:
LocalFileChangeEvent
):
void
{
if
(
!
this
.
textFile
Service
.
isAutoSaveEnabled
())
{
this
.
updateDirtyState
(
e
.
getAfter
().
resource
,
true
);
// no indication needed when auto save is turned off and we didn't show dirty
}
else
{
this
.
addEntry
(
e
.
getAfter
().
resource
);
}
}
private
onTextFileSaveError
(
e
:
filesCommon
.
LocalFileChangeEvent
):
void
{
private
onTextFileSaveError
(
e
:
LocalFileChangeEvent
):
void
{
this
.
updateDirtyState
(
e
.
getAfter
().
resource
,
true
);
}
private
onTextFileSaved
(
e
:
filesCommon
.
LocalFileChangeEvent
):
void
{
private
onTextFileSaved
(
e
:
LocalFileChangeEvent
):
void
{
this
.
updateDirtyState
(
e
.
getAfter
().
resource
,
false
);
}
private
onTextFileReverted
(
e
:
filesCommon
.
LocalFileChangeEvent
):
void
{
private
onTextFileReverted
(
e
:
LocalFileChangeEvent
):
void
{
if
(
this
.
hasEntry
(
e
.
getAfter
().
resource
))
{
this
.
updateDirtyState
(
e
.
getAfter
().
resource
,
false
);
}
...
...
@@ -119,7 +120,7 @@ export class WorkingFilesModel implements filesCommon.IWorkingFilesModel {
}
}
private
onLocalFileChange
(
e
:
filesCommon
.
LocalFileChangeEvent
):
void
{
private
onLocalFileChange
(
e
:
LocalFileChangeEvent
):
void
{
if
(
e
.
gotMoved
())
{
this
.
moveEntry
(
e
.
getBefore
().
resource
,
e
.
getAfter
().
resource
);
}
...
...
@@ -144,7 +145,7 @@ export class WorkingFilesModel implements filesCommon.IWorkingFilesModel {
}
}
public
get
onModelChange
():
Event
<
filesCommon
.
IWorkingFileModelChangeEvent
>
{
public
get
onModelChange
():
Event
<
IWorkingFileModelChangeEvent
>
{
return
this
.
_onModelChange
.
event
;
}
...
...
@@ -395,7 +396,7 @@ export class WorkingFilesModel implements filesCommon.IWorkingFilesModel {
this
.
toDispose
=
disposeAll
(
this
.
toDispose
);
}
private
fireModelChange
(
event
:
filesCommon
.
IWorkingFileModelChangeEvent
):
void
{
private
fireModelChange
(
event
:
IWorkingFileModelChangeEvent
):
void
{
this
.
_onModelChange
.
fire
(
event
);
}
...
...
@@ -413,7 +414,7 @@ interface ISerializedWorkingFileEntry {
index
:
number
;
}
export
class
WorkingFileEntry
implements
filesCommon
.
IWorkingFileEntry
{
export
class
WorkingFileEntry
implements
IWorkingFileEntry
{
private
_resource
:
uri
;
private
_index
:
number
;
private
_dirty
:
boolean
;
...
...
@@ -445,7 +446,7 @@ export class WorkingFileEntry implements filesCommon.IWorkingFileEntry {
}
public
get
CLASS_ID
():
string
{
return
filesCommon
.
WORKING_FILES_MODEL_ENTRY_CLASS_ID
;
return
WORKING_FILES_MODEL_ENTRY_CLASS_ID
;
}
public
get
isFile
():
boolean
{
...
...
src/vs/workbench/parts/files/common/files.ts
浏览文件 @
66c081aa
...
...
@@ -288,6 +288,10 @@ export interface IResult {
success
?:
boolean
;
}
export
interface
IAutoSaveConfiguration
{
autoSaveAfterDelay
:
number
;
}
export
var
ITextFileService
=
createDecorator
<
ITextFileService
>
(
TEXT_FILE_SERVICE_ID
);
export
interface
ITextFileService
extends
IDisposable
{
...
...
@@ -360,4 +364,14 @@ export interface ITextFileService extends IDisposable {
* Provides access to the list of working files.
*/
getWorkingFilesModel
():
IWorkingFilesModel
;
/**
* Checks if the user configured auto save to be enabled or not
*/
isAutoSaveEnabled
():
boolean
;
/**
* Convinient fast access to the configured auto save settings.
*/
getAutoSaveConfiguration
():
IAutoSaveConfiguration
;
}
\ No newline at end of file
src/vs/workbench/parts/files/electron-browser/electronFileTracker.ts
浏览文件 @
66c081aa
...
...
@@ -160,7 +160,7 @@ export class FileTracker implements IWorkbenchContribution {
}
private
onTextFileDirty
(
e
:
LocalFileChangeEvent
):
void
{
if
(
!
this
.
context
Service
.
isAutoSaveEnabled
()
&&
!
this
.
isDocumentedEdited
)
{
if
(
!
this
.
textFile
Service
.
isAutoSaveEnabled
()
&&
!
this
.
isDocumentedEdited
)
{
this
.
updateDocumentEdited
();
// no indication needed when auto save is turned off and we didn't show dirty
}
}
...
...
src/vs/workbench/parts/files/electron-browser/textFileServices.ts
浏览文件 @
66c081aa
...
...
@@ -23,9 +23,9 @@ import {SyncActionDescriptor} from 'vs/platform/actions/common/actions';
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IInstantiationService
,
INullService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IConfigurationService
,
IConfigurationServiceEvent
,
ConfigurationServiceEventTypes
}
from
'
vs/platform/configuration/common/configuration
'
;
import
remote
=
require
(
'
remote
'
);
import
ipc
=
require
(
'
ipc
'
);
...
...
@@ -35,20 +35,14 @@ const Dialog = remote.require('dialog');
export
class
TextFileService
extends
BrowserTextFileService
{
constructor
(
@
IEventService
eventService
:
IEventService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IFileService
private
fileService
:
IFileService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
ILifecycleService
lifecycleService
:
ILifecycleService
@
ILifecycleService
lifecycleService
:
ILifecycleService
,
@
IConfigurationService
configurationService
:
IConfigurationService
)
{
super
(
eventService
,
contextService
,
instantiationService
,
lifecycleService
);
this
.
registerAutoSaveActions
();
}
protected
onOptionsChanged
():
void
{
super
.
onOptionsChanged
();
super
(
contextService
,
instantiationService
,
configurationService
,
lifecycleService
);
this
.
registerAutoSaveActions
();
}
...
...
src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts
浏览文件 @
66c081aa
...
...
@@ -14,7 +14,7 @@ import {create} from 'vs/platform/instantiation/common/instantiationService';
import
{
TextFileService
}
from
'
vs/workbench/parts/files/browser/textFileServices
'
;
import
{
MainTelemetryService
}
from
'
vs/platform/telemetry/browser/mainTelemetryService
'
;
import
{
FileTracker
}
from
'
vs/workbench/parts/files/browser/fileTracker
'
;
import
{
TestFileService
,
Test
EditorService
,
TestPartService
,
MockRequest
Service
,
TestEventService
,
TestContextService
,
TestStorageService
,
TestWorkspace
}
from
'
vs/workbench/test/browser/servicesTestUtils
'
;
import
{
TestFileService
,
Test
LifecycleService
,
TestEditorService
,
TestPartService
,
MockRequestService
,
TestConfiguration
Service
,
TestEventService
,
TestContextService
,
TestStorageService
,
TestWorkspace
}
from
'
vs/workbench/test/browser/servicesTestUtils
'
;
import
{
createMockModelService
,
createMockModeService
}
from
'
vs/editor/test/common/servicesTestUtils
'
;
function
toResource
(
path
)
{
...
...
@@ -44,7 +44,9 @@ suite('Files - FileEditorInput', () => {
partService
:
new
TestPartService
(),
modeService
:
createMockModeService
(),
modelService
:
createMockModelService
(),
telemetryService
:
telemetryService
telemetryService
:
telemetryService
,
lifecycleService
:
new
TestLifecycleService
(),
configurationService
:
new
TestConfigurationService
()
});
let
textFileServices
=
instantiationService
.
createInstance
(
<
any
>
TextFileService
);
...
...
@@ -109,8 +111,8 @@ suite('Files - FileEditorInput', () => {
});
test
(
'
Input.matches() - FileEditorInput
'
,
function
()
{
let
fileEditorInput
=
new
FileEditorInput
(
toResource
(
'
/foo/bar/updatefile.js
'
),
'
text/javascript
'
,
void
0
,
void
0
,
void
0
);
let
contentEditorInput2
=
new
FileEditorInput
(
toResource
(
'
/foo/bar/updatefile.js
'
),
'
text/javascript
'
,
void
0
,
void
0
,
void
0
);
let
fileEditorInput
=
new
FileEditorInput
(
toResource
(
'
/foo/bar/updatefile.js
'
),
'
text/javascript
'
,
void
0
,
void
0
,
void
0
,
void
0
);
let
contentEditorInput2
=
new
FileEditorInput
(
toResource
(
'
/foo/bar/updatefile.js
'
),
'
text/javascript
'
,
void
0
,
void
0
,
void
0
,
void
0
);
assert
.
strictEqual
(
fileEditorInput
.
matches
(
null
),
false
);
assert
.
strictEqual
(
fileEditorInput
.
matches
(
fileEditorInput
),
true
);
...
...
@@ -133,7 +135,9 @@ suite('Files - FileEditorInput', () => {
partService
:
new
TestPartService
(),
modeService
:
createMockModeService
(),
modelService
:
createMockModelService
(),
telemetryService
:
telemetryService
telemetryService
:
telemetryService
,
lifecycleService
:
new
TestLifecycleService
(),
configurationService
:
new
TestConfigurationService
()
});
let
textFileServices
=
instantiationService
.
createInstance
(
<
any
>
TextFileService
);
...
...
@@ -175,7 +179,9 @@ suite('Files - FileEditorInput', () => {
partService
:
new
TestPartService
(),
modeService
:
createMockModeService
(),
modelService
:
createMockModelService
(),
telemetryService
:
telemetryService
telemetryService
:
telemetryService
,
lifecycleService
:
new
TestLifecycleService
(),
configurationService
:
new
TestConfigurationService
()
});
let
textFileServices
=
instantiationService
.
createInstance
(
<
any
>
TextFileService
);
...
...
src/vs/workbench/parts/files/test/browser/fileEditorModel.test.ts
浏览文件 @
66c081aa
...
...
@@ -15,7 +15,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
import
{
create
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
TextFileService
}
from
'
vs/workbench/parts/files/browser/textFileServices
'
;
import
{
EventType
,
LocalFileChangeEvent
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
TestFileService
,
Test
PartService
,
TestEditor
Service
,
TestUntitledEditorService
,
TestStorageService
,
TestTelemetryService
,
TestContextService
,
TestMessageService
,
TestEventService
}
from
'
vs/workbench/test/browser/servicesTestUtils
'
;
import
{
TestFileService
,
Test
LifecycleService
,
TestPartService
,
TestEditorService
,
TestConfiguration
Service
,
TestUntitledEditorService
,
TestStorageService
,
TestTelemetryService
,
TestContextService
,
TestMessageService
,
TestEventService
}
from
'
vs/workbench/test/browser/servicesTestUtils
'
;
import
Severity
=
require
(
'
vs/base/common/severity
'
);
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IMessageService
,
IConfirmation
}
from
'
vs/platform/message/common/message
'
;
...
...
@@ -48,10 +48,14 @@ suite('Files - TextFileEditorModel', () => {
editorService
:
new
TestEditorService
(),
partService
:
new
TestPartService
(),
modeService
:
createMockModeService
(),
modelService
:
createMockModelService
()
modelService
:
createMockModelService
(),
lifecycleService
:
new
TestLifecycleService
(),
configurationService
:
new
TestConfigurationService
()
});
textFileService
=
<
TextFileService
>
baseInstantiationService
.
createInstance
(
<
any
>
TextFileService
);
baseInstantiationService
.
registerService
(
'
textFileService
'
,
textFileService
);
});
teardown
(()
=>
{
...
...
src/vs/workbench/parts/files/test/browser/textFileEditor.test.ts
浏览文件 @
66c081aa
...
...
@@ -37,9 +37,9 @@ suite('Files - TextFileEditor', () => {
equal
(
Registry
.
as
(
ExtensionId
).
getEditors
().
length
,
oldEditorCnt
+
2
);
equal
(
Registry
.
as
(
ExtensionId
).
getEditorInputs
().
length
,
oldInputCnt
+
2
);
strictEqual
(
Registry
.
as
(
ExtensionId
).
getEditor
(
new
FileEditorInput
(
URI
.
file
(
join
(
'
C:
\\
'
,
"
/foo/bar/foobar.html
"
)),
"
test-text/html
"
,
void
0
,
void
0
,
void
0
)),
d1
);
strictEqual
(
Registry
.
as
(
ExtensionId
).
getEditor
(
new
FileEditorInput
(
URI
.
file
(
join
(
'
C:
\\
'
,
"
/foo/bar/foobar.js
"
)),
"
test-text/javascript
"
,
void
0
,
void
0
,
void
0
)),
d1
);
strictEqual
(
Registry
.
as
(
ExtensionId
).
getEditor
(
new
FileEditorInput
(
URI
.
file
(
join
(
'
C:
\\
'
,
"
/foo/bar/foobar.css
"
)),
"
test-text/css
"
,
void
0
,
void
0
,
void
0
)),
d2
);
strictEqual
(
Registry
.
as
(
ExtensionId
).
getEditor
(
new
FileEditorInput
(
URI
.
file
(
join
(
'
C:
\\
'
,
"
/foo/bar/foobar.html
"
)),
"
test-text/html
"
,
void
0
,
void
0
,
void
0
,
void
0
)),
d1
);
strictEqual
(
Registry
.
as
(
ExtensionId
).
getEditor
(
new
FileEditorInput
(
URI
.
file
(
join
(
'
C:
\\
'
,
"
/foo/bar/foobar.js
"
)),
"
test-text/javascript
"
,
void
0
,
void
0
,
void
0
,
void
0
)),
d1
);
strictEqual
(
Registry
.
as
(
ExtensionId
).
getEditor
(
new
FileEditorInput
(
URI
.
file
(
join
(
'
C:
\\
'
,
"
/foo/bar/foobar.css
"
)),
"
test-text/css
"
,
void
0
,
void
0
,
void
0
,
void
0
)),
d2
);
Registry
.
as
(
ExtensionId
).
setEditors
(
oldEditors
);
});
...
...
src/vs/workbench/test/browser/services.test.ts
浏览文件 @
66c081aa
...
...
@@ -17,7 +17,7 @@ import {StringEditorModel} from 'vs/workbench/browser/parts/editor/stringEditorM
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/browser/editors/fileEditorInput
'
;
import
{
TextFileEditorModel
}
from
'
vs/workbench/parts/files/browser/editors/textFileEditorModel
'
;
import
{
TextFileService
}
from
'
vs/workbench/parts/files/browser/textFileServices
'
;
import
{
TestEventService
,
Test
PartService
,
TestStorage
Service
,
TestRequestService
,
TestContextService
,
TestWorkspace
,
TestEditorService
,
MockRequestService
}
from
'
vs/workbench/test/browser/servicesTestUtils
'
;
import
{
TestEventService
,
Test
LifecycleService
,
TestPartService
,
TestStorageService
,
TestConfiguration
Service
,
TestRequestService
,
TestContextService
,
TestWorkspace
,
TestEditorService
,
MockRequestService
}
from
'
vs/workbench/test/browser/servicesTestUtils
'
;
import
{
Viewlet
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
EventType
}
from
'
vs/workbench/common/events
'
;
import
{
MainTelemetryService
}
from
'
vs/platform/telemetry/browser/mainTelemetryService
'
;
...
...
@@ -243,16 +243,20 @@ suite('Workbench UI Services', () => {
contextService
:
contextService
,
requestService
:
requestService
,
telemetryService
:
telemetryService
,
configurationService
:
new
TestConfigurationService
(),
untitledEditorService
:
new
UntitledEditorService
(),
storageService
:
new
TestStorageService
(),
editorService
:
editorService
,
partService
:
new
TestPartService
(),
modeService
:
createMockModeService
(),
modelService
:
createMockModelService
(),
lifecycleService
:
new
TestLifecycleService
(),
fileService
:
TestFileService
};
let
inst
=
create
(
services
);
let
textFileService
=
inst
.
createInstance
(
<
any
>
TextFileService
);
inst
.
registerService
(
'
textFileService
'
,
textFileService
);
services
[
'
instantiationService
'
]
=
inst
;
let
activeInput
:
EditorInput
=
inst
.
createInstance
(
FileEditorInput
,
toResource
(
'
/something.js
'
),
'
text/javascript
'
,
void
0
);
...
...
@@ -347,14 +351,15 @@ suite('Workbench UI Services', () => {
untitledEditorService
:
new
UntitledEditorService
(),
editorService
:
editorService
,
partService
:
new
TestPartService
(),
modelService
:
createMockModelService
()
lifecycleService
:
new
TestLifecycleService
(),
modelService
:
createMockModelService
(),
configurationService
:
new
TestConfigurationService
()
};
let
inst
=
create
(
services
);
let
textFileService
=
inst
.
createInstance
(
<
any
>
TextFileService
);
services
[
'
textFileService
'
]
=
textFileService
;
services
[
'
instantiationService
'
]
=
inst
;
inst
.
registerService
(
'
textFileService
'
,
textFileService
);
services
[
'
instantiationService
'
]
=
inst
;
let
activeInput
:
EditorInput
=
inst
.
createInstance
(
FileEditorInput
,
toResource
(
'
/something.js
'
),
'
text/javascript
'
,
void
0
);
let
testEditorPart
=
new
TestEditorPart
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录