Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4d1b09fc
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,发现更多精彩内容 >>
提交
4d1b09fc
编写于
9月 05, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move shutdown handling into base text file service
上级
92158fe2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
58 deletion
+38
-58
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+1
-5
src/vs/workbench/parts/files/common/textFileServices.ts
src/vs/workbench/parts/files/common/textFileServices.ts
+33
-10
src/vs/workbench/parts/files/electron-browser/textFileServices.ts
...orkbench/parts/files/electron-browser/textFileServices.ts
+4
-43
未找到文件。
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
4d1b09fc
...
@@ -30,7 +30,6 @@ import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollect
...
@@ -30,7 +30,6 @@ import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollect
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
IEditorGroupService
,
GroupArrangement
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorGroupService
,
GroupArrangement
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
TextFileService
}
from
'
vs/workbench/parts/files/common/textFileServices
'
;
import
{
TextFileService
}
from
'
vs/workbench/parts/files/common/textFileServices
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IFileService
,
IResolveContentOptions
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileService
,
IResolveContentOptions
}
from
'
vs/platform/files/common/files
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
ModelServiceImpl
}
from
'
vs/editor/common/services/modelServiceImpl
'
;
import
{
ModelServiceImpl
}
from
'
vs/editor/common/services/modelServiceImpl
'
;
...
@@ -96,17 +95,14 @@ export abstract class TestTextFileService extends TextFileService {
...
@@ -96,17 +95,14 @@ export abstract class TestTextFileService extends TextFileService {
constructor
(
constructor
(
@
ILifecycleService
lifecycleService
:
ILifecycleService
,
@
ILifecycleService
lifecycleService
:
ILifecycleService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IEventService
eventService
:
IEventService
,
@
IFileService
fileService
:
IFileService
,
@
IFileService
fileService
:
IFileService
,
@
IModelService
modelService
:
IModelService
,
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
)
{
)
{
super
(
lifecycleService
,
contextService
,
instantiationService
,
configurationService
,
telemetryService
,
editorGroupService
,
editorService
,
eventService
,
fileService
,
model
Service
,
untitledEditorService
);
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
editorGroupService
,
editorService
,
file
Service
,
untitledEditorService
);
}
}
public
resolveTextContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
TPromise
<
IRawTextContent
>
{
public
resolveTextContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
TPromise
<
IRawTextContent
>
{
...
...
src/vs/workbench/parts/files/common/textFileServices.ts
浏览文件 @
4d1b09fc
...
@@ -16,13 +16,10 @@ import {ConfirmResult} from 'vs/workbench/common/editor';
...
@@ -16,13 +16,10 @@ import {ConfirmResult} from 'vs/workbench/common/editor';
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IFileService
,
IResolveContentOptions
,
IFilesConfiguration
,
IFileOperationResult
,
FileOperationResult
,
AutoSaveConfiguration
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileService
,
IResolveContentOptions
,
IFilesConfiguration
,
IFileOperationResult
,
FileOperationResult
,
AutoSaveConfiguration
}
from
'
vs/platform/files/common/files
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
UntitledEditorModel
}
from
'
vs/workbench/common/editor/untitledEditorModel
'
;
import
{
UntitledEditorModel
}
from
'
vs/workbench/common/editor/untitledEditorModel
'
;
...
@@ -46,17 +43,14 @@ export abstract class TextFileService implements ITextFileService {
...
@@ -46,17 +43,14 @@ export abstract class TextFileService implements ITextFileService {
protected
configuredAutoSaveOnWindowChange
:
boolean
;
protected
configuredAutoSaveOnWindowChange
:
boolean
;
constructor
(
constructor
(
@
ILifecycleService
protected
lifecycleService
:
ILifecycleService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IWorkspaceContextService
protected
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IEditorGroupService
private
editorGroupService
:
IEditorGroupService
,
@
IEditorGroupService
private
editorGroupService
:
IEditorGroupService
,
@
IWorkbenchEditorService
protected
editorService
:
IWorkbenchEditorService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IEventService
private
eventService
:
IEventService
,
@
IFileService
protected
fileService
:
IFileService
,
@
IFileService
protected
fileService
:
IFileService
,
@
IModelService
protected
modelService
:
IModelService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
@
IUntitledEditorService
protected
untitledEditorService
:
IUntitledEditorService
)
{
)
{
this
.
listenerToUnbind
=
[];
this
.
listenerToUnbind
=
[];
this
.
_onAutoSaveConfigurationChange
=
new
Emitter
<
IAutoSaveConfiguration
>
();
this
.
_onAutoSaveConfigurationChange
=
new
Emitter
<
IAutoSaveConfiguration
>
();
...
@@ -73,12 +67,18 @@ export abstract class TextFileService implements ITextFileService {
...
@@ -73,12 +67,18 @@ export abstract class TextFileService implements ITextFileService {
public
abstract
promptForPath
(
defaultPath
?:
string
):
string
;
public
abstract
promptForPath
(
defaultPath
?:
string
):
string
;
public
abstract
confirmBeforeShutdown
():
boolean
|
TPromise
<
boolean
>
;
public
get
onAutoSaveConfigurationChange
():
Event
<
IAutoSaveConfiguration
>
{
public
get
onAutoSaveConfigurationChange
():
Event
<
IAutoSaveConfiguration
>
{
return
this
.
_onAutoSaveConfigurationChange
.
event
;
return
this
.
_onAutoSaveConfigurationChange
.
event
;
}
}
protected
registerListeners
():
void
{
protected
registerListeners
():
void
{
// Lifecycle
this
.
lifecycleService
.
onWillShutdown
(
event
=>
event
.
veto
(
this
.
beforeShutdown
()));
this
.
lifecycleService
.
onShutdown
(
this
.
dispose
,
this
);
// Configuration changes
// Configuration changes
this
.
listenerToUnbind
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationChange
(
e
.
config
)));
this
.
listenerToUnbind
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationChange
(
e
.
config
)));
...
@@ -88,6 +88,29 @@ export abstract class TextFileService implements ITextFileService {
...
@@ -88,6 +88,29 @@ export abstract class TextFileService implements ITextFileService {
this
.
listenerToUnbind
.
push
(
this
.
editorGroupService
.
onEditorsChanged
(()
=>
this
.
onEditorFocusChanged
()));
this
.
listenerToUnbind
.
push
(
this
.
editorGroupService
.
onEditorsChanged
(()
=>
this
.
onEditorFocusChanged
()));
}
}
private
beforeShutdown
():
boolean
|
TPromise
<
boolean
>
{
// Dirty files need treatment on shutdown
if
(
this
.
getDirty
().
length
)
{
// If auto save is enabled, save all files and then check again for dirty files
if
(
this
.
getAutoSaveMode
()
!==
AutoSaveMode
.
OFF
)
{
return
this
.
saveAll
(
false
/* files only */
).
then
(()
=>
{
if
(
this
.
getDirty
().
length
)
{
return
this
.
confirmBeforeShutdown
();
// we still have dirty files around, so confirm normally
}
return
false
;
// all good, no veto
});
}
// Otherwise just confirm what to do
return
this
.
confirmBeforeShutdown
();
}
return
false
;
// no veto
}
private
onWindowFocusLost
():
void
{
private
onWindowFocusLost
():
void
{
if
(
this
.
configuredAutoSaveOnWindowChange
&&
this
.
isDirty
())
{
if
(
this
.
configuredAutoSaveOnWindowChange
&&
this
.
isDirty
())
{
this
.
saveAll
().
done
(
null
,
errors
.
onUnexpectedError
);
this
.
saveAll
().
done
(
null
,
errors
.
onUnexpectedError
);
...
...
src/vs/workbench/parts/files/electron-browser/textFileServices.ts
浏览文件 @
4d1b09fc
...
@@ -12,12 +12,10 @@ import strings = require('vs/base/common/strings');
...
@@ -12,12 +12,10 @@ import strings = require('vs/base/common/strings');
import
{
isWindows
,
isLinux
}
from
'
vs/base/common/platform
'
;
import
{
isWindows
,
isLinux
}
from
'
vs/base/common/platform
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
ConfirmResult
}
from
'
vs/workbench/common/editor
'
;
import
{
ConfirmResult
}
from
'
vs/workbench/common/editor
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
TextFileService
as
AbstractTextFileService
}
from
'
vs/workbench/parts/files/common/textFileServices
'
;
import
{
TextFileService
as
AbstractTextFileService
}
from
'
vs/workbench/parts/files/common/textFileServices
'
;
import
{
AutoSaveMode
,
IRawTextContent
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IRawTextContent
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IFileService
,
IResolveContentOptions
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileService
,
IResolveContentOptions
}
from
'
vs/platform/files/common/files
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
@@ -37,29 +35,19 @@ export class TextFileService extends AbstractTextFileService {
...
@@ -37,29 +35,19 @@ export class TextFileService extends AbstractTextFileService {
constructor
(
constructor
(
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IFileService
fileService
:
IFileService
,
@
IFileService
fileService
:
IFileService
,
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
ILifecycleService
lifecycleService
:
ILifecycleService
,
@
ILifecycleService
lifecycleService
:
ILifecycleService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IEventService
eventService
:
IEventService
,
@
IModeService
private
modeService
:
IModeService
,
@
IModeService
private
modeService
:
IModeService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IWindowService
private
windowService
:
IWindowService
,
@
IWindowService
private
windowService
:
IWindowService
,
@
IModelService
modelService
:
IModelService
,
@
IModelService
private
modelService
:
IModelService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
)
{
)
{
super
(
lifecycleService
,
contextService
,
instantiationService
,
configurationService
,
telemetryService
,
editorGroupService
,
editorService
,
eventService
,
fileService
,
modelService
,
untitledEditorService
);
super
(
lifecycleService
,
contextService
,
configurationService
,
telemetryService
,
editorGroupService
,
editorService
,
fileService
,
untitledEditorService
);
}
protected
registerListeners
():
void
{
super
.
registerListeners
();
// Lifecycle
this
.
lifecycleService
.
onWillShutdown
(
event
=>
event
.
veto
(
this
.
beforeShutdown
()));
this
.
lifecycleService
.
onShutdown
(
this
.
onShutdown
,
this
);
}
}
public
resolveTextContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
TPromise
<
IRawTextContent
>
{
public
resolveTextContent
(
resource
:
URI
,
options
?:
IResolveContentOptions
):
TPromise
<
IRawTextContent
>
{
...
@@ -80,30 +68,7 @@ export class TextFileService extends AbstractTextFileService {
...
@@ -80,30 +68,7 @@ export class TextFileService extends AbstractTextFileService {
});
});
}
}
public
beforeShutdown
():
boolean
|
TPromise
<
boolean
>
{
public
confirmBeforeShutdown
():
boolean
|
TPromise
<
boolean
>
{
// Dirty files need treatment on shutdown
if
(
this
.
getDirty
().
length
)
{
// If auto save is enabled, save all files and then check again for dirty files
if
(
this
.
getAutoSaveMode
()
!==
AutoSaveMode
.
OFF
)
{
return
this
.
saveAll
(
false
/* files only */
).
then
(()
=>
{
if
(
this
.
getDirty
().
length
)
{
return
this
.
confirmBeforeShutdown
();
// we still have dirty files around, so confirm normally
}
return
false
;
// all good, no veto
});
}
// Otherwise just confirm what to do
return
this
.
confirmBeforeShutdown
();
}
return
false
;
// no veto
}
private
confirmBeforeShutdown
():
boolean
|
TPromise
<
boolean
>
{
const
confirm
=
this
.
confirmSave
();
const
confirm
=
this
.
confirmSave
();
// Save
// Save
...
@@ -128,10 +93,6 @@ export class TextFileService extends AbstractTextFileService {
...
@@ -128,10 +93,6 @@ export class TextFileService extends AbstractTextFileService {
}
}
}
}
private
onShutdown
():
void
{
super
.
dispose
();
}
public
confirmSave
(
resources
?:
URI
[]):
ConfirmResult
{
public
confirmSave
(
resources
?:
URI
[]):
ConfirmResult
{
if
(
!!
this
.
environmentService
.
extensionDevelopmentPath
)
{
if
(
!!
this
.
environmentService
.
extensionDevelopmentPath
)
{
return
ConfirmResult
.
DONT_SAVE
;
// no veto when we are in extension dev mode because we cannot assum we run interactive (e.g. tests)
return
ConfirmResult
.
DONT_SAVE
;
// no veto when we are in extension dev mode because we cannot assum we run interactive (e.g. tests)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录