Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6173cf8a
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,发现更多精彩内容 >>
提交
6173cf8a
编写于
9月 10, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pinned tabs - closing pinned tab should open next non-pinned
上级
25081cdb
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
55 addition
and
22 deletion
+55
-22
src/vs/workbench/browser/parts/editor/editorCommands.ts
src/vs/workbench/browser/parts/editor/editorCommands.ts
+30
-1
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+18
-19
src/vs/workbench/services/editor/common/editorService.ts
src/vs/workbench/services/editor/common/editorService.ts
+2
-2
src/vs/workbench/services/editor/test/browser/editorService.test.ts
...kbench/services/editor/test/browser/editorService.test.ts
+5
-0
未找到文件。
src/vs/workbench/browser/parts/editor/editorCommands.ts
浏览文件 @
6173cf8a
...
...
@@ -478,15 +478,44 @@ function registerSplitEditorCommands() {
function
registerCloseEditorCommands
()
{
// A special handler for "Close Editor" depending on context
// - keybindining: do not close sticky editors, rather open the next non-sticky editor
// - menu: always close editor, even sticky ones
function
closeEditorHandler
(
accessor
:
ServicesAccessor
,
forceCloseStickyEditors
:
boolean
,
resourceOrContext
?:
URI
|
IEditorCommandsContext
,
context
?:
IEditorCommandsContext
):
Promise
<
unknown
>
{
const
editorGroupsService
=
accessor
.
get
(
IEditorGroupsService
);
const
editorService
=
accessor
.
get
(
IEditorService
);
let
keepStickyEditors
=
true
;
if
(
forceCloseStickyEditors
)
{
keepStickyEditors
=
false
;
// explicitly close sticky editors
}
else
if
(
resourceOrContext
)
{
}
else
if
(
resourceOrContext
||
context
)
{
keepStickyEditors
=
false
;
// we have a context, as such this command was used e.g. from the tab context menu
}
// Without context: skip over sticky editor and select next if active editor is sticky
if
(
keepStickyEditors
&&
!
resourceOrContext
&&
!
context
)
{
const
activeGroup
=
editorGroupsService
.
activeGroup
;
const
activeEditor
=
activeGroup
.
activeEditor
;
if
(
activeEditor
&&
activeGroup
.
isSticky
(
activeEditor
))
{
// Open next recently active in same group
const
nextNonStickyEditorInGroup
=
activeGroup
.
getEditors
(
EditorsOrder
.
MOST_RECENTLY_ACTIVE
,
{
excludeSticky
:
true
})[
0
];
if
(
nextNonStickyEditorInGroup
)
{
return
activeGroup
.
openEditor
(
nextNonStickyEditorInGroup
);
}
// Open next recently active across all groups
const
nextNonStickyEditorInAllGroups
=
editorService
.
getEditors
(
EditorsOrder
.
MOST_RECENTLY_ACTIVE
,
{
excludeSticky
:
true
})[
0
];
if
(
nextNonStickyEditorInAllGroups
)
{
return
Promise
.
resolve
(
editorGroupsService
.
getGroup
(
nextNonStickyEditorInAllGroups
.
groupId
)?.
openEditor
(
nextNonStickyEditorInAllGroups
.
editor
));
}
}
}
// With context: proceed to close editors as instructed
const
{
editors
,
groups
}
=
getEditorsContext
(
accessor
,
resourceOrContext
,
context
);
return
Promise
.
all
(
groups
.
map
(
async
group
=>
{
if
(
group
)
{
const
editorsToClose
=
coalesce
(
editors
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
6173cf8a
...
...
@@ -436,13 +436,19 @@ export class EditorService extends Disposable implements EditorServiceImpl {
return
this
.
getEditors
(
EditorsOrder
.
SEQUENTIAL
).
map
(({
editor
})
=>
editor
);
}
getEditors
(
order
:
EditorsOrder
.
MOST_RECENTLY_ACTIVE
):
ReadonlyArray
<
IEditorIdentifier
>
;
getEditors
(
order
:
EditorsOrder
.
SEQUENTIAL
,
options
?:
{
excludeSticky
?:
boolean
}):
ReadonlyArray
<
IEditorIdentifier
>
;
getEditors
(
order
:
EditorsOrder
,
options
?:
{
excludeSticky
?:
boolean
}):
ReadonlyArray
<
IEditorIdentifier
>
{
if
(
order
===
EditorsOrder
.
MOST_RECENTLY_ACTIVE
)
{
return
this
.
editorsObserver
.
editors
;
switch
(
order
)
{
// MRU
case
EditorsOrder
.
MOST_RECENTLY_ACTIVE
:
if
(
options
?.
excludeSticky
)
{
return
this
.
editorsObserver
.
editors
.
filter
(({
groupId
,
editor
})
=>
!
this
.
editorGroupService
.
getGroup
(
groupId
)?.
isSticky
(
editor
));
}
return
this
.
editorsObserver
.
editors
;
// Sequential
case
EditorsOrder
.
SEQUENTIAL
:
const
editors
:
IEditorIdentifier
[]
=
[];
this
.
editorGroupService
.
getGroups
(
GroupsOrder
.
GRID_APPEARANCE
).
forEach
(
group
=>
{
...
...
@@ -451,6 +457,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
return
editors
;
}
}
get
activeEditor
():
IEditorInput
|
undefined
{
const
activeGroup
=
this
.
editorGroupService
.
activeGroup
;
...
...
@@ -1323,15 +1330,7 @@ export class DelegatingEditorService implements IEditorService {
get
editors
():
ReadonlyArray
<
IEditorInput
>
{
return
this
.
editorService
.
editors
;
}
get
count
():
number
{
return
this
.
editorService
.
count
;
}
getEditors
(
order
:
EditorsOrder
.
MOST_RECENTLY_ACTIVE
):
ReadonlyArray
<
IEditorIdentifier
>
;
getEditors
(
order
:
EditorsOrder
.
SEQUENTIAL
,
options
?:
{
excludeSticky
?:
boolean
}):
ReadonlyArray
<
IEditorIdentifier
>
;
getEditors
(
order
:
EditorsOrder
,
options
?:
{
excludeSticky
?:
boolean
}):
ReadonlyArray
<
IEditorIdentifier
>
{
if
(
order
===
EditorsOrder
.
MOST_RECENTLY_ACTIVE
)
{
return
this
.
editorService
.
getEditors
(
order
);
}
return
this
.
editorService
.
getEditors
(
order
,
options
);
}
getEditors
(
order
:
EditorsOrder
,
options
?:
{
excludeSticky
?:
boolean
}):
ReadonlyArray
<
IEditorIdentifier
>
{
return
this
.
editorService
.
getEditors
(
order
,
options
);
}
openEditors
(
editors
:
IEditorInputWithOptions
[],
group
?:
OpenInEditorGroup
):
Promise
<
IEditorPane
[]
>
;
openEditors
(
editors
:
IResourceEditorInputType
[],
group
?:
OpenInEditorGroup
):
Promise
<
IEditorPane
[]
>
;
...
...
src/vs/workbench/services/editor/common/editorService.ts
浏览文件 @
6173cf8a
...
...
@@ -175,9 +175,9 @@ export interface IEditorService {
* identifier.
*
* @param order the order of the editors to use
* @param options wether to exclude sticky editors or not
*/
getEditors
(
order
:
EditorsOrder
.
MOST_RECENTLY_ACTIVE
):
ReadonlyArray
<
IEditorIdentifier
>
;
getEditors
(
order
:
EditorsOrder
.
SEQUENTIAL
,
options
?:
{
excludeSticky
?:
boolean
}):
ReadonlyArray
<
IEditorIdentifier
>
;
getEditors
(
order
:
EditorsOrder
,
options
?:
{
excludeSticky
?:
boolean
}):
ReadonlyArray
<
IEditorIdentifier
>
;
/**
* Open an editor in an editor group.
...
...
src/vs/workbench/services/editor/test/browser/editorService.test.ts
浏览文件 @
6173cf8a
...
...
@@ -163,6 +163,11 @@ suite('EditorService', () => {
assert
.
equal
(
input
,
sequentialEditorsExcludingSticky
[
0
].
editor
);
assert
.
equal
(
otherInput
,
sequentialEditorsExcludingSticky
[
1
].
editor
);
const
mruEditorsExcludingSticky
=
service
.
getEditors
(
EditorsOrder
.
MOST_RECENTLY_ACTIVE
,
{
excludeSticky
:
true
});
assert
.
equal
(
mruEditorsExcludingSticky
.
length
,
2
);
assert
.
equal
(
input
,
sequentialEditorsExcludingSticky
[
0
].
editor
);
assert
.
equal
(
otherInput
,
sequentialEditorsExcludingSticky
[
1
].
editor
);
activeEditorChangeListener
.
dispose
();
visibleEditorChangeListener
.
dispose
();
didCloseEditorListener
.
dispose
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录