Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
46a1c8bb
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,发现更多精彩内容 >>
提交
46a1c8bb
编写于
5月 15, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - more tests adoption
上级
57583403
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
702 addition
and
735 deletion
+702
-735
src/vs/workbench/browser/parts/editor/editorCommands.ts
src/vs/workbench/browser/parts/editor/editorCommands.ts
+1
-11
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+4
-4
src/vs/workbench/common/editor/editorGroup.ts
src/vs/workbench/common/editor/editorGroup.ts
+547
-550
src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts
...orkbench/parts/files/test/browser/fileEditorInput.test.ts
+1
-24
src/vs/workbench/parts/files/test/browser/fileEditorTracker.test.ts
...kbench/parts/files/test/browser/fileEditorTracker.test.ts
+103
-102
src/vs/workbench/services/editor/common/editorService.ts
src/vs/workbench/services/editor/common/editorService.ts
+1
-1
src/vs/workbench/services/editor/test/browser/nextEditorService.test.ts
...ch/services/editor/test/browser/nextEditorService.test.ts
+9
-2
src/vs/workbench/test/browser/parts/editor/editorGroups.test.ts
.../workbench/test/browser/parts/editor/editorGroups.test.ts
+32
-33
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+4
-8
未找到文件。
src/vs/workbench/browser/parts/editor/editorCommands.ts
浏览文件 @
46a1c8bb
...
@@ -13,7 +13,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
...
@@ -13,7 +13,7 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi
import
{
IEditor
,
Position
,
POSITIONS
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditor
,
Position
,
POSITIONS
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
TextDiffEditor
}
from
'
vs/workbench/browser/parts/editor/textDiffEditor
'
;
import
{
TextDiffEditor
}
from
'
vs/workbench/browser/parts/editor/textDiffEditor
'
;
import
{
Editor
StacksModel
,
Editor
Group
}
from
'
vs/workbench/common/editor/editorGroup
'
;
import
{
EditorGroup
}
from
'
vs/workbench/common/editor/editorGroup
'
;
import
{
KeyMod
,
KeyCode
,
KeyChord
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyMod
,
KeyCode
,
KeyChord
}
from
'
vs/base/common/keyCodes
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
...
@@ -527,16 +527,6 @@ function registerEditorCommands() {
...
@@ -527,16 +527,6 @@ function registerEditorCommands() {
when
:
void
0
,
when
:
void
0
,
primary
:
void
0
primary
:
void
0
});
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
_workbench.validateStacksModel
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
0
),
handler
(
accessor
:
ServicesAccessor
)
{
(
<
EditorStacksModel
>
accessor
.
get
(
IEditorGroupService
).
getStacksModel
()).
validate
();
},
when
:
void
0
,
primary
:
void
0
});
}
}
function
positionAndInput
(
editorGroupService
:
IEditorGroupService
,
editorService
:
IWorkbenchEditorService
,
context
?:
IEditorCommandsContext
):
{
position
:
Position
,
input
:
IEditorInput
}
{
function
positionAndInput
(
editorGroupService
:
IEditorGroupService
,
editorService
:
IWorkbenchEditorService
,
context
?:
IEditorCommandsContext
):
{
position
:
Position
,
input
:
IEditorInput
}
{
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
46a1c8bb
...
@@ -33,7 +33,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
...
@@ -33,7 +33,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
Editor
StacksModel
,
Editor
Group
,
EditorIdentifier
,
EditorCloseEvent
}
from
'
vs/workbench/common/editor/editorGroup
'
;
import
{
EditorGroup
,
EditorIdentifier
,
EditorCloseEvent
}
from
'
vs/workbench/common/editor/editorGroup
'
;
import
{
Event
,
Emitter
,
once
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
,
once
}
from
'
vs/base/common/event
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
...
@@ -70,7 +70,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
...
@@ -70,7 +70,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
private
dimension
:
Dimension
;
private
dimension
:
Dimension
;
private
editorGroupsControl
:
IEditorGroupsControl
;
private
editorGroupsControl
:
IEditorGroupsControl
;
private
memento
:
object
;
private
memento
:
object
;
private
stacks
:
EditorStacksModel
;
private
stacks
:
any
;
private
tabOptions
:
IEditorTabOptions
;
private
tabOptions
:
IEditorTabOptions
;
private
forceHideTabs
:
boolean
;
private
forceHideTabs
:
boolean
;
private
revealIfOpen
:
boolean
;
private
revealIfOpen
:
boolean
;
...
@@ -132,7 +132,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
...
@@ -132,7 +132,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this
.
pendingEditorInputsToClose
=
[];
this
.
pendingEditorInputsToClose
=
[];
this
.
pendingEditorInputCloseTimeout
=
null
;
this
.
pendingEditorInputCloseTimeout
=
null
;
this
.
stacks
=
this
.
instantiationService
.
createInstance
(
EditorStacksModel
,
restoreFromStorage
);
this
.
stacks
=
Object
.
create
(
null
);
this
.
textCompareEditorVisible
=
TextCompareEditorVisibleContext
.
bindTo
(
contextKeyService
);
this
.
textCompareEditorVisible
=
TextCompareEditorVisibleContext
.
bindTo
(
contextKeyService
);
...
@@ -1403,7 +1403,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
...
@@ -1403,7 +1403,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return
this
.
visibleEditors
?
this
.
visibleEditors
.
filter
(
editor
=>
!!
editor
)
:
[];
return
this
.
visibleEditors
?
this
.
visibleEditors
.
filter
(
editor
=>
!!
editor
)
:
[];
}
}
public
getStacksModel
()
:
EditorStacksModel
{
public
getStacksModel
()
{
return
this
.
stacks
;
return
this
.
stacks
;
}
}
...
...
src/vs/workbench/common/editor/editorGroup.ts
浏览文件 @
46a1c8bb
此差异已折叠。
点击以展开。
src/vs/workbench/parts/files/test/browser/fileEditorInput.test.ts
浏览文件 @
46a1c8bb
...
@@ -9,7 +9,7 @@ import URI from 'vs/base/common/uri';
...
@@ -9,7 +9,7 @@ import URI from 'vs/base/common/uri';
import
{
join
}
from
'
vs/base/common/paths
'
;
import
{
join
}
from
'
vs/base/common/paths
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/common/editors/fileEditorInput
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/common/editors/fileEditorInput
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
workbenchInstantiationService
,
TestTextFileService
,
TestEditorGroupService
,
createFileInput
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
workbenchInstantiationService
,
TestTextFileService
,
TestEditorGroupService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
EncodingMode
}
from
'
vs/workbench/common/editor
'
;
import
{
EncodingMode
}
from
'
vs/workbench/common/editor
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
...
@@ -185,27 +185,4 @@ suite('Files - FileEditorInput', () => {
...
@@ -185,27 +185,4 @@ suite('Files - FileEditorInput', () => {
resolved
.
dispose
();
resolved
.
dispose
();
});
});
});
});
test
(
'
disposes model when not open anymore
'
,
function
()
{
const
resource
=
toResource
(
this
,
'
/path/index.txt
'
);
const
input
=
createFileInput
(
instantiationService
,
resource
);
return
input
.
resolve
().
then
((
model
:
TextFileEditorModel
)
=>
{
const
stacks
=
accessor
.
editorGroupService
.
getStacksModel
();
const
group
=
stacks
.
openGroup
(
'
group
'
,
true
);
group
.
openEditor
(
input
);
accessor
.
editorGroupService
.
fireChange
();
assert
.
ok
(
!
model
.
isDisposed
());
group
.
closeEditor
(
input
);
accessor
.
editorGroupService
.
fireChange
();
assert
.
ok
(
model
.
isDisposed
());
model
.
dispose
();
assert
.
ok
(
!
accessor
.
modelService
.
getModel
(
model
.
getResource
()));
});
});
});
});
\ No newline at end of file
src/vs/workbench/parts/files/test/browser/fileEditorTracker.test.ts
浏览文件 @
46a1c8bb
...
@@ -9,23 +9,22 @@ import * as assert from 'assert';
...
@@ -9,23 +9,22 @@ import * as assert from 'assert';
import
{
FileEditorTracker
}
from
'
vs/workbench/parts/files/browser/editors/fileEditorTracker
'
;
import
{
FileEditorTracker
}
from
'
vs/workbench/parts/files/browser/editors/fileEditorTracker
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
join
}
from
'
vs/base/common/paths
'
;
import
{
join
}
from
'
vs/base/common/paths
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/common/editors/fileEditorInput
'
;
//
import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput';
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
workbenchInstantiationService
,
TestTextFileService
,
TestFileService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
workbenchInstantiationService
,
TestTextFileService
,
TestFileService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
EditorStacksModel
}
from
'
vs/workbench/common/editor/editorGroup
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
FileOperation
,
FileOperationEvent
,
FileChangesEvent
,
FileChangeType
,
IFileService
,
snapshotToString
}
from
'
vs/platform/files/common/files
'
;
import
{
/*FileOperation, FileOperationEvent,*/
FileChangesEvent
,
FileChangeType
,
IFileService
,
snapshotToString
}
from
'
vs/platform/files/common/files
'
;
import
{
TextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textFileEditorModel
'
;
import
{
TextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textFileEditorModel
'
;
import
{
once
}
from
'
vs/base/common/event
'
;
//
import { once } from 'vs/base/common/event';
class
TestFileEditorTracker
extends
FileEditorTracker
{
//
class TestFileEditorTracker extends FileEditorTracker {
setCloseOnFileDelete
(
value
:
boolean
):
void
{
//
setCloseOnFileDelete(value: boolean): void {
this
.
closeOnFileDelete
=
value
;
//
this.closeOnFileDelete = value;
}
//
}
}
//
}
function
toResource
(
self
:
any
,
path
:
string
)
{
function
toResource
(
self
:
any
,
path
:
string
)
{
return
URI
.
file
(
join
(
'
C:
\\
'
,
Buffer
.
from
(
self
.
test
.
fullTitle
()).
toString
(
'
base64
'
),
path
));
return
URI
.
file
(
join
(
'
C:
\\
'
,
Buffer
.
from
(
self
.
test
.
fullTitle
()).
toString
(
'
base64
'
),
path
));
...
@@ -51,138 +50,140 @@ suite('Files - FileEditorTracker', () => {
...
@@ -51,138 +50,140 @@ suite('Files - FileEditorTracker', () => {
accessor
=
instantiationService
.
createInstance
(
ServiceAccessor
);
accessor
=
instantiationService
.
createInstance
(
ServiceAccessor
);
});
});
test
(
'
disposes input when resource gets deleted - local file changes
'
,
function
()
{
// TODO@grid revisit these tests once the file tracker adopted grid servies
const
stacks
=
accessor
.
editorGroupService
.
getStacksModel
()
as
EditorStacksModel
;
const
group
=
stacks
.
openGroup
(
'
first
'
,
true
);
const
tracker
=
instantiationService
.
createInstance
(
FileEditorTracker
);
// test('disposes input when resource gets deleted - local file changes', function () {
assert
.
ok
(
tracker
);
// const stacks = accessor.editorGroupService.getStacksModel() as NoOpEditorStacksModel;
// const group = stacks.openGroup('first', true);
const
parent
=
toResource
(
this
,
'
/foo/bar
'
);
// const tracker = instantiationService.createInstance(FileEditorTracker);
const
resource
=
toResource
(
this
,
'
/foo/bar/updatefile.js
'
);
// assert.ok(tracker);
let
input
=
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
group
.
openEditor
(
input
);
assert
.
ok
(
!
input
.
isDisposed
());
// const parent = toResource(this, '/foo/bar');
// const resource = toResource(this, '/foo/bar/updatefile.js');
// let input = instantiationService.createInstance(FileEditorInput, resource, void 0);
// group.openEditor(input);
accessor
.
fileService
.
fireAfterOperation
(
new
FileOperationEvent
(
resource
,
FileOperation
.
DELETE
));
// assert.ok(!input.isDisposed());
assert
.
ok
(
input
.
isDisposed
());
group
.
closeEditor
(
input
);
input
=
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
// accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.DELETE));
group
.
openEditor
(
input
);
// assert.ok(input.isDisposed());
// group.closeEditor(input);
const
other
=
toResource
(
this
,
'
/foo/barfoo
'
);
// input = instantiationService.createInstance(FileEditorInput, resource, void 0);
// group.openEditor(input);
accessor
.
fileService
.
fireAfterOperation
(
new
FileOperationEvent
(
other
,
FileOperation
.
DELETE
));
// const other = toResource(this, '/foo/barfoo');
assert
.
ok
(
!
input
.
isDisposed
());
accessor
.
fileService
.
fireAfterOperation
(
new
FileOperationEvent
(
parent
,
FileOperation
.
DELETE
));
// accessor.fileService.fireAfterOperation(new FileOperationEvent(other
, FileOperation.DELETE));
assert
.
ok
(
input
.
isDisposed
());
// assert.ok(!
input.isDisposed());
// Move
// accessor.fileService.fireAfterOperation(new FileOperationEvent(parent, FileOperation.DELETE));
const
to
:
any
=
toResource
(
this
,
'
/foo/barfoo/change.js
'
);
// assert.ok(input.isDisposed());
accessor
.
fileService
.
fireAfterOperation
(
new
FileOperationEvent
(
resource
,
FileOperation
.
MOVE
,
to
));
assert
.
ok
(
input
.
isDisposed
());
tracker
.
dispose
();
// // Move
});
// const to: any = toResource(this, '/foo/barfoo/change.js');
// accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.MOVE, to));
// assert.ok(input.isDisposed());
test
(
'
disposes input when resource gets deleted - local file changes - even when closeOnFileDelete = false
'
,
function
()
{
// tracker.dispose();
const
stacks
=
accessor
.
editorGroupService
.
getStacksModel
()
as
EditorStacksModel
;
// });
const
group
=
stacks
.
openGroup
(
'
first
'
,
true
);
const
tracker
=
instantiationService
.
createInstance
(
TestFileEditorTracker
);
// test('disposes input when resource gets deleted - local file changes - even when closeOnFileDelete = false', function () {
tracker
.
setCloseOnFileDelete
(
false
)
;
// const stacks = accessor.editorGroupService.getStacksModel() as EditorStacksModel
;
assert
.
ok
(
tracker
);
// const group = stacks.openGroup('first', true
);
const
parent
=
toResource
(
this
,
'
/foo/bar
'
);
// const tracker = instantiationService.createInstance(TestFileEditorTracker);
const
resource
=
toResource
(
this
,
'
/foo/bar/updatefile.js
'
);
// tracker.setCloseOnFileDelete(false);
let
input
=
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
// assert.ok(tracker);
group
.
openEditor
(
input
);
assert
.
ok
(
!
input
.
isDisposed
());
// const parent = toResource(this, '/foo/bar');
// const resource = toResource(this, '/foo/bar/updatefile.js');
// let input = instantiationService.createInstance(FileEditorInput, resource, void 0);
// group.openEditor(input);
accessor
.
fileService
.
fireAfterOperation
(
new
FileOperationEvent
(
resource
,
FileOperation
.
DELETE
));
// assert.ok(!input.isDisposed());
assert
.
ok
(
input
.
isDisposed
());
group
.
closeEditor
(
input
);
input
=
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
// accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.DELETE));
group
.
openEditor
(
input
);
// assert.ok(input.isDisposed());
// group.closeEditor(input);
const
other
=
toResource
(
this
,
'
/foo/barfoo
'
);
// input = instantiationService.createInstance(FileEditorInput, resource, void 0);
// group.openEditor(input);
accessor
.
fileService
.
fireAfterOperation
(
new
FileOperationEvent
(
other
,
FileOperation
.
DELETE
));
// const other = toResource(this, '/foo/barfoo');
assert
.
ok
(
!
input
.
isDisposed
());
accessor
.
fileService
.
fireAfterOperation
(
new
FileOperationEvent
(
parent
,
FileOperation
.
DELETE
));
// accessor.fileService.fireAfterOperation(new FileOperationEvent(other
, FileOperation.DELETE));
assert
.
ok
(
input
.
isDisposed
());
// assert.ok(!
input.isDisposed());
// Move
// accessor.fileService.fireAfterOperation(new FileOperationEvent(parent, FileOperation.DELETE));
const
to
:
any
=
toResource
(
this
,
'
/foo/barfoo/change.js
'
);
// assert.ok(input.isDisposed());
accessor
.
fileService
.
fireAfterOperation
(
new
FileOperationEvent
(
resource
,
FileOperation
.
MOVE
,
to
));
assert
.
ok
(
input
.
isDisposed
());
tracker
.
dispose
();
// // Move
});
// const to: any = toResource(this, '/foo/barfoo/change.js');
// accessor.fileService.fireAfterOperation(new FileOperationEvent(resource, FileOperation.MOVE, to));
// assert.ok(input.isDisposed());
test
(
'
disposes when resource gets deleted - remote file changes
'
,
function
(
done
)
{
// tracker.dispose();
const
stacks
=
accessor
.
editorGroupService
.
getStacksModel
()
as
EditorStacksModel
;
// });
const
group
=
stacks
.
openGroup
(
'
first
'
,
true
);
const
tracker
=
instantiationService
.
createInstance
(
FileEditorTracker
);
// test('disposes when resource gets deleted - remote file changes', function (done) {
assert
.
ok
(
tracker
);
// const stacks = accessor.editorGroupService.getStacksModel() as EditorStacksModel;
// const group = stacks.openGroup('first', true);
const
parent
=
toResource
(
this
,
'
/foo/bar
'
);
// const tracker = instantiationService.createInstance(FileEditorTracker);
const
resource
=
toResource
(
this
,
'
/foo/bar/updatefile.js
'
);
// assert.ok(tracker);
let
input
=
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
group
.
openEditor
(
input
);
assert
.
ok
(
!
input
.
isDisposed
());
// const parent = toResource(this, '/foo/bar');
// const resource = toResource(this, '/foo/bar/updatefile.js');
// let input = instantiationService.createInstance(FileEditorInput, resource, void 0);
// group.openEditor(input);
accessor
.
fileService
.
fireFileChanges
(
new
FileChangesEvent
([{
resource
,
type
:
FileChangeType
.
DELETED
}]
));
// assert.ok(!input.isDisposed(
));
once
(
input
.
onDispose
)(()
=>
{
// accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource, type: FileChangeType.DELETED }]));
assert
.
ok
(
input
.
isDisposed
());
group
.
closeEditor
(
input
);
input
=
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
// once(input.onDispose)(() => {
group
.
openEditor
(
input
);
// assert.ok(input.isDisposed());
// group.closeEditor(input);
const
other
=
toResource
(
this
,
'
/foo/barfoo
'
);
// input = instantiationService.createInstance(FileEditorInput, resource, void 0);
// group.openEditor(input);
accessor
.
fileService
.
fireFileChanges
(
new
FileChangesEvent
([{
resource
:
other
,
type
:
FileChangeType
.
DELETED
}]));
// const other = toResource(this, '/foo/barfoo');
assert
.
ok
(
!
input
.
isDisposed
());
accessor
.
fileService
.
fireFileChanges
(
new
FileChangesEvent
([{
resource
:
parent
,
type
:
FileChangeType
.
DELETED
}]));
// accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource: other, type: FileChangeType.DELETED }]));
// assert.ok(!input.isDisposed());
once
(
input
.
onDispose
)(()
=>
{
// accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource: parent, type: FileChangeType.DELETED }]));
assert
.
ok
(
input
.
isDisposed
());
tracker
.
dispose
();
// once(input.onDispose)(() => {
done
();
// assert.ok(input.isDisposed());
});
});
});
test
(
'
keeps open when resource gets deleted - remote file changes - closeOnFileDelete = false
'
,
function
()
{
// tracker.dispose();
const
stacks
=
accessor
.
editorGroupService
.
getStacksModel
()
as
EditorStacksModel
;
// done();
const
group
=
stacks
.
openGroup
(
'
first
'
,
true
);
// });
// });
// });
const
tracker
=
instantiationService
.
createInstance
(
TestFileEditorTracker
);
// test('keeps open when resource gets deleted - remote file changes - closeOnFileDelete = false', function () {
tracker
.
setCloseOnFileDelete
(
false
)
;
// const stacks = accessor.editorGroupService.getStacksModel() as EditorStacksModel
;
assert
.
ok
(
tracker
);
// const group = stacks.openGroup('first', true
);
const
resource
=
toResource
(
this
,
'
/foo/bar/updatefile.js
'
);
// const tracker = instantiationService.createInstance(TestFileEditorTracker
);
let
input
=
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
// tracker.setCloseOnFileDelete(false
);
group
.
openEditor
(
input
);
// assert.ok(tracker
);
accessor
.
fileService
.
fireFileChanges
(
new
FileChangesEvent
([{
resource
,
type
:
FileChangeType
.
DELETED
}]));
// const resource = toResource(this, '/foo/bar/updatefile.js');
// let input = instantiationService.createInstance(FileEditorInput, resource, void 0);
// group.openEditor(input);
assert
.
ok
(
!
input
.
isDisposed
(
));
// accessor.fileService.fireFileChanges(new FileChangesEvent([{ resource, type: FileChangeType.DELETED }]
));
tracker
.
dispose
();
// assert.ok(!input.isDisposed());
});
// tracker.dispose();
// });
test
(
'
file change event updates model
'
,
function
()
{
test
(
'
file change event updates model
'
,
function
()
{
const
tracker
=
instantiationService
.
createInstance
(
FileEditorTracker
);
const
tracker
=
instantiationService
.
createInstance
(
FileEditorTracker
);
...
...
src/vs/workbench/services/editor/common/editorService.ts
浏览文件 @
46a1c8bb
...
@@ -230,7 +230,7 @@ export class NoOpEditorPart implements IEditorPart, IEditorGroupService {
...
@@ -230,7 +230,7 @@ export class NoOpEditorPart implements IEditorPart, IEditorGroupService {
}
}
}
}
class
NoOpEditorStacksModel
implements
IEditorStacksModel
{
export
class
NoOpEditorStacksModel
implements
IEditorStacksModel
{
onModelChanged
:
Event
<
IStacksModelChangeEvent
>
=
new
Emitter
<
IStacksModelChangeEvent
>
().
event
;
onModelChanged
:
Event
<
IStacksModelChangeEvent
>
=
new
Emitter
<
IStacksModelChangeEvent
>
().
event
;
onWillCloseEditor
:
Event
<
IEditorCloseEvent
>
=
new
Emitter
<
IEditorCloseEvent
>
().
event
;
onWillCloseEditor
:
Event
<
IEditorCloseEvent
>
=
new
Emitter
<
IEditorCloseEvent
>
().
event
;
...
...
src/vs/workbench/services/editor/test/browser/nextEditorService.test.ts
浏览文件 @
46a1c8bb
...
@@ -37,7 +37,7 @@ export class TestEditorControl extends BaseEditor {
...
@@ -37,7 +37,7 @@ export class TestEditorControl extends BaseEditor {
}
}
export
class
TestEditorInput
extends
EditorInput
implements
IFileEditorInput
{
export
class
TestEditorInput
extends
EditorInput
implements
IFileEditorInput
{
public
gotDisposed
:
boolean
;
constructor
(
private
resource
:
URI
)
{
super
();
}
constructor
(
private
resource
:
URI
)
{
super
();
}
getTypeId
()
{
return
'
testEditorInputForNextEditorService
'
;
}
getTypeId
()
{
return
'
testEditorInputForNextEditorService
'
;
}
...
@@ -48,6 +48,10 @@ export class TestEditorInput extends EditorInput implements IFileEditorInput {
...
@@ -48,6 +48,10 @@ export class TestEditorInput extends EditorInput implements IFileEditorInput {
setPreferredEncoding
(
encoding
:
string
)
{
}
setPreferredEncoding
(
encoding
:
string
)
{
}
getResource
():
URI
{
return
this
.
resource
;
}
getResource
():
URI
{
return
this
.
resource
;
}
setForceOpenAsBinary
():
void
{
}
setForceOpenAsBinary
():
void
{
}
dispose
():
void
{
super
.
dispose
();
this
.
gotDisposed
=
true
;
}
}
}
suite
(
'
NextEditorService editor2
'
,
()
=>
{
suite
(
'
NextEditorService editor2
'
,
()
=>
{
...
@@ -97,7 +101,7 @@ suite('NextEditorService editor2', () => {
...
@@ -97,7 +101,7 @@ suite('NextEditorService editor2', () => {
willCloseEditorListenerCounter
++
;
willCloseEditorListenerCounter
++
;
});
});
// Open
EditorI
nput
// Open
i
nput
return
service
.
openEditor
(
input
,
{
pinned
:
true
}).
then
(
editor
=>
{
return
service
.
openEditor
(
input
,
{
pinned
:
true
}).
then
(
editor
=>
{
assert
.
ok
(
editor
instanceof
TestEditorControl
);
assert
.
ok
(
editor
instanceof
TestEditorControl
);
assert
.
equal
(
editor
,
service
.
activeControl
);
assert
.
equal
(
editor
,
service
.
activeControl
);
...
@@ -111,12 +115,15 @@ suite('NextEditorService editor2', () => {
...
@@ -111,12 +115,15 @@ suite('NextEditorService editor2', () => {
assert
.
equal
(
visibleEditorChangeEventCounter
,
1
);
assert
.
equal
(
visibleEditorChangeEventCounter
,
1
);
assert
.
equal
(
willOpenEditorEventCounter
,
1
);
assert
.
equal
(
willOpenEditorEventCounter
,
1
);
// Close input
service
.
closeEditor
(
input
,
editor
.
group
);
service
.
closeEditor
(
input
,
editor
.
group
);
assert
.
equal
(
willCloseEditorListenerCounter
,
1
);
assert
.
equal
(
willCloseEditorListenerCounter
,
1
);
assert
.
equal
(
didCloseEditorListenerCounter
,
1
);
assert
.
equal
(
didCloseEditorListenerCounter
,
1
);
assert
.
equal
(
activeEditorChangeEventCounter
,
2
);
assert
.
equal
(
activeEditorChangeEventCounter
,
2
);
assert
.
equal
(
visibleEditorChangeEventCounter
,
2
);
assert
.
equal
(
visibleEditorChangeEventCounter
,
2
);
assert
.
ok
(
input
.
gotDisposed
);
// Open again 2 inputs
return
service
.
openEditor
(
input
,
{
pinned
:
true
}).
then
(
editor
=>
{
return
service
.
openEditor
(
input
,
{
pinned
:
true
}).
then
(
editor
=>
{
return
service
.
openEditor
(
otherInput
,
{
pinned
:
true
}).
then
(
editor
=>
{
return
service
.
openEditor
(
otherInput
,
{
pinned
:
true
}).
then
(
editor
=>
{
assert
.
equal
(
service
.
visibleControls
.
length
,
1
);
assert
.
equal
(
service
.
visibleControls
.
length
,
1
);
...
...
src/vs/workbench/test/browser/parts/editor/editorGroups.test.ts
浏览文件 @
46a1c8bb
...
@@ -22,6 +22,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
...
@@ -22,6 +22,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
function
inst
():
IInstantiationService
{
function
inst
():
IInstantiationService
{
let
inst
=
new
TestInstantiationService
();
let
inst
=
new
TestInstantiationService
();
...
@@ -136,7 +137,7 @@ class NonSerializableTestEditorInput extends EditorInput {
...
@@ -136,7 +137,7 @@ class NonSerializableTestEditorInput extends EditorInput {
getTypeId
()
{
return
'
testEditorInputForGroups-nonSerializable
'
;
}
getTypeId
()
{
return
'
testEditorInputForGroups-nonSerializable
'
;
}
resolve
():
TPromise
<
IEditorModel
>
{
return
null
;
}
resolve
():
TPromise
<
IEditorModel
>
{
return
null
;
}
matches
(
other
:
TestEditorInput
):
boolean
{
matches
(
other
:
NonSerializable
TestEditorInput
):
boolean
{
return
other
&&
this
.
id
===
other
.
id
&&
other
instanceof
NonSerializableTestEditorInput
;
return
other
&&
this
.
id
===
other
.
id
&&
other
instanceof
NonSerializableTestEditorInput
;
}
}
}
}
...
@@ -149,7 +150,7 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput {
...
@@ -149,7 +150,7 @@ class TestFileEditorInput extends EditorInput implements IFileEditorInput {
getTypeId
()
{
return
'
testFileEditorInputForGroups
'
;
}
getTypeId
()
{
return
'
testFileEditorInputForGroups
'
;
}
resolve
():
TPromise
<
IEditorModel
>
{
return
null
;
}
resolve
():
TPromise
<
IEditorModel
>
{
return
null
;
}
matches
(
other
:
TestEditorInput
):
boolean
{
matches
(
other
:
Test
File
EditorInput
):
boolean
{
return
other
&&
this
.
id
===
other
.
id
&&
other
instanceof
TestFileEditorInput
;
return
other
&&
this
.
id
===
other
.
id
&&
other
instanceof
TestFileEditorInput
;
}
}
...
@@ -206,7 +207,7 @@ class TestEditorInputFactory implements IEditorInputFactory {
...
@@ -206,7 +207,7 @@ class TestEditorInputFactory implements IEditorInputFactory {
suite
(
'
Editor Groups editor2
'
,
()
=>
{
suite
(
'
Editor Groups editor2
'
,
()
=>
{
function
registerEditorInputFactory
()
{
function
registerEditorInputFactory
()
{
Registry
.
as
<
IEditorInputFactoryRegistry
>
(
EditorExtensions
.
EditorInputFactories
).
registerEditorInputFactory
(
'
testEditorInputFor
Editor
Groups
'
,
TestEditorInputFactory
);
Registry
.
as
<
IEditorInputFactoryRegistry
>
(
EditorExtensions
.
EditorInputFactories
).
registerEditorInputFactory
(
'
testEditorInputForGroups
'
,
TestEditorInputFactory
);
}
}
registerEditorInputFactory
();
registerEditorInputFactory
();
...
@@ -236,44 +237,42 @@ suite('Editor Groups editor2', () => {
...
@@ -236,44 +237,42 @@ suite('Editor Groups editor2', () => {
assert
.
equal
(
clone
.
isActive
(
input3
),
true
);
assert
.
equal
(
clone
.
isActive
(
input3
),
true
);
});
});
// test('Stack - contains() with diff editor support', function () {
test
(
'
Stack - contains() with diff editor support
'
,
function
()
{
// const model = create();
const
group
=
createGroup
();
// const group1 = model.openGroup('group1');
//
const input1 = input();
const
input1
=
input
();
//
const input2 = input();
const
input2
=
input
();
//
const diffInput = new DiffEditorInput('name', 'description', input1, input2);
const
diffInput
=
new
DiffEditorInput
(
'
name
'
,
'
description
'
,
input1
,
input2
);
// group1
.openEditor(input2, { pinned: true, active: true });
group
.
openEditor
(
input2
,
{
pinned
:
true
,
active
:
true
});
// assert.equal(group1
.contains(input2), true);
assert
.
equal
(
group
.
contains
(
input2
),
true
);
// assert.equal(group1
.contains(diffInput), false);
assert
.
equal
(
group
.
contains
(
diffInput
),
false
);
// assert.equal(group1
.contains(diffInput, true), true);
assert
.
equal
(
group
.
contains
(
diffInput
,
true
),
true
);
//
});
});
//
test('Stack - group serialization', function () {
test
(
'
Stack - group serialization
'
,
function
()
{
// const model = create(
);
Registry
.
as
<
IEditorInputFactoryRegistry
>
(
EditorExtensions
.
EditorInputFactories
).
setInstantiationService
(
inst
()
);
// const group = model.openGroup('group'
);
const
group
=
createGroup
(
);
//
const input1 = input();
const
input1
=
input
();
//
const input2 = input();
const
input2
=
input
();
//
const input3 = input();
const
input3
=
input
();
//
// Pinned and Active
// Pinned and Active
//
group.openEditor(input1, { pinned: true, active: true });
group
.
openEditor
(
input1
,
{
pinned
:
true
,
active
:
true
});
//
group.openEditor(input2, { pinned: true, active: true });
group
.
openEditor
(
input2
,
{
pinned
:
true
,
active
:
true
});
//
group.openEditor(input3, { pinned: false, active: true });
group
.
openEditor
(
input3
,
{
pinned
:
false
,
active
:
true
});
//
const deserialized = createGroup(group.serialize());
const
deserialized
=
createGroup
(
group
.
serialize
());
//
assert.equal(group.id, deserialized.id);
assert
.
equal
(
group
.
id
,
deserialized
.
id
);
//
assert.equal(deserialized.count, 3);
assert
.
equal
(
deserialized
.
count
,
3
);
//
assert.equal(deserialized.isPinned(input1), true);
assert
.
equal
(
deserialized
.
isPinned
(
input1
),
true
);
//
assert.equal(deserialized.isPinned(input2), true);
assert
.
equal
(
deserialized
.
isPinned
(
input2
),
true
);
//
assert.equal(deserialized.isPinned(input3), false);
assert
.
equal
(
deserialized
.
isPinned
(
input3
),
false
);
//
assert.equal(deserialized.isActive(input3), true);
assert
.
equal
(
deserialized
.
isActive
(
input3
),
true
);
//
});
});
// test('Groups - Basic', function () {
// test('Groups - Basic', function () {
// const model = create();
// const model = create();
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
46a1c8bb
...
@@ -27,9 +27,7 @@ import { IEditorInput, IEditorOptions, Position, IEditor, IResourceInput, IUntit
...
@@ -27,9 +27,7 @@ import { IEditorInput, IEditorOptions, Position, IEditor, IResourceInput, IUntit
import
{
IUntitledEditorService
,
UntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IUntitledEditorService
,
UntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IWorkspaceContextService
,
IWorkspace
as
IWorkbenchWorkspace
,
WorkbenchState
,
IWorkspaceFolder
,
IWorkspaceFoldersChangeEvent
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
,
IWorkspace
as
IWorkbenchWorkspace
,
WorkbenchState
,
IWorkspaceFolder
,
IWorkspaceFoldersChangeEvent
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ILifecycleService
,
ShutdownEvent
,
ShutdownReason
,
StartupKind
,
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
ILifecycleService
,
ShutdownEvent
,
ShutdownReason
,
StartupKind
,
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
EditorStacksModel
}
from
'
vs/workbench/common/editor/editorGroup
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
IEditorGroupService
,
GroupArrangement
,
GroupOrientation
,
IEditorTabOptions
,
IMoveOptions
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IEditorGroupService
,
GroupArrangement
,
GroupOrientation
,
IEditorTabOptions
,
IMoveOptions
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
TextFileService
}
from
'
vs/workbench/services/textfile/common/textFileService
'
;
import
{
TextFileService
}
from
'
vs/workbench/services/textfile/common/textFileService
'
;
import
{
FileOperationEvent
,
IFileService
,
IResolveContentOptions
,
FileOperationError
,
IFileStat
,
IResolveFileResult
,
FileChangesEvent
,
IResolveFileOptions
,
IContent
,
IUpdateContentOptions
,
IStreamContent
,
ICreateFileOptions
,
ITextSnapshot
,
IResourceEncodings
}
from
'
vs/platform/files/common/files
'
;
import
{
FileOperationEvent
,
IFileService
,
IResolveContentOptions
,
FileOperationError
,
IFileStat
,
IResolveFileResult
,
FileChangesEvent
,
IResolveFileOptions
,
IContent
,
IUpdateContentOptions
,
IStreamContent
,
ICreateFileOptions
,
ITextSnapshot
,
IResourceEncodings
}
from
'
vs/platform/files/common/files
'
;
...
@@ -40,7 +38,7 @@ import { IRawTextContent, ITextFileService } from 'vs/workbench/services/textfil
...
@@ -40,7 +38,7 @@ import { IRawTextContent, ITextFileService } from 'vs/workbench/services/textfil
import
{
parseArgs
}
from
'
vs/platform/environment/node/argv
'
;
import
{
parseArgs
}
from
'
vs/platform/environment/node/argv
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
{
EnvironmentService
}
from
'
vs/platform/environment/node/environmentService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IWorkbenchEditorService
,
ICloseEditorsFilter
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkbenchEditorService
,
ICloseEditorsFilter
,
NoOpEditorStacksModel
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
IInstantiationService
,
ServicesAccessor
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
,
ServicesAccessor
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
...
@@ -497,7 +495,7 @@ export class TestStorageService implements IStorageService {
...
@@ -497,7 +495,7 @@ export class TestStorageService implements IStorageService {
export
class
TestEditorGroupService
implements
IEditorGroupService
{
export
class
TestEditorGroupService
implements
IEditorGroupService
{
public
_serviceBrand
:
any
;
public
_serviceBrand
:
any
;
private
stacksModel
:
EditorStacksModel
;
private
stacksModel
;
private
readonly
_onEditorsChanged
:
Emitter
<
void
>
;
private
readonly
_onEditorsChanged
:
Emitter
<
void
>
;
private
readonly
_onEditorOpening
:
Emitter
<
IEditorOpeningEvent
>
;
private
readonly
_onEditorOpening
:
Emitter
<
IEditorOpeningEvent
>
;
...
@@ -523,9 +521,7 @@ export class TestEditorGroupService implements IEditorGroupService {
...
@@ -523,9 +521,7 @@ export class TestEditorGroupService implements IEditorGroupService {
services
.
set
(
ILifecycleService
,
lifecycle
);
services
.
set
(
ILifecycleService
,
lifecycle
);
services
.
set
(
ITelemetryService
,
NullTelemetryService
);
services
.
set
(
ITelemetryService
,
NullTelemetryService
);
let
inst
=
new
InstantiationService
(
services
);
this
.
stacksModel
=
new
NoOpEditorStacksModel
();
this
.
stacksModel
=
inst
.
createInstance
(
EditorStacksModel
,
true
);
}
}
public
fireChange
():
void
{
public
fireChange
():
void
{
...
@@ -600,7 +596,7 @@ export class TestEditorGroupService implements IEditorGroupService {
...
@@ -600,7 +596,7 @@ export class TestEditorGroupService implements IEditorGroupService {
public
moveEditor
(
input
:
IEditorInput
,
from
:
any
,
to
:
any
,
moveOptions
?:
IMoveOptions
):
void
{
public
moveEditor
(
input
:
IEditorInput
,
from
:
any
,
to
:
any
,
moveOptions
?:
IMoveOptions
):
void
{
}
}
public
getStacksModel
()
:
EditorStacksModel
{
public
getStacksModel
()
{
return
this
.
stacksModel
;
return
this
.
stacksModel
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录