Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
c038219f
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,发现更多精彩内容 >>
提交
c038219f
编写于
10月 24, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adopt new event for when editor layout changes
上级
53042122
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
50 addition
and
36 deletion
+50
-36
src/vs/test/utils/servicesTestUtils.ts
src/vs/test/utils/servicesTestUtils.ts
+6
-0
src/vs/workbench/browser/actions/toggleEditorLayout.ts
src/vs/workbench/browser/actions/toggleEditorLayout.ts
+7
-0
src/vs/workbench/browser/layout.ts
src/vs/workbench/browser/layout.ts
+11
-17
src/vs/workbench/browser/parts/editor/editorActions.ts
src/vs/workbench/browser/parts/editor/editorActions.ts
+3
-4
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+18
-15
src/vs/workbench/services/group/common/groupService.ts
src/vs/workbench/services/group/common/groupService.ts
+5
-0
未找到文件。
src/vs/test/utils/servicesTestUtils.ts
浏览文件 @
c038219f
...
...
@@ -315,10 +315,12 @@ export class TestEditorGroupService implements IEditorGroupService {
private
_onEditorsChanged
:
Emitter
<
void
>
;
private
_onEditorOpenFail
:
Emitter
<
IEditorInput
>
;
private
_onEditorsMoved
:
Emitter
<
void
>
;
private
_onGroupOrientationChanged
:
Emitter
<
void
>
;
constructor
(
callback
?:
(
method
:
string
)
=>
void
)
{
this
.
_onEditorsMoved
=
new
Emitter
<
void
>
();
this
.
_onEditorsChanged
=
new
Emitter
<
void
>
();
this
.
_onGroupOrientationChanged
=
new
Emitter
<
void
>
();
this
.
_onEditorOpenFail
=
new
Emitter
<
IEditorInput
>
();
let
services
=
new
ServiceCollection
();
...
...
@@ -350,6 +352,10 @@ export class TestEditorGroupService implements IEditorGroupService {
return
this
.
_onEditorsMoved
.
event
;
}
public
get
onGroupOrientationChanged
():
Event
<
void
>
{
return
this
.
_onGroupOrientationChanged
.
event
;
}
public
focusGroup
(
group
:
IEditorGroup
):
void
;
public
focusGroup
(
position
:
Position
):
void
;
public
focusGroup
(
arg1
:
any
):
void
{
...
...
src/vs/workbench/browser/actions/toggleEditorLayout.ts
浏览文件 @
c038219f
...
...
@@ -33,12 +33,19 @@ export class ToggleEditorLayoutAction extends Action {
this
.
class
=
'
toggle-editor-layout
'
;
this
.
updateEnablement
();
this
.
updateLabel
();
this
.
registerListeners
();
}
private
registerListeners
():
void
{
this
.
toDispose
.
push
(
this
.
editorGroupService
.
onEditorsChanged
(()
=>
this
.
updateEnablement
()));
this
.
toDispose
.
push
(
this
.
editorGroupService
.
onGroupOrientationChanged
(()
=>
this
.
updateLabel
()));
}
private
updateLabel
():
void
{
const
editorGroupLayoutVertical
=
(
this
.
editorGroupService
.
getGroupOrientation
()
!==
'
horizontal
'
);
this
.
label
=
editorGroupLayoutVertical
?
nls
.
localize
(
'
horizontalLayout
'
,
"
Horizontal Editor Group Layout
"
)
:
nls
.
localize
(
'
verticalLayout
'
,
"
Vertical Editor Group Layout
"
);
}
private
updateEnablement
():
void
{
...
...
src/vs/workbench/browser/layout.ts
浏览文件 @
c038219f
...
...
@@ -18,7 +18,6 @@ import { IThemeService } from 'vs/workbench/services/themes/common/themeService'
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IWorkbenchEditorConfiguration
}
from
'
vs/workbench/common/editor
'
;
const
DEFAULT_MIN_SIDEBAR_PART_WIDTH
=
170
;
const
DEFAULT_MIN_PANEL_PART_HEIGHT
=
77
;
...
...
@@ -82,7 +81,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
private
startPanelHeight
:
number
;
private
panelHeight
:
number
;
private
panelWidth
:
number
;
private
layoutEditorsVertically
:
boolean
;
private
layoutEditor
Group
sVertically
:
boolean
;
// Take parts as an object bag since instatation service does not have typings for constructors with 9+ arguments
constructor
(
...
...
@@ -101,7 +100,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
@
IEventService
eventService
:
IEventService
,
@
IContextViewService
private
contextViewService
:
IContextViewService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IEditorGroupService
private
editorGroupService
:
IEditorGroupService
,
@
IPartService
private
partService
:
IPartService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IViewletService
private
viewletService
:
IViewletService
,
...
...
@@ -131,11 +130,11 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
this
.
sidebarWidth
=
this
.
storageService
.
getInteger
(
WorkbenchLayout
.
sashXWidthSettingsKey
,
StorageScope
.
GLOBAL
,
-
1
);
this
.
panelHeight
=
this
.
storageService
.
getInteger
(
WorkbenchLayout
.
sashYHeightSettingsKey
,
StorageScope
.
GLOBAL
,
0
);
this
.
onDidUpdateConfiguration
(
configurationService
.
getConfiguration
<
IWorkbenchEditorConfiguration
>
(),
false
);
this
.
layoutEditorGroupsVertically
=
(
this
.
editorGroupService
.
getGroupOrientation
()
!==
'
horizontal
'
);
this
.
toUnbind
.
push
(
themeService
.
onDidColorThemeChange
(
_
=>
this
.
relayout
()));
this
.
toUnbind
.
push
(
editorGroupService
.
onEditorsChanged
(()
=>
this
.
onEditorsChanged
()));
this
.
toUnbind
.
push
(
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onDidUpdateConfiguration
(
e
.
config
,
true
)));
this
.
toUnbind
.
push
(
editorGroupService
.
onGroupOrientationChanged
(
e
=>
this
.
onGroupOrientationChanged
(
)));
this
.
registerSashListeners
();
}
...
...
@@ -264,8 +263,8 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
if
(
this
.
workbenchSize
&&
(
this
.
sidebarWidth
||
this
.
panelHeight
))
{
let
visibleEditors
=
this
.
editorService
.
getVisibleEditors
().
length
;
if
(
visibleEditors
>
1
)
{
const
sidebarOverflow
=
this
.
layoutEditorsVertically
&&
(
this
.
workbenchSize
.
width
-
this
.
sidebarWidth
<
visibleEditors
*
DEFAULT_MIN_EDITOR_PART_WIDTH
);
const
panelOverflow
=
!
this
.
layoutEditorsVertically
&&
(
this
.
workbenchSize
.
height
-
this
.
panelHeight
<
visibleEditors
*
DEFAULT_MIN_EDITOR_PART_HEIGHT
);
const
sidebarOverflow
=
this
.
layoutEditor
Group
sVertically
&&
(
this
.
workbenchSize
.
width
-
this
.
sidebarWidth
<
visibleEditors
*
DEFAULT_MIN_EDITOR_PART_WIDTH
);
const
panelOverflow
=
!
this
.
layoutEditor
Group
sVertically
&&
(
this
.
workbenchSize
.
height
-
this
.
panelHeight
<
visibleEditors
*
DEFAULT_MIN_EDITOR_PART_HEIGHT
);
if
(
sidebarOverflow
||
panelOverflow
)
{
this
.
layout
();
...
...
@@ -274,16 +273,11 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
}
}
private
onDidUpdateConfiguration
(
config
:
IWorkbenchEditorConfiguration
,
relayout
:
boolean
):
void
{
let
newLayoutEditorsVertically
:
boolean
;
if
(
config
.
workbench
&&
config
.
workbench
.
editor
)
{
newLayoutEditorsVertically
=
(
config
.
workbench
.
editor
.
sideBySideLayout
!==
'
horizontal
'
);
}
else
{
newLayoutEditorsVertically
=
true
;
}
private
onGroupOrientationChanged
():
void
{
const
newLayoutEditorGroupsVertically
=
(
this
.
editorGroupService
.
getGroupOrientation
()
!==
'
horizontal
'
);
const
doLayout
=
relayout
&&
(
this
.
layoutEditorsVertically
!==
newLayoutEditorsVertically
)
;
this
.
layoutEditor
sVertically
=
newLayoutEditor
sVertically
;
const
doLayout
=
this
.
layoutEditorGroupsVertically
!==
newLayoutEditorGroupsVertically
;
this
.
layoutEditor
GroupsVertically
=
newLayoutEditorGroup
sVertically
;
if
(
doLayout
)
{
this
.
layout
();
...
...
@@ -417,7 +411,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
let
editorMinHeight
=
this
.
computedStyles
.
editor
.
minHeight
;
let
visibleEditorCount
=
this
.
editorService
.
getVisibleEditors
().
length
;
if
(
visibleEditorCount
>
1
)
{
if
(
this
.
layoutEditorsVertically
)
{
if
(
this
.
layoutEditor
Group
sVertically
)
{
editorMinWidth
*=
visibleEditorCount
;
// when editors layout vertically, multiply the min editor width by number of visible editors
}
else
{
editorMinHeight
*=
visibleEditorCount
;
// when editors layout horizontally, multiply the min editor height by number of visible editors
...
...
src/vs/workbench/browser/parts/editor/editorActions.ts
浏览文件 @
c038219f
...
...
@@ -16,7 +16,6 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
import
{
Position
,
IEditor
,
Direction
,
IResourceInput
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IEditorGroupService
,
GroupArrangement
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
...
...
@@ -412,7 +411,7 @@ export class OpenToSideAction extends Action {
constructor
(
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
I
ConfigurationService
private
configurationService
:
IConfiguration
Service
@
I
EditorGroupService
private
editorGroupService
:
IEditorGroup
Service
)
{
super
(
OpenToSideAction
.
OPEN_TO_SIDE_ID
,
OpenToSideAction
.
OPEN_TO_SIDE_LABEL
);
...
...
@@ -421,9 +420,9 @@ export class OpenToSideAction extends Action {
}
public
updateClass
():
void
{
const
editor
LayoutVertical
=
this
.
configurationService
.
lookup
(
'
workbench.editor.sideBySideLayout
'
).
value
!==
'
horizontal
'
;
const
editor
GroupLayoutVertical
=
(
this
.
editorGroupService
.
getGroupOrientation
()
!==
'
horizontal
'
)
;
this
.
class
=
editorLayoutVertical
?
'
quick-open-sidebyside-vertical
'
:
'
quick-open-sidebyside-horizontal
'
;
this
.
class
=
editor
Group
LayoutVertical
?
'
quick-open-sidebyside-vertical
'
:
'
quick-open-sidebyside-horizontal
'
;
}
private
updateEnablement
():
void
{
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
c038219f
...
...
@@ -86,11 +86,11 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
private
memento
:
any
;
private
stacks
:
EditorStacksModel
;
private
previewEditors
:
boolean
;
private
layoutVertically
:
boolean
;
private
_onEditorsChanged
:
Emitter
<
void
>
;
private
_onEditorsMoved
:
Emitter
<
void
>
;
private
_onEditorOpenFail
:
Emitter
<
EditorInput
>
;
private
_onGroupOrientationChanged
:
Emitter
<
void
>
;
// The following data structures are partitioned into array of Position as provided by Services.POSITION array
private
visibleEditors
:
BaseEditor
[];
...
...
@@ -115,6 +115,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this
.
_onEditorsChanged
=
new
Emitter
<
void
>
();
this
.
_onEditorsMoved
=
new
Emitter
<
void
>
();
this
.
_onEditorOpenFail
=
new
Emitter
<
EditorInput
>
();
this
.
_onGroupOrientationChanged
=
new
Emitter
<
void
>
();
this
.
visibleEditors
=
[];
...
...
@@ -134,7 +135,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
const
editorConfig
=
config
.
workbench
.
editor
;
this
.
previewEditors
=
editorConfig
.
enablePreview
;
this
.
layoutVertically
=
editorConfig
.
sideBySideLayout
!==
'
horizontal
'
;
this
.
telemetryService
.
publicLog
(
'
workbenchEditorConfiguration
'
,
editorConfig
);
}
...
...
@@ -161,14 +161,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
}
});
}
this
.
previewEditors
=
newPreviewEditors
;
// Rename groups when layout changes
const
newLayoutVertically
=
editorConfig
.
sideBySideLayout
!==
'
horizontal
'
;
if
(
newLayoutVertically
!==
this
.
layoutVertically
)
{
this
.
layoutVertically
=
newLayoutVertically
;
this
.
renameGroups
();
}
this
.
previewEditors
=
newPreviewEditors
;
}
}
...
...
@@ -195,6 +189,10 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return
this
.
_onEditorOpenFail
.
event
;
}
public
get
onGroupOrientationChanged
():
Event
<
void
>
{
return
this
.
_onGroupOrientationChanged
.
event
;
}
public
openEditor
(
input
:
EditorInput
,
options
?:
EditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
BaseEditor
>
;
public
openEditor
(
input
:
EditorInput
,
options
?:
EditorOptions
,
position
?:
Position
,
ratio
?:
number
[]):
TPromise
<
BaseEditor
>
;
public
openEditor
(
input
:
EditorInput
,
options
?:
EditorOptions
,
arg3
?:
any
,
ratio
?:
number
[]):
TPromise
<
BaseEditor
>
{
...
...
@@ -806,6 +804,10 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
public
setGroupOrientation
(
orientation
:
GroupOrientation
):
void
{
this
.
sideBySideControl
.
setGroupOrientation
(
orientation
);
this
.
_onGroupOrientationChanged
.
fire
();
// Rename groups when layout changes
this
.
renameGroups
();
}
public
getGroupOrientation
():
GroupOrientation
{
...
...
@@ -1352,23 +1354,24 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
private
renameGroups
():
void
{
const
groups
=
this
.
stacks
.
groups
;
if
(
groups
.
length
>
0
)
{
const
layoutVertically
=
(
this
.
sideBySideControl
.
getGroupOrientation
()
!==
'
horizontal
'
);
// ONE | TWO | THREE
if
(
groups
.
length
>
2
)
{
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
ONE
),
this
.
layoutVertically
?
EditorPart
.
GROUP_LEFT
:
EditorPart
.
GROUP_TOP
);
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
TWO
),
this
.
layoutVertically
?
EditorPart
.
GROUP_CENTER
:
EditorPart
.
GROUP_MIDDLE
);
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
THREE
),
this
.
layoutVertically
?
EditorPart
.
GROUP_RIGHT
:
EditorPart
.
GROUP_BOTTOM
);
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
ONE
),
layoutVertically
?
EditorPart
.
GROUP_LEFT
:
EditorPart
.
GROUP_TOP
);
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
TWO
),
layoutVertically
?
EditorPart
.
GROUP_CENTER
:
EditorPart
.
GROUP_MIDDLE
);
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
THREE
),
layoutVertically
?
EditorPart
.
GROUP_RIGHT
:
EditorPart
.
GROUP_BOTTOM
);
}
// ONE | TWO
else
if
(
groups
.
length
>
1
)
{
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
ONE
),
this
.
layoutVertically
?
EditorPart
.
GROUP_LEFT
:
EditorPart
.
GROUP_TOP
);
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
TWO
),
this
.
layoutVertically
?
EditorPart
.
GROUP_RIGHT
:
EditorPart
.
GROUP_BOTTOM
);
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
ONE
),
layoutVertically
?
EditorPart
.
GROUP_LEFT
:
EditorPart
.
GROUP_TOP
);
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
TWO
),
layoutVertically
?
EditorPart
.
GROUP_RIGHT
:
EditorPart
.
GROUP_BOTTOM
);
}
// ONE
else
{
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
ONE
),
this
.
layoutVertically
?
EditorPart
.
GROUP_LEFT
:
EditorPart
.
GROUP_TOP
);
this
.
stacks
.
renameGroup
(
this
.
stacks
.
groupAt
(
Position
.
ONE
),
layoutVertically
?
EditorPart
.
GROUP_LEFT
:
EditorPart
.
GROUP_TOP
);
}
}
}
...
...
src/vs/workbench/services/group/common/groupService.ts
浏览文件 @
c038219f
...
...
@@ -41,6 +41,11 @@ export interface IEditorGroupService {
*/
onEditorsMoved
:
Event
<
void
>
;
/**
* Emitted when the editor group orientation was changed.
*/
onGroupOrientationChanged
:
Event
<
void
>
;
/**
* Keyboard focus the editor group at the provided position.
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录