Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5139e261
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,发现更多精彩内容 >>
提交
5139e261
编写于
5月 19, 2016
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
open editors: use context for actions
上级
d88a714d
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
52 addition
and
25 deletion
+52
-25
src/vs/workbench/browser/parts/editor/editorActions.ts
src/vs/workbench/browser/parts/editor/editorActions.ts
+35
-14
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
...workbench/browser/parts/editor/sideBySideEditorControl.ts
+8
-3
src/vs/workbench/common/editor/editorStacksModel.ts
src/vs/workbench/common/editor/editorStacksModel.ts
+2
-2
src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts
.../workbench/parts/files/browser/views/openEditorsViewer.ts
+5
-4
src/vs/workbench/test/common/editor/editorStacksModel.test.ts
...vs/workbench/test/common/editor/editorStacksModel.test.ts
+2
-2
未找到文件。
src/vs/workbench/browser/parts/editor/editorActions.ts
浏览文件 @
5139e261
...
@@ -407,8 +407,8 @@ export class CloseEditorAction extends Action {
...
@@ -407,8 +407,8 @@ export class CloseEditorAction extends Action {
super
(
id
,
label
,
'
close-editor-action
'
);
super
(
id
,
label
,
'
close-editor-action
'
);
}
}
public
run
(
position
:
Position
):
TPromise
<
any
>
{
public
run
(
editorIdentifier
:
IEditorIdentifier
):
TPromise
<
any
>
{
let
position
=
editorIdentifier
?
this
.
editorService
.
getStacksModel
().
positionOfGroup
(
editorIdentifier
.
group
)
:
null
;
// Close Active Editor
// Close Active Editor
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
...
@@ -417,10 +417,17 @@ export class CloseEditorAction extends Action {
...
@@ -417,10 +417,17 @@ export class CloseEditorAction extends Action {
}
}
}
}
// Close Editor at Position
let
input
=
editorIdentifier
?
editorIdentifier
.
editor
:
null
;
if
(
!
input
)
{
// Get Top Editor at Position
let
visibleEditors
=
this
.
editorService
.
getVisibleEditors
();
let
visibleEditors
=
this
.
editorService
.
getVisibleEditors
();
if
(
visibleEditors
[
position
])
{
if
(
visibleEditors
[
position
])
{
return
this
.
editorService
.
closeEditor
(
position
,
visibleEditors
[
position
].
input
);
input
=
visibleEditors
[
position
].
input
;
}
}
if
(
input
)
{
return
this
.
editorService
.
closeEditor
(
position
,
input
);
}
}
return
TPromise
.
as
(
false
);
return
TPromise
.
as
(
false
);
...
@@ -436,7 +443,8 @@ export class CloseEditorsInGroupAction extends Action {
...
@@ -436,7 +443,8 @@ export class CloseEditorsInGroupAction extends Action {
super
(
id
,
label
);
super
(
id
,
label
);
}
}
public
run
(
position
:
Position
):
TPromise
<
any
>
{
public
run
(
editorIdentifier
:
IEditorIdentifier
):
TPromise
<
any
>
{
let
position
=
editorIdentifier
?
this
.
editorService
.
getStacksModel
().
positionOfGroup
(
editorIdentifier
.
group
)
:
null
;
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
if
(
activeEditor
)
{
...
@@ -513,7 +521,8 @@ export class CloseEditorsInOtherGroupsAction extends Action {
...
@@ -513,7 +521,8 @@ export class CloseEditorsInOtherGroupsAction extends Action {
super
(
id
,
label
);
super
(
id
,
label
);
}
}
public
run
(
position
:
Position
):
TPromise
<
any
>
{
public
run
(
editorIdentifier
:
IEditorIdentifier
):
TPromise
<
any
>
{
let
position
=
editorIdentifier
?
this
.
editorService
.
getStacksModel
().
positionOfGroup
(
editorIdentifier
.
group
)
:
null
;
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
if
(
activeEditor
)
{
...
@@ -538,10 +547,19 @@ export class CloseOtherEditorsInGroupAction extends Action {
...
@@ -538,10 +547,19 @@ export class CloseOtherEditorsInGroupAction extends Action {
super
(
id
,
label
);
super
(
id
,
label
);
}
}
public
run
():
TPromise
<
any
>
{
public
run
(
editorIdentifier
:
IEditorIdentifier
):
TPromise
<
any
>
{
let
position
=
editorIdentifier
?
this
.
editorService
.
getStacksModel
().
positionOfGroup
(
editorIdentifier
.
group
)
:
null
;
let
input
=
editorIdentifier
?
editorIdentifier
.
editor
:
null
;
// If position or input are not passed in take the position and input of the active editor.
const
active
=
this
.
editorService
.
getActiveEditor
();
const
active
=
this
.
editorService
.
getActiveEditor
();
if
(
active
)
{
if
(
active
)
{
return
this
.
editorService
.
closeEditors
(
active
.
position
,
active
.
input
);
position
=
typeof
position
===
'
number
'
?
position
:
active
.
position
;
input
=
input
?
input
:
active
.
input
;
}
if
(
typeof
position
===
'
number
'
&&
input
)
{
return
this
.
editorService
.
closeEditors
(
position
,
input
);
}
}
return
TPromise
.
as
(
false
);
return
TPromise
.
as
(
false
);
...
@@ -557,7 +575,8 @@ export class CloseAllEditorsInGroupAction extends Action {
...
@@ -557,7 +575,8 @@ export class CloseAllEditorsInGroupAction extends Action {
super
(
id
,
label
,
'
action-close-all-files
'
);
super
(
id
,
label
,
'
action-close-all-files
'
);
}
}
public
run
(
position
:
Position
):
TPromise
<
any
>
{
public
run
(
editorIdentifier
:
IEditorIdentifier
):
TPromise
<
any
>
{
let
position
=
editorIdentifier
?
this
.
editorService
.
getStacksModel
().
positionOfGroup
(
editorIdentifier
.
group
)
:
null
;
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
if
(
activeEditor
)
{
...
@@ -580,7 +599,8 @@ export class MoveGroupLeftAction extends Action {
...
@@ -580,7 +599,8 @@ export class MoveGroupLeftAction extends Action {
super
(
id
,
label
);
super
(
id
,
label
);
}
}
public
run
(
position
:
Position
):
TPromise
<
any
>
{
public
run
(
editorIdentifier
:
IEditorIdentifier
):
TPromise
<
any
>
{
let
position
=
editorIdentifier
?
this
.
editorService
.
getStacksModel
().
positionOfGroup
(
editorIdentifier
.
group
)
:
null
;
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
&&
(
activeEditor
.
position
===
Position
.
CENTER
||
activeEditor
.
position
===
Position
.
RIGHT
))
{
if
(
activeEditor
&&
(
activeEditor
.
position
===
Position
.
CENTER
||
activeEditor
.
position
===
Position
.
RIGHT
))
{
...
@@ -608,7 +628,8 @@ export class MoveGroupRightAction extends Action {
...
@@ -608,7 +628,8 @@ export class MoveGroupRightAction extends Action {
super
(
id
,
label
);
super
(
id
,
label
);
}
}
public
run
(
position
:
Position
):
TPromise
<
any
>
{
public
run
(
editorIdentifier
:
IEditorIdentifier
):
TPromise
<
any
>
{
let
position
=
editorIdentifier
?
this
.
editorService
.
getStacksModel
().
positionOfGroup
(
editorIdentifier
.
group
)
:
null
;
if
(
typeof
position
!==
'
number
'
)
{
if
(
typeof
position
!==
'
number
'
)
{
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
let
editors
=
this
.
editorService
.
getVisibleEditors
();
let
editors
=
this
.
editorService
.
getVisibleEditors
();
...
...
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
浏览文件 @
5139e261
...
@@ -1025,7 +1025,8 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
...
@@ -1025,7 +1025,8 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
const
toolbar
=
this
.
doCreateToolbar
(
div
,
position
);
const
toolbar
=
this
.
doCreateToolbar
(
div
,
position
);
this
.
editorTitleToolbar
[
position
]
=
toolbar
;
this
.
editorTitleToolbar
[
position
]
=
toolbar
;
this
.
editorTitleToolbar
[
position
].
setActions
([
this
.
closeEditorActions
[
position
]])();
this
.
editorTitleToolbar
[
position
].
setActions
([
this
.
closeEditorActions
[
position
]])();
this
.
editorTitleToolbar
[
position
].
context
=
position
;
const
group
=
this
.
editorService
.
getStacksModel
().
getGroup
(
position
);
this
.
editorTitleToolbar
[
position
].
context
=
{
group
};
});
});
// Left Title Labe
// Left Title Labe
...
@@ -1046,7 +1047,8 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
...
@@ -1046,7 +1047,8 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
},
(
div
)
=>
{
},
(
div
)
=>
{
const
toolbar
=
this
.
doCreateToolbar
(
div
,
position
);
const
toolbar
=
this
.
doCreateToolbar
(
div
,
position
);
this
.
editorActionsToolbar
[
position
]
=
toolbar
;
this
.
editorActionsToolbar
[
position
]
=
toolbar
;
this
.
editorActionsToolbar
[
position
].
context
=
position
;
const
group
=
this
.
editorService
.
getStacksModel
().
getGroup
(
position
);
this
.
editorActionsToolbar
[
position
].
context
=
{
group
};
});
});
}
}
...
@@ -1209,6 +1211,9 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
...
@@ -1209,6 +1211,9 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
const
activePosition
=
this
.
lastActivePosition
;
const
activePosition
=
this
.
lastActivePosition
;
states
.
forEach
(
state
=>
{
states
.
forEach
(
state
=>
{
const
group
=
this
.
editorService
.
getStacksModel
().
groups
[
state
.
position
];
this
.
editorTitleToolbar
[
state
.
position
].
context
=
{
group
};
this
.
editorActionsToolbar
[
state
.
position
].
context
=
{
group
};
let
editor
=
this
.
visibleEditors
[
state
.
position
];
let
editor
=
this
.
visibleEditors
[
state
.
position
];
let
input
=
editor
?
editor
.
input
:
null
;
let
input
=
editor
?
editor
.
input
:
null
;
...
...
src/vs/workbench/common/editor/editorStacksModel.ts
浏览文件 @
5139e261
...
@@ -14,7 +14,7 @@ import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/c
...
@@ -14,7 +14,7 @@ import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/c
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IEditorRegistry
,
Extensions
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
IEditorRegistry
,
Extensions
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
Position
,
Direction
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Position
,
Direction
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
export
interface
IEditorGroup
{
export
interface
IEditorGroup
{
...
@@ -72,7 +72,7 @@ export interface IEditorStacksModel {
...
@@ -72,7 +72,7 @@ export interface IEditorStacksModel {
export
interface
IEditorIdentifier
{
export
interface
IEditorIdentifier
{
group
:
IEditorGroup
;
group
:
IEditorGroup
;
editor
:
EditorInput
;
editor
:
I
EditorInput
;
}
}
export
type
GroupIdentifier
=
number
;
export
type
GroupIdentifier
=
number
;
...
...
src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts
浏览文件 @
5139e261
...
@@ -185,7 +185,7 @@ export class Renderer implements IRenderer {
...
@@ -185,7 +185,7 @@ export class Renderer implements IRenderer {
private
renderEditorGroup
(
tree
:
ITree
,
editorGroup
:
IEditorGroup
,
templateData
:
IOpenEditorTemplateData
):
void
{
private
renderEditorGroup
(
tree
:
ITree
,
editorGroup
:
IEditorGroup
,
templateData
:
IOpenEditorTemplateData
):
void
{
templateData
.
name
.
textContent
=
editorGroup
.
label
;
templateData
.
name
.
textContent
=
editorGroup
.
label
;
templateData
.
actionBar
.
context
=
this
.
model
.
positionOfGroup
(
editorGroup
)
;
templateData
.
actionBar
.
context
=
{
group
:
editorGroup
}
;
}
}
private
renderOpenEditor
(
tree
:
ITree
,
editor
:
OpenEditor
,
templateData
:
IOpenEditorTemplateData
):
void
{
private
renderOpenEditor
(
tree
:
ITree
,
editor
:
OpenEditor
,
templateData
:
IOpenEditorTemplateData
):
void
{
...
@@ -195,7 +195,7 @@ export class Renderer implements IRenderer {
...
@@ -195,7 +195,7 @@ export class Renderer implements IRenderer {
templateData
.
root
.
title
=
resource
?
resource
.
fsPath
:
''
;
templateData
.
root
.
title
=
resource
?
resource
.
fsPath
:
''
;
templateData
.
name
.
textContent
=
editor
.
editorInput
.
getName
();
templateData
.
name
.
textContent
=
editor
.
editorInput
.
getName
();
templateData
.
description
.
textContent
=
editor
.
editorInput
.
getDescription
();
templateData
.
description
.
textContent
=
editor
.
editorInput
.
getDescription
();
templateData
.
actionBar
.
context
=
this
.
model
.
positionOfGroup
(
editor
.
editorGroup
)
;
templateData
.
actionBar
.
context
=
{
group
:
editor
.
editorGroup
,
editor
:
editor
.
editorInput
}
;
}
}
public
disposeTemplate
(
tree
:
ITree
,
templateId
:
string
,
templateData
:
any
):
void
{
public
disposeTemplate
(
tree
:
ITree
,
templateId
:
string
,
templateData
:
any
):
void
{
...
@@ -291,7 +291,8 @@ export class Controller extends treedefaults.DefaultController {
...
@@ -291,7 +291,8 @@ export class Controller extends treedefaults.DefaultController {
event
.
stopPropagation
();
event
.
stopPropagation
();
tree
.
setFocus
(
element
);
tree
.
setFocus
(
element
);
const
editorGroup
=
element
instanceof
EditorGroup
?
element
:
(
<
OpenEditor
>
element
).
editorGroup
;
const
group
=
element
instanceof
EditorGroup
?
element
:
(
<
OpenEditor
>
element
).
editorGroup
;
const
editor
=
element
instanceof
OpenEditor
?
(
<
OpenEditor
>
element
).
editorInput
:
undefined
;
let
anchor
=
{
x
:
event
.
posx
+
1
,
y
:
event
.
posy
};
let
anchor
=
{
x
:
event
.
posx
+
1
,
y
:
event
.
posy
};
this
.
contextMenuService
.
showContextMenu
({
this
.
contextMenuService
.
showContextMenu
({
...
@@ -310,7 +311,7 @@ export class Controller extends treedefaults.DefaultController {
...
@@ -310,7 +311,7 @@ export class Controller extends treedefaults.DefaultController {
tree
.
DOMFocus
();
tree
.
DOMFocus
();
}
}
},
},
getActionsContext
:
()
=>
this
.
model
.
positionOfGroup
(
editorGroup
)
getActionsContext
:
()
=>
({
group
,
editor
}
)
});
});
return
true
;
return
true
;
...
...
src/vs/workbench/test/common/editor/editorStacksModel.test.ts
浏览文件 @
5139e261
...
@@ -1375,7 +1375,7 @@ suite('Editor Stacks Model', () => {
...
@@ -1375,7 +1375,7 @@ suite('Editor Stacks Model', () => {
assert
.
equal
(
previous
.
editor
,
input6
);
assert
.
equal
(
previous
.
editor
,
input6
);
model
.
setActive
(
<
EditorGroup
>
previous
.
group
);
model
.
setActive
(
<
EditorGroup
>
previous
.
group
);
(
<
EditorGroup
>
previous
.
group
).
setActive
(
previous
.
editor
);
(
<
EditorGroup
>
previous
.
group
).
setActive
(
<
EditorInput
>
previous
.
editor
);
let
next
=
model
.
next
();
let
next
=
model
.
next
();
assert
.
equal
(
next
.
group
,
group1
);
assert
.
equal
(
next
.
group
,
group1
);
...
@@ -1389,7 +1389,7 @@ suite('Editor Stacks Model', () => {
...
@@ -1389,7 +1389,7 @@ suite('Editor Stacks Model', () => {
assert
.
equal
(
next
.
editor
,
input4
);
assert
.
equal
(
next
.
editor
,
input4
);
model
.
setActive
(
<
EditorGroup
>
next
.
group
);
model
.
setActive
(
<
EditorGroup
>
next
.
group
);
(
<
EditorGroup
>
next
.
group
).
setActive
(
next
.
editor
);
(
<
EditorGroup
>
next
.
group
).
setActive
(
<
EditorInput
>
next
.
editor
);
previous
=
model
.
previous
();
previous
=
model
.
previous
();
assert
.
equal
(
previous
.
group
,
group1
);
assert
.
equal
(
previous
.
group
,
group1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录