Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7a14223c
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7a14223c
编写于
5月 05, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - more context keys and commands
上级
b6c60a5b
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
102 addition
and
37 deletion
+102
-37
src/vs/workbench/browser/parts/editor/editorCommands.ts
src/vs/workbench/browser/parts/editor/editorCommands.ts
+22
-7
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+2
-2
src/vs/workbench/browser/parts/editor2/media/nextEditorGroupView.css
...bench/browser/parts/editor2/media/nextEditorGroupView.css
+4
-0
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
...vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
+7
-4
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
+10
-0
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+7
-2
src/vs/workbench/electron-browser/commands.ts
src/vs/workbench/electron-browser/commands.ts
+2
-2
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+38
-20
src/vs/workbench/services/editor/common/nextEditorGroupsService.ts
...rkbench/services/editor/common/nextEditorGroupsService.ts
+10
-0
未找到文件。
src/vs/workbench/browser/parts/editor/editorCommands.ts
浏览文件 @
7a14223c
...
...
@@ -8,7 +8,7 @@ import * as types from 'vs/base/common/types';
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
ActiveEditorMoveArguments
,
ActiveEditorMovePositioning
,
ActiveEditorMovePositioningBy
,
EditorCommands
,
TextCompareEditorVisible
,
EditorInput
,
IEditorIdentifier
,
IEditorCommand
sContext
}
from
'
vs/workbench/common/editor
'
;
import
{
ActiveEditorMoveArguments
,
ActiveEditorMovePositioning
,
ActiveEditorMovePositioningBy
,
EditorCommands
,
TextCompareEditorVisible
Context
,
EditorInput
,
IEditorIdentifier
,
IEditorCommandsContext
,
ActiveEditorGroupEmptyContext
,
MultipleEditorGroup
sContext
}
from
'
vs/workbench/common/editor
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditor
,
Position
,
POSITIONS
,
Direction
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
...
...
@@ -22,11 +22,14 @@ import { IDiffEditorOptions } from 'vs/editor/common/config/editorOptions';
import
{
IListService
}
from
'
vs/platform/list/browser/listService
'
;
import
{
List
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
INextEditorGroupsService
}
from
'
vs/workbench/services/editor/common/nextEditorGroupsService
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
export
const
CLOSE_SAVED_EDITORS_COMMAND_ID
=
'
workbench.action.closeUnmodifiedEditors
'
;
export
const
CLOSE_EDITORS_IN_GROUP_COMMAND_ID
=
'
workbench.action.closeEditorsInGroup
'
;
export
const
CLOSE_EDITORS_TO_THE_RIGHT_COMMAND_ID
=
'
workbench.action.closeEditorsToTheRight
'
;
export
const
CLOSE_EDITOR_COMMAND_ID
=
'
workbench.action.closeActiveEditor
'
;
export
const
CLOSE_EDITOR_GROUP_COMMAND_ID
=
'
workbench.action.closeActiveEditorGroup
'
;
export
const
CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID
=
'
workbench.action.closeOtherEditors
'
;
export
const
KEEP_EDITOR_COMMAND_ID
=
'
workbench.action.keepEditor
'
;
export
const
SHOW_EDITORS_IN_GROUP
=
'
workbench.action.showEditorsInGroup
'
;
...
...
@@ -162,7 +165,7 @@ function registerDiffEditorCommands(): void {
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.action.compareEditor.nextChange
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
TextCompareEditorVisible
,
when
:
TextCompareEditorVisible
Context
,
primary
:
null
,
handler
:
accessor
=>
navigateInDiffEditor
(
accessor
,
true
)
});
...
...
@@ -170,7 +173,7 @@ function registerDiffEditorCommands(): void {
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
'
workbench.action.compareEditor.previousChange
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
TextCompareEditorVisible
,
when
:
TextCompareEditorVisible
Context
,
primary
:
null
,
handler
:
accessor
=>
navigateInDiffEditor
(
accessor
,
false
)
});
...
...
@@ -327,6 +330,7 @@ function registerEditorCommands() {
handler
:
(
accessor
,
resource
:
URI
|
object
,
context
:
IEditorCommandsContext
)
=>
{
const
editorGroupService
=
accessor
.
get
(
IEditorGroupService
);
const
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
const
nextEditorGroupService
=
accessor
.
get
(
INextEditorGroupsService
);
const
contexts
=
getMultiSelectedEditorContexts
(
context
,
accessor
.
get
(
IListService
));
const
groupIds
=
distinct
(
contexts
.
map
(
context
=>
context
.
groupId
));
...
...
@@ -353,10 +357,7 @@ function registerEditorCommands() {
});
if
(
editorsToClose
.
size
===
0
)
{
const
activeEditor
=
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
return
editorService
.
closeEditor
(
activeEditor
.
position
,
activeEditor
.
input
);
}
return
nextEditorGroupService
.
activeGroup
.
closeEditor
();
}
return
editorService
.
closeEditors
({
...
...
@@ -367,6 +368,20 @@ function registerEditorCommands() {
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
CLOSE_EDITOR_GROUP_COMMAND_ID
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
when
:
ContextKeyExpr
.
and
(
ActiveEditorGroupEmptyContext
,
MultipleEditorGroupsContext
),
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_W
,
win
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
F4
,
secondary
:
[
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_W
]
},
handler
:
(
accessor
,
resource
:
URI
|
object
,
context
:
IEditorCommandsContext
)
=>
{
const
nextEditorGroupService
=
accessor
.
get
(
INextEditorGroupsService
);
// TODO@grid handle more cases from the related CLOSE_EDITOR_COMMAND_ID and also revisit command ID
nextEditorGroupService
.
removeGroup
(
nextEditorGroupService
.
activeGroup
);
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
({
id
:
CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(),
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
7a14223c
...
...
@@ -20,7 +20,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import
{
Scope
as
MementoScope
}
from
'
vs/workbench/common/memento
'
;
import
{
Part
}
from
'
vs/workbench/browser/part
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
EditorInput
,
EditorOptions
,
ConfirmResult
,
IWorkbenchEditorConfiguration
,
TextEditorOptions
,
SideBySideEditorInput
,
TextCompareEditorVisible
,
TEXT_DIFF_EDITOR_ID
,
EditorOpeningEvent
,
IEditorOpeningEvent
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorInput
,
EditorOptions
,
ConfirmResult
,
IWorkbenchEditorConfiguration
,
TextEditorOptions
,
SideBySideEditorInput
,
TextCompareEditorVisible
Context
,
TEXT_DIFF_EDITOR_ID
,
EditorOpeningEvent
,
IEditorOpeningEvent
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorGroupsControl
,
Rochade
,
IEditorGroupsControl
,
ProgressState
}
from
'
vs/workbench/browser/parts/editor/editorGroupsControl
'
;
import
{
ScopedProgressService
}
from
'
vs/workbench/services/progress/browser/progressService
'
;
import
{
IEditorGroupService
,
GroupOrientation
,
GroupArrangement
,
IEditorTabOptions
,
IMoveOptions
}
from
'
vs/workbench/services/group/common/groupService
'
;
...
...
@@ -703,7 +703,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this
.
stacks
=
this
.
instantiationService
.
createInstance
(
EditorStacksModel
,
restoreFromStorage
);
this
.
textCompareEditorVisible
=
TextCompareEditorVisible
.
bindTo
(
contextKeyService
);
this
.
textCompareEditorVisible
=
TextCompareEditorVisible
Context
.
bindTo
(
contextKeyService
);
const
config
=
configurationService
.
getValue
<
IWorkbenchEditorConfiguration
>
();
if
(
config
&&
config
.
workbench
&&
config
.
workbench
.
editor
)
{
...
...
src/vs/workbench/browser/parts/editor2/media/nextEditorGroupView.css
浏览文件 @
7a14223c
...
...
@@ -23,6 +23,10 @@
outline-offset
:
-2px
;
}
.monaco-workbench
>
.part.editor
>
.content.empty
.editor-group-container.empty.active
{
outline-width
:
0
;
/* no outline when editor part is empty */
}
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title
{
height
:
35px
;
display
:
flex
;
...
...
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
浏览文件 @
7a14223c
...
...
@@ -551,10 +551,6 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
// Update model
this
.
_group
.
openEditor
(
editor
,
openEditorOptions
);
// Forward to title control (create lazily)
const
titleAreaControl
=
this
.
titleAreaControl
||
this
.
createTitleAreaControl
();
titleAreaControl
.
openEditor
(
editor
);
// Forward to editor control if the active editor changed (create lazily)
let
openEditorPromise
:
Thenable
<
void
>
;
if
(
openEditorOptions
.
active
)
{
...
...
@@ -574,6 +570,10 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
openEditorPromise
=
TPromise
.
as
(
void
0
);
}
// Forward to title control after editor control because some actions depend on it (create lazily)
const
titleAreaControl
=
this
.
titleAreaControl
||
this
.
createTitleAreaControl
();
titleAreaControl
.
openEditor
(
editor
);
return
openEditorPromise
;
}
...
...
@@ -669,6 +669,9 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
//#region closeEditor()
closeEditor
(
editor
:
EditorInput
=
this
.
activeEditor
):
Thenable
<
void
>
{
if
(
!
editor
)
{
return
TPromise
.
as
(
void
0
);
}
// Check for dirty and veto
return
this
.
handleDirty
([
editor
],
true
/* ignore if opened in other group */
).
then
(
veto
=>
{
...
...
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
浏览文件 @
7a14223c
...
...
@@ -50,6 +50,9 @@ export class NextEditorPart extends Part implements INextEditorGroupsService, IN
private
_onDidAddGroup
:
Emitter
<
INextEditorGroupView
>
=
this
.
_register
(
new
Emitter
<
INextEditorGroupView
>
());
get
onDidAddGroup
():
Event
<
INextEditorGroupView
>
{
return
this
.
_onDidAddGroup
.
event
;
}
private
_onDidRemoveGroup
:
Emitter
<
INextEditorGroupView
>
=
this
.
_register
(
new
Emitter
<
INextEditorGroupView
>
());
get
onDidRemoveGroup
():
Event
<
INextEditorGroupView
>
{
return
this
.
_onDidRemoveGroup
.
event
;
}
//#endregion
private
dimension
:
Dimension
;
...
...
@@ -135,6 +138,10 @@ export class NextEditorPart extends Part implements INextEditorGroupsService, IN
return
values
(
this
.
groupViews
);
}
get
count
():
number
{
return
this
.
groupViews
.
size
;
}
getGroups
(
sortByMostRecentlyActive
?:
boolean
):
INextEditorGroupView
[]
{
if
(
!
sortByMostRecentlyActive
)
{
return
this
.
groups
;
...
...
@@ -227,6 +234,9 @@ export class NextEditorPart extends Part implements INextEditorGroupsService, IN
// Update container
this
.
updateContainer
();
// Event
this
.
_onDidRemoveGroup
.
fire
(
groupView
);
}
private
toGridViewDirection
(
direction
:
Direction
):
GridViewDirection
{
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
7a14223c
...
...
@@ -13,13 +13,18 @@ import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
import
{
IEditor
,
IEditorViewState
,
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorInput
,
IEditorModel
,
IEditorOptions
,
ITextEditorOptions
,
IBaseResourceInput
,
Position
,
Verbosity
,
IEditor
as
IBaseEditor
,
IRevertOptions
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IInstantiationService
,
IConstructorSignature0
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
RawContextKey
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
LRUCache
}
from
'
vs/base/common/map
'
;
export
const
TextCompareEditorVisible
=
new
RawContextKey
<
boolean
>
(
'
textCompareEditorVisible
'
,
false
);
export
const
EditorsVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
editorIsOpen
'
,
false
);
export
const
NoEditorsVisibleContext
:
ContextKeyExpr
=
EditorsVisibleContext
.
toNegated
();
export
const
TextCompareEditorVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
textCompareEditorVisible
'
,
false
);
export
const
ActiveEditorGroupEmptyContext
=
new
RawContextKey
<
boolean
>
(
'
activeEditorGroupEmpty
'
,
false
);
export
const
MultipleEditorGroupsContext
=
new
RawContextKey
<
boolean
>
(
'
multipleEditorGroups
'
,
false
);
export
const
InEditorZenModeContext
=
new
RawContextKey
<
boolean
>
(
'
inZenMode
'
,
false
);
export
enum
ConfirmResult
{
SAVE
,
...
...
src/vs/workbench/electron-browser/commands.ts
浏览文件 @
7a14223c
...
...
@@ -10,7 +10,6 @@ import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
NoEditorsVisibleContext
,
InZenModeContext
}
from
'
vs/workbench/electron-browser/workbench
'
;
import
{
IWindowsService
,
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
List
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
*
as
errors
from
'
vs/base/common/errors
'
;
...
...
@@ -23,6 +22,7 @@ import { PagedList } from 'vs/base/browser/ui/list/listPaging';
import
{
range
}
from
'
vs/base/common/arrays
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ITree
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
InEditorZenModeContext
,
NoEditorsVisibleContext
}
from
'
vs/workbench/common/editor
'
;
// --- List Commands
...
...
@@ -519,7 +519,7 @@ export function registerCommands(): void {
const
partService
=
accessor
.
get
(
IPartService
);
partService
.
toggleZenMode
();
},
when
:
InZenModeContext
,
when
:
In
Editor
ZenModeContext
,
primary
:
KeyChord
(
KeyCode
.
Escape
,
KeyCode
.
Escape
)
});
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
7a14223c
...
...
@@ -23,7 +23,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import
{
isWindows
,
isLinux
,
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
Position
as
EditorPosition
,
IResourceDiffInput
,
IUntitledResourceInput
,
IEditor
,
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
IEditorInputFactoryRegistry
,
Extensions
as
EditorExtensions
,
TextCompareEditorVisible
,
TEXT_DIFF_EDITOR_ID
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditorInputFactoryRegistry
,
Extensions
as
EditorExtensions
,
TextCompareEditorVisible
Context
,
TEXT_DIFF_EDITOR_ID
,
EditorsVisibleContext
,
InEditorZenModeContext
,
ActiveEditorGroupEmptyContext
,
MultipleEditorGroupsContext
}
from
'
vs/workbench/common/editor
'
;
import
{
HistoryService
}
from
'
vs/workbench/services/history/electron-browser/history
'
;
import
{
ActivitybarPart
}
from
'
vs/workbench/browser/parts/activitybar/activitybarPart
'
;
import
{
SidebarPart
}
from
'
vs/workbench/browser/parts/sidebar/sidebarPart
'
;
...
...
@@ -49,7 +49,7 @@ import { JSONEditingService } from 'vs/workbench/services/configuration/node/jso
import
{
ContextKeyService
}
from
'
vs/platform/contextkey/browser/contextKeyService
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingEditingService
,
KeybindingsEditingService
}
from
'
vs/workbench/services/keybinding/common/keybindingEditing
'
;
import
{
ContextKeyExpr
,
RawContextKey
,
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
RawContextKey
,
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IActivityService
}
from
'
vs/workbench/services/activity/common/activity
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
ViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewletService
'
;
...
...
@@ -114,11 +114,6 @@ import { INextEditorGroupsService } from 'vs/workbench/services/editor/common/ne
import
{
NextEditorService
}
from
'
vs/workbench/services/editor/browser/nextEditorService
'
;
import
{
IExtensionUrlHandler
,
ExtensionUrlHandler
}
from
'
vs/platform/url/electron-browser/inactiveExtensionUrlHandler
'
;
export
const
EditorsVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
editorIsOpen
'
,
false
);
export
const
InZenModeContext
=
new
RawContextKey
<
boolean
>
(
'
inZenMode
'
,
false
);
export
const
SidebarVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
sidebarVisible
'
,
false
);
export
const
NoEditorsVisibleContext
:
ContextKeyExpr
=
EditorsVisibleContext
.
toNegated
();
interface
WorkbenchParams
{
configuration
:
IWindowConfiguration
;
serviceCollection
:
ServiceCollection
;
...
...
@@ -195,9 +190,10 @@ export class Workbench extends Disposable implements IPartService {
private
workbenchCreated
:
boolean
;
private
workbenchShutdown
:
boolean
;
private
nextEditorService
:
INextEditorService
;
private
nextEditorGroupsService
:
INextEditorGroupsService
;
private
legacyEditorService
:
IWorkbenchEditorService
;
private
legacyEditorGroupService
:
IEditorGroupService
;
private
nextEditorService
:
INextEditorService
;
private
viewletService
:
IViewletService
;
private
contextKeyService
:
IContextKeyService
;
private
keybindingService
:
IKeybindingService
;
...
...
@@ -230,8 +226,6 @@ export class Workbench extends Disposable implements IPartService {
private
hasFilesToCreateOpenOrDiff
:
boolean
;
private
inZenMode
:
IContextKey
<
boolean
>
;
private
editorsVisibleContext
:
IContextKey
<
boolean
>
;
private
textCompareEditorVisible
:
IContextKey
<
boolean
>
;
private
sideBarVisibleContext
:
IContextKey
<
boolean
>
;
private
closeEmptyWindowScheduler
:
RunOnceScheduler
=
new
RunOnceScheduler
(()
=>
this
.
onAllEditorsClosed
(),
50
);
...
...
@@ -306,21 +300,44 @@ export class Workbench extends Disposable implements IPartService {
}
private
handleContextKeys
():
void
{
this
.
editorsVisibleContext
=
EditorsVisibl
eContext
.
bindTo
(
this
.
contextKeyService
);
this
.
textCompareEditorVisible
=
TextCompareEditorVisible
.
bindTo
(
this
.
contextKeyService
);
this
.
inZenMode
=
InZenModeContext
.
bindTo
(
this
.
contextKeyServic
e
);
this
.
sideBarVisibleContext
=
SidebarVisibleContext
.
bindTo
(
this
.
contextKeyService
);
this
.
inZenMode
=
InEditorZenMod
eContext
.
bindTo
(
this
.
contextKeyService
);
const
sidebarVisibleContextRaw
=
new
RawContextKey
<
boolean
>
(
'
sidebarVisible
'
,
fals
e
);
this
.
sideBarVisibleContext
=
sidebarVisibleContextRaw
.
bindTo
(
this
.
contextKeyService
);
this
.
_register
(
this
.
nextEditorService
.
onDidVisibleEditorsChange
(()
=>
{
const
editorsVisibleContext
=
EditorsVisibleContext
.
bindTo
(
this
.
contextKeyService
);
const
textCompareEditorVisible
=
TextCompareEditorVisibleContext
.
bindTo
(
this
.
contextKeyService
);
const
activeEditorGroupEmpty
=
ActiveEditorGroupEmptyContext
.
bindTo
(
this
.
contextKeyService
);
const
multipleEditorGroups
=
MultipleEditorGroupsContext
.
bindTo
(
this
.
contextKeyService
);
const
updateEditorContextKeys
=
()
=>
{
const
visibleEditors
=
this
.
nextEditorService
.
visibleControls
;
this
.
textCompareEditorVisible
.
set
(
visibleEditors
.
some
(
e
=>
e
&&
e
.
isVisible
()
&&
e
.
getId
()
===
TEXT_DIFF_EDITOR_ID
));
if
(
visibleEditors
.
length
===
0
)
{
this
.
editorsVisibleContext
.
reset
();
textCompareEditorVisible
.
set
(
visibleEditors
.
some
(
control
=>
control
.
getId
()
===
TEXT_DIFF_EDITOR_ID
));
if
(
visibleEditors
.
length
>
0
)
{
editorsVisibleContext
.
set
(
true
);
}
else
{
this
.
editorsVisibleContext
.
set
(
true
);
editorsVisibleContext
.
reset
(
);
}
}));
if
(
!
this
.
nextEditorService
.
activeEditor
)
{
activeEditorGroupEmpty
.
set
(
true
);
}
else
{
activeEditorGroupEmpty
.
reset
();
}
if
(
this
.
nextEditorGroupsService
.
count
>
1
)
{
multipleEditorGroups
.
set
(
true
);
}
else
{
multipleEditorGroups
.
reset
();
}
};
this
.
_register
(
this
.
nextEditorService
.
onDidActiveEditorChange
(()
=>
updateEditorContextKeys
()));
this
.
_register
(
this
.
nextEditorService
.
onDidVisibleEditorsChange
(()
=>
updateEditorContextKeys
()));
this
.
_register
(
this
.
nextEditorGroupsService
.
onDidAddGroup
(()
=>
updateEditorContextKeys
()));
this
.
_register
(
this
.
nextEditorGroupsService
.
onDidRemoveGroup
(()
=>
updateEditorContextKeys
()));
const
inputFocused
=
InputFocusedContext
.
bindTo
(
this
.
contextKeyService
);
this
.
_register
(
DOM
.
addDisposableListener
(
window
,
'
focusin
'
,
()
=>
{
...
...
@@ -715,6 +732,7 @@ export class Workbench extends Disposable implements IPartService {
// Editor service (next editor part)
this
.
editorPart
=
this
.
instantiationService
.
createInstance
(
NextEditorPart
,
Identifiers
.
EDITOR_PART
/*, !this.hasFilesToCreateOpenOrDiff*/
);
this
.
_register
(
toDisposable
(()
=>
this
.
editorPart
.
shutdown
()));
this
.
nextEditorGroupsService
=
this
.
editorPart
;
serviceCollection
.
set
(
INextEditorGroupsService
,
this
.
editorPart
);
this
.
nextEditorService
=
this
.
instantiationService
.
createInstance
(
NextEditorService
);
serviceCollection
.
set
(
INextEditorService
,
this
.
nextEditorService
);
...
...
src/vs/workbench/services/editor/common/nextEditorGroupsService.ts
浏览文件 @
7a14223c
...
...
@@ -155,6 +155,11 @@ export interface INextEditorGroupsService {
*/
readonly
onDidAddGroup
:
Event
<
INextEditorGroup
>
;
/**
* An event for when a group was removed.
*/
readonly
onDidRemoveGroup
:
Event
<
INextEditorGroup
>
;
/**
* An active group is the default location for new editors to open.
*/
...
...
@@ -165,6 +170,11 @@ export interface INextEditorGroupsService {
*/
readonly
groups
:
INextEditorGroup
[];
/**
* The number of editor groups that are currently opened.
*/
readonly
count
:
number
;
/**
* Get all groups that are currently visible in the editor area optionally
* sorted by being most recent active.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录