Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f6703e50
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,发现更多精彩内容 >>
提交
f6703e50
编写于
3月 04, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - group context keys in one place
上级
cdbe7bff
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
18 deletion
+44
-18
src/vs/workbench/browser/contextkeys.ts
src/vs/workbench/browser/contextkeys.ts
+30
-3
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+9
-15
src/vs/workbench/services/part/common/partService.ts
src/vs/workbench/services/part/common/partService.ts
+5
-0
未找到文件。
src/vs/workbench/browser/contextkeys.ts
浏览文件 @
f6703e50
...
...
@@ -8,7 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
InputFocusedContext
}
from
'
vs/platform/contextkey/common/contextkeys
'
;
import
{
IWindowConfiguration
,
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
ActiveEditorContext
,
EditorsVisibleContext
,
TextCompareEditorVisibleContext
,
TextCompareEditorActiveContext
,
ActiveEditorGroupEmptyContext
,
MultipleEditorGroupsContext
,
TEXT_DIFF_EDITOR_ID
,
SplitEditorsVertically
}
from
'
vs/workbench/common/editor
'
;
import
{
ActiveEditorContext
,
EditorsVisibleContext
,
TextCompareEditorVisibleContext
,
TextCompareEditorActiveContext
,
ActiveEditorGroupEmptyContext
,
MultipleEditorGroupsContext
,
TEXT_DIFF_EDITOR_ID
,
SplitEditorsVertically
,
InEditorZenModeContext
}
from
'
vs/workbench/common/editor
'
;
import
{
IsMacContext
,
IsLinuxContext
,
IsWindowsContext
,
HasMacNativeTabsContext
,
IsDevelopmentContext
,
SupportsWorkspacesContext
,
SupportsOpenFileFolderContext
,
WorkbenchStateContext
,
WorkspaceFolderCountContext
}
from
'
vs/workbench/common/contextkeys
'
;
import
{
trackFocus
,
addDisposableListener
,
EventType
}
from
'
vs/base/browser/dom
'
;
import
{
preferredSideBySideGroupDirection
,
GroupDirection
,
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
...
...
@@ -17,18 +17,28 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
WorkbenchState
,
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
EditorGroupsServiceImpl
}
from
'
vs/workbench/browser/parts/editor/editor
'
;
import
{
SidebarVisibleContext
}
from
'
vs/workbench/common/viewlet
'
;
import
{
IPartService
,
Parts
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
export
class
WorkbenchContextKeysHandler
extends
Disposable
{
private
inputFocusedContext
:
IContextKey
<
boolean
>
;
private
activeEditorContext
:
IContextKey
<
string
|
null
>
;
private
editorsVisibleContext
:
IContextKey
<
boolean
>
;
private
textCompareEditorVisibleContext
:
IContextKey
<
boolean
>
;
private
textCompareEditorActiveContext
:
IContextKey
<
boolean
>
;
private
activeEditorGroupEmpty
:
IContextKey
<
boolean
>
;
private
multipleEditorGroupsContext
:
IContextKey
<
boolean
>
;
private
splitEditorsVerticallyContext
:
IContextKey
<
boolean
>
;
private
workbenchStateContext
:
IContextKey
<
string
>
;
private
workspaceFolderCountContext
:
IContextKey
<
number
>
;
private
splitEditorsVerticallyContext
:
IContextKey
<
boolean
>
;
private
inZenModeContext
:
IContextKey
<
boolean
>
;
private
sideBarVisibleContext
:
IContextKey
<
boolean
>
;
constructor
(
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
,
...
...
@@ -37,7 +47,9 @@ export class WorkbenchContextKeysHandler extends Disposable {
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IWindowService
private
windowService
:
IWindowService
,
@
IEditorService
private
editorService
:
IEditorService
,
@
IEditorGroupsService
private
editorGroupService
:
EditorGroupsServiceImpl
@
IEditorGroupsService
private
editorGroupService
:
EditorGroupsServiceImpl
,
@
IPartService
private
partService
:
IPartService
,
@
IViewletService
private
viewletService
:
IViewletService
)
{
super
();
...
...
@@ -63,6 +75,11 @@ export class WorkbenchContextKeysHandler extends Disposable {
this
.
updateSplitEditorsVerticallyContext
();
}
}));
this
.
_register
(
this
.
partService
.
onZenModeChange
(
enabled
=>
this
.
inZenModeContext
.
set
(
enabled
)));
this
.
_register
(
this
.
viewletService
.
onDidViewletClose
(()
=>
this
.
updateSideBarContextKeys
()));
this
.
_register
(
this
.
viewletService
.
onDidViewletOpen
(()
=>
this
.
updateSideBarContextKeys
()));
}
private
initContextKeys
():
void
{
...
...
@@ -105,6 +122,12 @@ export class WorkbenchContextKeysHandler extends Disposable {
// Editor Layout
this
.
splitEditorsVerticallyContext
=
SplitEditorsVertically
.
bindTo
(
this
.
contextKeyService
);
this
.
updateSplitEditorsVerticallyContext
();
// Zen Mode
this
.
inZenModeContext
=
InEditorZenModeContext
.
bindTo
(
this
.
contextKeyService
);
// Sidebar
this
.
sideBarVisibleContext
=
SidebarVisibleContext
.
bindTo
(
this
.
contextKeyService
);
}
private
updateEditorContextKeys
():
void
{
...
...
@@ -178,4 +201,8 @@ export class WorkbenchContextKeysHandler extends Disposable {
case
WorkbenchState
.
WORKSPACE
:
return
'
workspace
'
;
}
}
private
updateSideBarContextKeys
():
void
{
this
.
sideBarVisibleContext
.
set
(
this
.
partService
.
isVisible
(
Parts
.
SIDEBAR_PART
));
}
}
\ No newline at end of file
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
f6703e50
...
...
@@ -19,7 +19,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import
{
isWindows
,
isLinux
,
isMacintosh
,
language
}
from
'
vs/base/common/platform
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
IEditorInputFactoryRegistry
,
Extensions
as
EditorExtensions
,
IUntitledResourceInput
,
IResourceDiffInput
,
InEditorZenModeContext
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditorInputFactoryRegistry
,
Extensions
as
EditorExtensions
,
IUntitledResourceInput
,
IResourceDiffInput
}
from
'
vs/workbench/common/editor
'
;
import
{
ActivitybarPart
}
from
'
vs/workbench/browser/parts/activitybar/activitybarPart
'
;
import
{
SidebarPart
}
from
'
vs/workbench/browser/parts/sidebar/sidebarPart
'
;
import
{
PanelPart
}
from
'
vs/workbench/browser/parts/panel/panelPart
'
;
...
...
@@ -40,7 +40,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import
{
IJSONEditingService
}
from
'
vs/workbench/services/configuration/common/jsonEditing
'
;
import
{
ContextKeyService
}
from
'
vs/platform/contextkey/browser/contextKeyService
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKeyService
}
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
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -111,7 +111,6 @@ import { WorkbenchThemeService } from 'vs/workbench/services/themes/browser/work
import
{
IProductService
}
from
'
vs/platform/product/common/product
'
;
import
{
IAccessibilityService
}
from
'
vs/platform/accessibility/common/accessibility
'
;
import
{
WorkbenchContextKeysHandler
}
from
'
vs/workbench/browser/contextkeys
'
;
import
{
SidebarVisibleContext
}
from
'
vs/workbench/common/viewlet
'
;
// import@node
import
{
BackupFileService
,
InMemoryBackupFileService
}
from
'
vs/workbench/services/backup/node/backupFileService
'
;
...
...
@@ -202,7 +201,6 @@ export class Workbench extends Disposable implements IPartService {
private
editorService
:
EditorService
;
private
editorGroupService
:
IEditorGroupsService
;
private
contextViewService
:
ContextViewService
;
private
contextKeyService
:
IContextKeyService
;
private
keybindingService
:
IKeybindingService
;
private
backupFileService
:
IBackupFileService
;
private
notificationService
:
NotificationService
;
...
...
@@ -225,8 +223,6 @@ export class Workbench extends Disposable implements IPartService {
private
notificationsToasts
:
NotificationsToasts
;
private
fontAliasing
:
FontAliasingOption
;
private
inZenModeContext
:
IContextKey
<
boolean
>
;
private
sideBarVisibleContext
:
IContextKey
<
boolean
>
;
constructor
(
private
container
:
HTMLElement
,
...
...
@@ -335,8 +331,6 @@ export class Workbench extends Disposable implements IPartService {
// Context Keys
this
.
_register
(
this
.
instantiationService
.
createInstance
(
WorkbenchContextKeysHandler
));
this
.
inZenModeContext
=
InEditorZenModeContext
.
bindTo
(
this
.
contextKeyService
);
this
.
sideBarVisibleContext
=
SidebarVisibleContext
.
bindTo
(
this
.
contextKeyService
);
// Register Listeners
this
.
registerListeners
();
...
...
@@ -494,8 +488,7 @@ export class Workbench extends Disposable implements IPartService {
serviceCollection
.
set
(
IStatusbarService
,
this
.
statusbarPart
);
// Context Keys
this
.
contextKeyService
=
this
.
instantiationService
.
createInstance
(
ContextKeyService
);
serviceCollection
.
set
(
IContextKeyService
,
this
.
contextKeyService
);
serviceCollection
.
set
(
IContextKeyService
,
new
SyncDescriptor
(
ContextKeyService
));
// Keybindings
this
.
keybindingService
=
this
.
instantiationService
.
createInstance
(
WorkbenchKeybindingService
,
window
);
...
...
@@ -696,8 +689,6 @@ export class Workbench extends Disposable implements IPartService {
// Restore Sidebar
let
viewletIdToRestore
:
string
|
undefined
;
if
(
!
this
.
state
.
sideBar
.
hidden
)
{
this
.
sideBarVisibleContext
.
set
(
true
);
if
(
this
.
shouldRestoreLastOpenedViewlet
())
{
viewletIdToRestore
=
this
.
storageService
.
get
(
SidebarPart
.
activeViewletSettingsKey
,
StorageScope
.
WORKSPACE
);
}
...
...
@@ -1055,6 +1046,9 @@ export class Workbench extends Disposable implements IPartService {
private
readonly
_onTitleBarVisibilityChange
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
get
onTitleBarVisibilityChange
():
Event
<
void
>
{
return
this
.
_onTitleBarVisibilityChange
.
event
;
}
private
readonly
_onZenMode
:
Emitter
<
boolean
>
=
this
.
_register
(
new
Emitter
<
boolean
>
());
get
onZenModeChange
():
Event
<
boolean
>
{
return
this
.
_onZenMode
.
event
;
}
get
onEditorLayout
():
Event
<
IDimension
>
{
return
this
.
editorPart
.
onDidLayout
;
}
private
workbenchGrid
:
Grid
<
View
>
|
WorkbenchLayout
;
...
...
@@ -1346,8 +1340,6 @@ export class Workbench extends Disposable implements IPartService {
toggleFullScreen
=
this
.
state
.
zenMode
.
transitionedToFullScreen
&&
isFullscreen
();
}
this
.
inZenModeContext
.
set
(
this
.
state
.
zenMode
.
active
);
if
(
!
skipLayout
)
{
this
.
layout
();
}
...
...
@@ -1355,6 +1347,9 @@ export class Workbench extends Disposable implements IPartService {
if
(
toggleFullScreen
)
{
this
.
windowService
.
toggleFullScreen
();
}
// Event
this
.
_onZenMode
.
fire
(
this
.
state
.
zenMode
.
active
);
}
private
setStatusBarHidden
(
hidden
:
boolean
,
skipLayout
?:
boolean
):
void
{
...
...
@@ -1601,7 +1596,6 @@ export class Workbench extends Disposable implements IPartService {
setSideBarHidden
(
hidden
:
boolean
,
skipLayout
?:
boolean
):
void
{
this
.
state
.
sideBar
.
hidden
=
hidden
;
this
.
sideBarVisibleContext
.
set
(
!
hidden
);
// Adjust CSS
if
(
hidden
)
{
...
...
src/vs/workbench/services/part/common/partService.ts
浏览文件 @
f6703e50
...
...
@@ -49,6 +49,11 @@ export interface IPartService {
*/
onTitleBarVisibilityChange
:
Event
<
void
>
;
/**
* Emits when the zen mode is enabled or disabled.
*/
onZenModeChange
:
Event
<
boolean
>
;
/**
* Emits when the editor part's layout changes.
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录