Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
466d6549
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,发现更多精彩内容 >>
提交
466d6549
编写于
5月 04, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
introduce mru
上级
142cc943
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
34 deletion
+61
-34
src/vs/workbench/common/editor/editorStacksModel.ts
src/vs/workbench/common/editor/editorStacksModel.ts
+61
-34
未找到文件。
src/vs/workbench/common/editor/editorStacksModel.ts
浏览文件 @
466d6549
...
...
@@ -12,7 +12,6 @@ import {EditorInput} from 'vs/workbench/common/editor';
export
interface
IEditorGroup
{
editors
:
EditorInput
[];
activeEditor
:
EditorInput
;
previewEditor
:
EditorInput
;
...
...
@@ -22,6 +21,7 @@ export interface IEditorGroup {
onEditorPinned
:
Event
<
EditorInput
>
;
onEditorUnpinned
:
Event
<
EditorInput
>
;
getEditors
(
mru
?:
boolean
):
EditorInput
[];
openEditor
(
editor
:
EditorInput
,
options
?:
IEditorOpenOptions
):
void
;
setActive
(
editor
:
EditorInput
):
void
;
isActive
(
editor
:
EditorInput
):
boolean
;
...
...
@@ -77,18 +77,6 @@ export interface IEditorOpenOptions {
// TODO what about editor input state (dirty decoration)?
class
List
<
T
>
{
private
elements
:
T
[];
constructor
()
{
this
.
elements
=
[];
}
public
insert
(
entry
:
T
,
index
?:
number
,
dir
?:
Direction
):
void
{
}
}
export
enum
Direction
{
LEFT
,
RIGHT
...
...
@@ -97,9 +85,8 @@ export enum Direction {
const
DEFAULT_OPEN_EDITOR_DIRECTION
=
Direction
.
RIGHT
;
// open new editors to the right of existing ones
export
class
EditorGroup
implements
IEditorGroup
{
private
_editors
:
EditorInput
[];
private
mru
:
number
[];
// indeces of editors in MRU order
private
editors
:
EditorInput
[];
private
mru
:
EditorInput
[];
private
preview
:
EditorInput
;
// editor in preview state
private
active
:
EditorInput
;
// editor in active state
...
...
@@ -111,7 +98,7 @@ export class EditorGroup implements IEditorGroup {
private
_onEditorUnpinned
:
Emitter
<
EditorInput
>
;
constructor
(
private
label
:
string
)
{
this
.
_
editors
=
[];
this
.
editors
=
[];
this
.
mru
=
[];
this
.
_onEditorActivated
=
new
Emitter
<
EditorInput
>
();
...
...
@@ -141,8 +128,8 @@ export class EditorGroup implements IEditorGroup {
return
this
.
_onEditorUnpinned
.
event
;
}
public
get
editors
(
):
EditorInput
[]
{
return
this
.
_
editors
.
slice
(
0
);
public
get
Editors
(
mru
?:
boolean
):
EditorInput
[]
{
return
mru
?
this
.
mru
.
slice
(
0
)
:
this
.
editors
.
slice
(
0
);
}
public
get
activeEditor
():
EditorInput
{
...
...
@@ -165,7 +152,7 @@ export class EditorGroup implements IEditorGroup {
const
index
=
this
.
indexOf
(
editor
);
const
indexOfActive
=
this
.
indexOf
(
this
.
active
);
const
indexOfPreview
=
this
.
indexOf
(
this
.
preview
);
let
oldPreviewToClose
:
EditorInput
;
let
oldPreviewToClose
:
EditorInput
;
const
makeActive
=
options
&&
options
.
active
;
const
makePinned
=
options
&&
options
.
pinned
;
...
...
@@ -175,16 +162,16 @@ export class EditorGroup implements IEditorGroup {
// Insert into our list of editors if pinned or we are first
if
(
makePinned
||
indexOfPreview
===
-
1
)
{
if
(
!
this
.
_
editors
.
length
)
{
this
.
_editors
.
push
(
editor
);
// first editor in list
if
(
!
this
.
editors
.
length
)
{
this
.
splice
(
0
,
false
,
editor
);
// first editor in list
}
else
if
(
DEFAULT_OPEN_EDITOR_DIRECTION
===
Direction
.
LEFT
)
{
if
(
indexOfActive
===
0
)
{
this
.
_editors
.
unshift
(
editor
);
// to the left becoming first editor in list
this
.
splice
(
0
,
false
,
editor
);
// to the left becoming first editor in list
}
else
{
this
.
_editors
.
splice
(
indexOfActive
-
1
,
0
,
editor
);
// to the left of active editor
this
.
splice
(
indexOfActive
-
1
,
false
,
editor
);
// to the left of active editor
}
}
else
{
this
.
_editors
.
splice
(
indexOfActive
,
0
,
editor
);
// to the right of active editor
this
.
splice
(
indexOfActive
,
false
,
editor
);
// to the right of active editor
}
}
...
...
@@ -192,7 +179,7 @@ export class EditorGroup implements IEditorGroup {
else
{
oldPreviewToClose
=
this
.
preview
;
this
.
preview
=
editor
;
this
.
_editors
[
indexOfPreview
]
=
editor
;
this
.
splice
(
indexOfPreview
,
true
,
editor
)
;
}
// Event
...
...
@@ -232,12 +219,12 @@ export class EditorGroup implements IEditorGroup {
if
(
editor
.
matches
(
this
.
active
))
{
// More than one editor
if
(
this
.
_
editors
.
length
>
1
)
{
if
(
this
.
editors
.
length
>
1
)
{
let
newActiveEditor
:
EditorInput
;
if
(
this
.
_
editors
.
length
>
index
+
1
)
{
newActiveEditor
=
this
.
_
editors
[
index
+
1
];
// make next editor to the right active
if
(
this
.
editors
.
length
>
index
+
1
)
{
newActiveEditor
=
this
.
editors
[
index
+
1
];
// make next editor to the right active
}
else
{
newActiveEditor
=
this
.
_
editors
[
index
-
1
];
// make next editor to the left active
newActiveEditor
=
this
.
editors
[
index
-
1
];
// make next editor to the left active
}
this
.
setActive
(
newActiveEditor
);
...
...
@@ -254,7 +241,7 @@ export class EditorGroup implements IEditorGroup {
this
.
preview
=
null
;
}
this
.
_editors
.
splice
(
index
,
1
);
this
.
splice
(
index
,
true
);
// Event
this
.
_onEditorClosed
.
fire
(
editor
);
...
...
@@ -272,6 +259,8 @@ export class EditorGroup implements IEditorGroup {
this
.
active
=
editor
;
this
.
setMostRecentlyUsed
(
editor
);
// Event
this
.
_onEditorActivated
.
fire
(
editor
);
}
...
...
@@ -317,19 +306,57 @@ export class EditorGroup implements IEditorGroup {
return
!
this
.
preview
.
matches
(
editor
);
}
private
indexOf
(
candidate
:
EditorInput
):
number
{
private
splice
(
index
:
number
,
del
:
boolean
,
editor
?:
EditorInput
):
void
{
// Perform on editors array
this
.
editors
.
splice
(
index
,
del
?
1
:
0
,
editor
);
// Add: make it LRU editor
if
(
!
del
&&
editor
)
{
this
.
mru
.
push
(
editor
);
}
// Remove: remove from MRU
else
if
(
del
&&
!
editor
)
{
this
.
mru
.
splice
(
this
.
indexOf
(
this
.
editors
[
index
]),
1
);
}
// Replace: replace MRU at location
else
{
this
.
mru
.
splice
(
this
.
indexOf
(
this
.
editors
[
index
]),
1
,
editor
);
}
}
private
indexOf
(
candidate
:
EditorInput
,
editors
=
this
.
editors
):
number
{
if
(
!
candidate
)
{
return
-
1
;
}
for
(
let
i
=
0
;
i
<
this
.
_
editors
.
length
;
i
++
)
{
if
(
this
.
_
editors
[
i
].
matches
(
candidate
))
{
for
(
let
i
=
0
;
i
<
editors
.
length
;
i
++
)
{
if
(
editors
[
i
].
matches
(
candidate
))
{
return
i
;
}
}
return
-
1
;
}
private
setMostRecentlyUsed
(
editor
:
EditorInput
):
void
{
const
index
=
this
.
indexOf
(
editor
);
if
(
index
===
-
1
)
{
return
;
// editor not found
}
const
mruIndex
=
this
.
indexOf
(
editor
,
this
.
mru
);
// Remove old index
if
(
mruIndex
>=
0
)
{
this
.
mru
.
splice
(
mruIndex
,
1
);
}
// Set to front
this
.
mru
.
unshift
(
editor
);
}
}
export
class
EditorStacksModel
implements
IEditorStacksModel
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录