Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ab09cff0
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,发现更多精彩内容 >>
提交
ab09cff0
编写于
8月 18, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove another getOptions() call
上级
d977e9cf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
51 deletion
+27
-51
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+1
-1
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+2
-1
src/vs/workbench/common/editor/editorStacksModel.ts
src/vs/workbench/common/editor/editorStacksModel.ts
+2
-4
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+9
-30
src/vs/workbench/test/common/editor/editorStacksModel.test.ts
...vs/workbench/test/common/editor/editorStacksModel.test.ts
+13
-15
未找到文件。
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
ab09cff0
...
...
@@ -305,7 +305,7 @@ export class TestEditorGroupService implements IEditorGroupService {
let
inst
=
new
InstantiationService
(
services
);
this
.
stacksModel
=
inst
.
createInstance
(
EditorStacksModel
);
this
.
stacksModel
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
}
public
fireChange
():
void
{
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
ab09cff0
...
...
@@ -99,6 +99,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
constructor
(
id
:
string
,
restoreFromStorage
:
boolean
,
@
IMessageService
private
messageService
:
IMessageService
,
@
IEventService
private
eventService
:
IEventService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
...
...
@@ -125,7 +126,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this
.
pendingEditorInputsToClose
=
[];
this
.
pendingEditorInputCloseTimeout
=
null
;
this
.
stacks
=
this
.
instantiationService
.
createInstance
(
EditorStacksModel
);
this
.
stacks
=
this
.
instantiationService
.
createInstance
(
EditorStacksModel
,
restoreFromStorage
);
const
editorConfig
=
configurationService
.
getConfiguration
<
IWorkbenchEditorConfiguration
>
().
workbench
.
editor
;
this
.
previewEditors
=
editorConfig
.
enablePreview
;
...
...
src/vs/workbench/common/editor/editorStacksModel.ts
浏览文件 @
ab09cff0
...
...
@@ -12,7 +12,6 @@ import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage'
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IWorkspaceContextService
}
from
'
vs/workbench/services/workspace/common/contextService
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
Position
,
Direction
}
from
'
vs/platform/editor/common/editor
'
;
...
...
@@ -667,9 +666,9 @@ export class EditorStacksModel implements IEditorStacksModel {
private
_onModelChanged
:
Emitter
<
IStacksModelChangeEvent
>
;
constructor
(
private
restoreFromStorage
:
boolean
,
@
IStorageService
private
storageService
:
IStorageService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
)
{
this
.
toDispose
=
[];
...
...
@@ -997,8 +996,7 @@ export class EditorStacksModel implements IEditorStacksModel {
}
private
load
():
void
{
const
options
=
this
.
contextService
.
getOptions
();
if
((
options
.
filesToCreate
&&
options
.
filesToCreate
.
length
)
||
(
options
.
filesToOpen
&&
options
.
filesToOpen
.
length
)
||
(
options
.
filesToDiff
&&
options
.
filesToDiff
.
length
))
{
if
(
!
this
.
restoreFromStorage
)
{
return
;
// do not load from last session if the user explicitly asks to open a set of files
}
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
ab09cff0
...
...
@@ -8,11 +8,10 @@
import
'
vs/css!./media/workbench
'
;
import
{
TPromise
,
ValueCallback
}
from
'
vs/base/common/winjs.base
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
DOM
=
require
(
'
vs/base/browser/dom
'
);
import
{
Box
,
Builder
,
withElementById
,
$
}
from
'
vs/base/browser/builder
'
;
import
{
Box
,
Builder
,
$
}
from
'
vs/base/browser/builder
'
;
import
{
Delayer
}
from
'
vs/base/common/async
'
;
import
assert
=
require
(
'
vs/base/common/assert
'
);
import
timer
=
require
(
'
vs/base/common/timer
'
);
...
...
@@ -126,6 +125,7 @@ export class Workbench implements IPartService {
private
editorBackgroundDelayer
:
Delayer
<
void
>
;
private
messagesVisibleContext
:
IContextKey
<
boolean
>
;
private
editorsVisibleContext
:
IContextKey
<
boolean
>
;
private
hasFilesToCreateOpenOrDiff
:
boolean
;
constructor
(
container
:
HTMLElement
,
...
...
@@ -142,27 +142,16 @@ export class Workbench implements IPartService {
@
IThreadService
private
threadService
:
IThreadService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
)
{
// Validate params
this
.
validateParams
(
container
,
options
);
// If String passed in as container, try to find it in DOM
if
(
types
.
isString
(
container
))
{
const
element
=
withElementById
(
container
.
toString
());
this
.
container
=
element
.
getHTMLElement
();
}
// Otherwise use as HTMLElement
else
{
this
.
container
=
container
;
}
this
.
container
=
container
;
this
.
workbenchParams
=
{
workspace
:
workspace
,
options
:
options
||
{}
,
options
,
serviceCollection
};
this
.
hasFilesToCreateOpenOrDiff
=
(
options
.
filesToCreate
&&
options
.
filesToCreate
.
length
>
0
)
||
(
options
.
filesToOpen
&&
options
.
filesToOpen
.
length
>
0
)
||
(
options
.
filesToDiff
&&
options
.
filesToDiff
.
length
>
0
);
this
.
toDispose
=
[];
this
.
toShutdown
=
[];
this
.
editorBackgroundDelayer
=
new
Delayer
<
void
>
(
50
);
...
...
@@ -172,16 +161,6 @@ export class Workbench implements IPartService {
});
}
private
validateParams
(
container
:
HTMLElement
,
options
:
IOptions
):
void
{
// Container
assert
.
ok
(
container
,
'
Workbench requires a container to be created with
'
);
if
(
types
.
isString
(
container
))
{
const
element
=
withElementById
(
container
.
toString
());
assert
.
ok
(
element
,
strings
.
format
(
'
Can not find HTMLElement with id
\'
{0}
\'
.
'
,
container
));
}
}
/**
* Starts the workbench and creates the HTML elements on the container. A workbench can only be started
* once. Use the shutdown function to free up resources created by the workbench on startup.
...
...
@@ -297,8 +276,8 @@ export class Workbench implements IPartService {
private
resolveEditorsToOpen
():
TPromise
<
{
input
:
EditorInput
,
options
?:
EditorOptions
}[]
>
{
// Files to open, diff or create
const
wbopt
=
this
.
workbenchParams
.
options
;
if
((
wbopt
.
filesToCreate
&&
wbopt
.
filesToCreate
.
length
)
||
(
wbopt
.
filesToOpen
&&
wbopt
.
filesToOpen
.
length
)
||
(
wbopt
.
filesToDiff
&&
wbopt
.
filesToDiff
.
length
))
{
if
(
this
.
hasFilesToCreateOpenOrDiff
)
{
const
wbopt
=
this
.
workbenchParams
.
options
;
const
filesToCreate
=
wbopt
.
filesToCreate
||
[];
const
filesToOpen
=
wbopt
.
filesToOpen
||
[];
const
filesToDiff
=
wbopt
.
filesToDiff
;
...
...
@@ -383,7 +362,7 @@ export class Workbench implements IPartService {
serviceCollection
.
set
(
IActivityService
,
this
.
activitybarPart
);
// Editor service (editor part)
this
.
editorPart
=
this
.
instantiationService
.
createInstance
(
EditorPart
,
Identifiers
.
EDITOR_PART
);
this
.
editorPart
=
this
.
instantiationService
.
createInstance
(
EditorPart
,
Identifiers
.
EDITOR_PART
,
!
this
.
hasFilesToCreateOpenOrDiff
);
this
.
toDispose
.
push
(
this
.
editorPart
);
this
.
toShutdown
.
push
(
this
.
editorPart
);
this
.
editorService
=
this
.
instantiationService
.
createInstance
(
WorkbenchEditorService
,
this
.
editorPart
);
...
...
src/vs/workbench/test/common/editor/editorStacksModel.test.ts
浏览文件 @
ab09cff0
...
...
@@ -9,7 +9,7 @@ import * as assert from 'assert';
import
{
EditorStacksModel
,
EditorGroup
}
from
'
vs/workbench/common/editor/editorStacksModel
'
;
import
{
EditorInput
,
IFileEditorInput
,
IEditorIdentifier
,
IEditorGroup
,
IStacksModelChangeEvent
,
IEditorRegistry
,
Extensions
as
EditorExtensions
,
IEditorInputFactory
}
from
'
vs/workbench/common/editor
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TestStorageService
,
TestConfigurationService
,
TestLifecycleService
,
TestContextService
,
TestWorkspace
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
{
TestStorageService
,
TestConfigurationService
,
TestLifecycleService
,
TestContextService
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
{
TestInstantiationService
}
from
'
vs/test/utils/instantiationTestUtils
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
...
...
@@ -32,7 +32,7 @@ function create(): EditorStacksModel {
inst
.
stub
(
IConfigurationService
,
config
);
return
inst
.
createInstance
(
EditorStacksModel
);
return
inst
.
createInstance
(
EditorStacksModel
,
true
);
}
interface
ModelEvents
{
...
...
@@ -645,7 +645,7 @@ suite('Editor Stacks Model', () => {
config
.
setUserConfiguration
(
'
workbench
'
,
{
editor
:
{
openPositioning
:
'
left
'
}
});
const
model
=
inst
.
createInstance
(
EditorStacksModel
);
const
model
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
const
group
=
model
.
openGroup
(
'
group
'
);
const
events
=
groupListener
(
group
);
...
...
@@ -1180,7 +1180,7 @@ suite('Editor Stacks Model', () => {
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
setInstantiationService
(
inst
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
let
group
=
model
.
openGroup
(
'
group
'
);
const
input1
=
input
();
...
...
@@ -1196,7 +1196,7 @@ suite('Editor Stacks Model', () => {
lifecycle
.
fireShutdown
();
// Create model again - should load from storage
model
=
inst
.
createInstance
(
EditorStacksModel
);
model
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
assert
.
equal
(
model
.
groups
.
length
,
1
);
...
...
@@ -1223,7 +1223,7 @@ suite('Editor Stacks Model', () => {
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
setInstantiationService
(
inst
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
let
group1
=
model
.
openGroup
(
'
group1
'
);
...
...
@@ -1266,7 +1266,7 @@ suite('Editor Stacks Model', () => {
lifecycle
.
fireShutdown
();
// Create model again - should load from storage
model
=
inst
.
createInstance
(
EditorStacksModel
);
model
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
group1
=
model
.
groups
[
0
];
group2
=
model
.
groups
[
1
];
...
...
@@ -1304,7 +1304,7 @@ suite('Editor Stacks Model', () => {
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
setInstantiationService
(
inst
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
let
group
=
model
.
openGroup
(
'
group1
'
);
...
...
@@ -1327,7 +1327,7 @@ suite('Editor Stacks Model', () => {
lifecycle
.
fireShutdown
();
// Create model again - should load from storage
model
=
inst
.
createInstance
(
EditorStacksModel
);
model
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
group
=
model
.
groups
[
0
];
...
...
@@ -1353,7 +1353,7 @@ suite('Editor Stacks Model', () => {
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
setInstantiationService
(
inst
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
let
group1
=
model
.
openGroup
(
'
group1
'
);
let
group2
=
model
.
openGroup
(
'
group1
'
);
...
...
@@ -1370,7 +1370,7 @@ suite('Editor Stacks Model', () => {
lifecycle
.
fireShutdown
();
// Create model again - should load from storage
model
=
inst
.
createInstance
(
EditorStacksModel
);
model
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
group1
=
model
.
groups
[
0
];
...
...
@@ -1384,17 +1384,15 @@ suite('Editor Stacks Model', () => {
let
inst
=
new
TestInstantiationService
();
inst
.
stub
(
IStorageService
,
new
TestStorageService
());
inst
.
stub
(
IWorkspaceContextService
,
new
TestContextService
(
TestWorkspace
,
{
filesToCreate
:
[
true
]
}));
const
lifecycle
=
new
TestLifecycleService
();
inst
.
stub
(
ILifecycleService
,
lifecycle
);
const
config
=
new
TestConfigurationService
();
config
.
setUserConfiguration
(
'
workbench
'
,
{
editor
:
{
openPositioning
:
'
right
'
}
});
inst
.
stub
(
IConfigurationService
,
config
);
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
setInstantiationService
(
inst
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
);
let
model
:
EditorStacksModel
=
inst
.
createInstance
(
EditorStacksModel
,
false
);
let
group1
=
model
.
openGroup
(
'
group1
'
);
let
group2
=
model
.
openGroup
(
'
group1
'
);
...
...
@@ -1411,7 +1409,7 @@ suite('Editor Stacks Model', () => {
lifecycle
.
fireShutdown
();
// Create model again - should NOT load from storage
model
=
inst
.
createInstance
(
EditorStacksModel
);
model
=
inst
.
createInstance
(
EditorStacksModel
,
false
);
assert
.
equal
(
model
.
groups
.
length
,
0
);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录