Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b7ee78d6
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,发现更多精彩内容 >>
提交
b7ee78d6
编写于
6月 18, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tabs bugfixing and polish
上级
d7f953f5
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
184 addition
and
123 deletion
+184
-123
src/typings/electron.d.ts
src/typings/electron.d.ts
+2
-1
src/vs/workbench/browser/parts/editor/editorActions.ts
src/vs/workbench/browser/parts/editor/editorActions.ts
+32
-0
src/vs/workbench/browser/parts/editor/media/sidebyside.css
src/vs/workbench/browser/parts/editor/media/sidebyside.css
+0
-1
src/vs/workbench/browser/parts/editor/media/tabstitle.css
src/vs/workbench/browser/parts/editor/media/tabstitle.css
+11
-12
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
...workbench/browser/parts/editor/sideBySideEditorControl.ts
+79
-36
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
+17
-7
src/vs/workbench/browser/parts/editor/titleControl.ts
src/vs/workbench/browser/parts/editor/titleControl.ts
+31
-60
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+11
-5
src/vs/workbench/services/contextview/electron-browser/contextmenuService.ts
...rvices/contextview/electron-browser/contextmenuService.ts
+1
-1
未找到文件。
src/typings/electron.d.ts
浏览文件 @
b7ee78d6
...
...
@@ -838,8 +838,9 @@ declare module Electron {
* at the current mouse cursor position.
* @param x Horizontal coordinate where the menu will be placed.
* @param y Vertical coordinate where the menu will be placed.
* @param positioningItem The item to select by default.
*/
popup
(
browserWindow
:
BrowserWindow
,
x
?:
number
,
y
?:
number
):
void
;
popup
(
browserWindow
:
BrowserWindow
,
x
?:
number
,
y
?:
number
,
positioningItem
?:
number
):
void
;
/**
* Appends the menuItem to the menu.
*/
...
...
src/vs/workbench/browser/parts/editor/editorActions.ts
浏览文件 @
b7ee78d6
...
...
@@ -970,6 +970,38 @@ export class ShowEditorsInRightGroupAction extends QuickOpenAction {
}
}
export
class
ShowEditorsInGroupAction
extends
Action
{
public
static
ID
=
'
workbench.action.showEditorsInGroup
'
;
public
static
LABEL
=
nls
.
localize
(
'
showEditorsInGroup
'
,
"
Show Editors in Group
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IQuickOpenService
private
quickOpenService
:
IQuickOpenService
,
@
IEditorGroupService
private
editorGroupService
:
IEditorGroupService
)
{
super
(
id
,
label
);
}
public
run
(
context
?:
IEditorContext
):
TPromise
<
any
>
{
const
stacks
=
this
.
editorGroupService
.
getStacksModel
();
const
groupCount
=
stacks
.
groups
.
length
;
if
(
groupCount
<=
1
||
!
context
)
{
return
this
.
quickOpenService
.
show
(
NAVIGATE_ALL_EDITORS_GROUP_PREFIX
);
}
switch
(
stacks
.
positionOfGroup
(
context
.
group
))
{
case
Position
.
CENTER
:
return
this
.
quickOpenService
.
show
((
groupCount
===
2
)
?
NAVIGATE_IN_RIGHT_GROUP_PREFIX
:
NAVIGATE_IN_CENTER_GROUP_PREFIX
);
case
Position
.
RIGHT
:
return
this
.
quickOpenService
.
show
(
NAVIGATE_IN_RIGHT_GROUP_PREFIX
);
}
return
this
.
quickOpenService
.
show
(
NAVIGATE_IN_LEFT_GROUP_PREFIX
);
}
}
export
const
NAVIGATE_ALL_EDITORS_GROUP_PREFIX
=
'
edt
'
;
export
class
ShowAllEditorsAction
extends
QuickOpenAction
{
...
...
src/vs/workbench/browser/parts/editor/media/sidebyside.css
浏览文件 @
b7ee78d6
...
...
@@ -16,7 +16,6 @@
position
:
absolute
;
left
:
0
;
width
:
100%
;
height
:
100%
;
z-index
:
3000000
;
}
...
...
src/vs/workbench/browser/parts/editor/media/tabstitle.css
浏览文件 @
b7ee78d6
...
...
@@ -11,11 +11,14 @@
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container
{
display
:
flex
;
/*overflow: scroll;*/
background-color
:
rgba
(
128
,
128
,
128
,
0.2
);
height
:
35px
;
}
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container.scroll
{
overflow
:
scroll
!important
;
}
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container
::-webkit-scrollbar
{
display
:
none
;
}
...
...
@@ -36,10 +39,6 @@
padding-left
:
10px
;
}
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container
>
.tab
:focus
{
outline-offset
:
-2px
;
}
.hc-black
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title.active
.tabs-container
>
.tab.active
{
border
:
1px
solid
#f38518
;
}
...
...
@@ -49,15 +48,19 @@
}
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container
>
.tab.active
{
border-bottom
:
0
;
border-bottom
-color
:
transparent
;
opacity
:
1
!important
;
}
.vs
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container.dropfeedback
,
.vs
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container
>
.tab.dropfeedback
{
.vs
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container.dropfeedback
{
background-color
:
rgba
(
51
,
153
,
255
,
0.18
);
}
.vs
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container
>
.tab.dropfeedback
{
background-color
:
rgba
(
187
,
230
,
255
,
0.5
);
opacity
:
1
!important
;
}
.vs-dark
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container.dropfeedback
,
.vs-dark
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container
>
.tab.dropfeedback
{
background-color
:
rgba
(
83
,
89
,
93
,
0.5
);
...
...
@@ -70,10 +73,6 @@
outline-offset
:
-2px
;
}
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.tabs-container
>
.tab.dragged
{
opacity
:
0.7
!important
;
}
/* Tab Close */
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
.title
.tabs-container
>
.tab
>
.tab-close
{
...
...
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
浏览文件 @
b7ee78d6
...
...
@@ -758,6 +758,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
const
$this
=
this
;
const
overlayId
=
'
monaco-workbench-editor-drop-overlay
'
;
const
splitToPropertyKey
=
'
splitToPosition
'
;
const
stacks
=
this
.
editorGroupService
.
getStacksModel
();
let
overlay
:
Builder
;
function
onDrop
(
e
:
DragEvent
,
position
:
Position
,
splitTo
?:
Position
):
void
{
...
...
@@ -766,7 +767,6 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
const
editorService
=
$this
.
editorService
;
const
groupService
=
$this
.
editorGroupService
;
const
stacks
=
groupService
.
getStacksModel
();
const
splitEditor
=
(
typeof
splitTo
===
'
number
'
);
// TODO@Ben ugly split code should benefit from empty group support once available!
const
freeGroup
=
(
stacks
.
groups
.
length
===
1
)
?
Position
.
CENTER
:
Position
.
RIGHT
;
...
...
@@ -784,7 +784,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
if
(
splitTo
!==
freeGroup
)
{
groupService
.
moveGroup
(
freeGroup
,
splitTo
);
}
});
})
.
done
(
null
,
errors
.
onUnexpectedError
)
;
}
else
{
editorService
.
openEditor
(
draggedEditor
.
editor
,
pinned
,
position
).
done
(
null
,
errors
.
onUnexpectedError
);
}
...
...
@@ -794,12 +794,17 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
else
{
const
sourcePosition
=
stacks
.
positionOfGroup
(
draggedEditor
.
group
);
if
(
splitEditor
)
{
if
(
draggedEditor
.
group
.
count
===
1
)
{
groupService
.
moveGroup
(
sourcePosition
,
splitTo
);
}
else
{
editorService
.
openEditor
(
draggedEditor
.
editor
,
pinned
,
freeGroup
).
then
(()
=>
{
if
(
splitTo
!==
freeGroup
)
{
groupService
.
moveGroup
(
freeGroup
,
splitTo
);
}
groupService
.
moveEditor
(
draggedEditor
.
editor
,
stacks
.
positionOfGroup
(
draggedEditor
.
group
),
splitTo
);
});
}).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
else
{
groupService
.
moveEditor
(
draggedEditor
.
editor
,
sourcePosition
,
position
);
}
...
...
@@ -840,38 +845,70 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
const
overlayWidth
=
target
.
clientWidth
;
const
splitThreshold
=
overlayIsSplit
?
overlayWidth
/
5
:
overlayWidth
/
10
;
const
isCopy
=
(
e
.
ctrlKey
&&
!
isMacintosh
)
||
(
e
.
altKey
&&
isMacintosh
);
const
draggedEditor
=
TitleControl
.
getDraggedEditor
();
const
isOverSplitLeft
=
posXOnOverlay
<
splitThreshold
;
const
isOverSplitRight
=
posXOnOverlay
+
splitThreshold
>
overlayWidth
;
let
allowSplit
=
true
;
let
splitTarget
:
Position
;
// No splitting if we reached maximum group count
if
(
groups
===
POSITIONS
.
length
)
{
allowSplit
=
false
;
// do not show split feedback when we already at the maximum
splitTarget
=
null
;
}
const
draggedEditor
=
TitleControl
.
getDraggedEditor
();
if
(
!
isCopy
&&
draggedEditor
&&
draggedEditor
.
group
.
count
===
1
)
{
allowSplit
=
false
;
// do not show split feedback when moving the only one editor of a group
// Special splitting if we drag an editor of a group with only one editor
else
if
(
!
isCopy
&&
draggedEditor
&&
draggedEditor
.
group
.
count
===
1
)
{
const
positionOfDraggedEditor
=
stacks
.
positionOfGroup
(
draggedEditor
.
group
);
switch
(
positionOfDraggedEditor
)
{
case
Position
.
LEFT
:
if
(
position
===
Position
.
CENTER
&&
isOverSplitRight
)
{
splitTarget
=
Position
.
CENTER
;
// allow to move single editor from LEFT to CENTER
}
break
;
case
Position
.
CENTER
:
if
(
position
===
Position
.
LEFT
&&
isOverSplitLeft
)
{
splitTarget
=
Position
.
LEFT
;
// allow to move single editor from CENTER to LEFT
}
break
;
default
:
splitTarget
=
null
;
// splitting not allowed
}
}
// Any other case, check for mouse position
else
{
if
(
isOverSplitRight
)
{
splitTarget
=
(
position
===
Position
.
LEFT
)
?
Position
.
CENTER
:
Position
.
RIGHT
;
}
else
if
(
isOverSplitLeft
)
{
splitTarget
=
(
position
===
Position
.
LEFT
)
?
Position
.
LEFT
:
Position
.
CENTER
;
}
}
// Apply split target
const
canSplit
=
(
typeof
splitTarget
===
'
number
'
);
if
(
canSplit
)
{
overlay
.
setProperty
(
splitToPropertyKey
,
splitTarget
);
}
else
{
overlay
.
removeProperty
(
splitToPropertyKey
);
}
// Compute split decoration
if
(
allowSplit
)
{
if
(
posXOnOverlay
+
splitThreshold
>
overlayWidth
)
{
overlay
.
setProperty
(
splitToPropertyKey
,
position
===
Position
.
LEFT
?
Position
.
CENTER
:
Position
.
RIGHT
);
// Update overlay styles
if
(
canSplit
&&
isOverSplitRight
)
{
overlay
.
style
({
left
:
'
50%
'
,
width
:
'
50%
'
,
});
}
else
if
(
posXOnOverlay
<
splitThreshold
)
{
overlay
.
setProperty
(
splitToPropertyKey
,
position
===
Position
.
LEFT
?
Position
.
LEFT
:
Position
.
CENTER
);
}
else
if
(
canSplit
&&
isOverSplitLeft
)
{
overlay
.
style
({
width
:
'
50%
'
});
}
else
{
overlay
.
removeProperty
(
splitToPropertyKey
);
overlay
.
style
({
left
:
'
0
'
,
width
:
'
100%
'
});
}
}
// Make sure the overlay is visible
overlay
.
style
({
opacity
:
1
});
...
...
@@ -885,7 +922,8 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
const
useTabs
=
!!
$this
.
configurationService
.
getConfiguration
<
IWorkbenchEditorConfiguration
>
().
workbench
.
editor
.
showTabs
;
overlay
=
$
(
'
div
'
).
style
({
top
:
useTabs
?
SideBySideEditorControl
.
EDITOR_TITLE_HEIGHT
+
'
px
'
:
0
top
:
useTabs
?
SideBySideEditorControl
.
EDITOR_TITLE_HEIGHT
+
'
px
'
:
0
,
height
:
useTabs
?
`calc(100% -
${
SideBySideEditorControl
.
EDITOR_TITLE_HEIGHT
}
px`
:
'
100%
'
}).
id
(
overlayId
);
overlay
.
appendTo
(
container
);
...
...
@@ -976,7 +1014,8 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
// Overlay the editor area with a div to be able to capture all mouse events
let
overlayDiv
=
$
(
'
div
'
).
style
({
top
:
SideBySideEditorControl
.
EDITOR_TITLE_HEIGHT
+
'
px
'
top
:
SideBySideEditorControl
.
EDITOR_TITLE_HEIGHT
+
'
px
'
,
height
:
'
100%
'
}).
id
(
'
monaco-workbench-editor-move-overlay
'
);
overlayDiv
.
appendTo
(
this
.
parent
);
...
...
@@ -1122,8 +1161,12 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
// Move to valid position if any
if
(
moveTo
!==
null
)
{
this
.
editorGroupService
.
moveGroup
(
position
,
moveTo
);
this
.
titleAreaControl
[
position
].
refresh
(
true
);
this
.
titleAreaControl
[
moveTo
].
refresh
(
true
);
// To reduce flickering during this operation we trigger a refresh of all
// title controls right after.
POSITIONS
.
forEach
(
p
=>
{
this
.
titleAreaControl
[
p
].
refresh
(
true
);
});
}
// Otherwise layout to restore proper positioning
...
...
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
浏览文件 @
b7ee78d6
...
...
@@ -78,6 +78,14 @@ export class TabsTitleControl extends TitleControl {
this
.
tabsContainer
.
setAttribute
(
'
role
'
,
'
tablist
'
);
DOM
.
addClass
(
this
.
tabsContainer
,
'
tabs-container
'
);
this
.
toDispose
.
push
(
DOM
.
addDisposableListener
(
this
.
tabsContainer
,
DOM
.
EventType
.
SCROLL
,
e
=>
{
if
(
DOM
.
hasClass
(
this
.
tabsContainer
,
'
scroll
'
))
{
this
.
scrollbar
.
updateState
({
scrollLeft
:
this
.
tabsContainer
.
scrollLeft
// during DND the container gets scrolled so we need to update the custom scrollbar
});
}
}));
// Custom Scrollbar
this
.
scrollbar
=
new
ScrollableElement
(
this
.
tabsContainer
,
{
horizontal
:
ScrollbarVisibility
.
Auto
,
...
...
@@ -87,7 +95,6 @@ export class TabsTitleControl extends TitleControl {
canUseTranslate3d
:
true
,
horizontalScrollbarSize
:
3
});
// this.tabsContainer.style.overflow = 'scroll'; // custom scrollbar is eager on removing this style but we want it for DND scroll feedback
this
.
scrollbar
.
onScroll
(
e
=>
{
this
.
tabsContainer
.
scrollLeft
=
e
.
scrollLeft
;
...
...
@@ -97,6 +104,8 @@ export class TabsTitleControl extends TitleControl {
// Drag over
this
.
toDispose
.
push
(
DOM
.
addDisposableListener
(
this
.
tabsContainer
,
DOM
.
EventType
.
DRAG_OVER
,
(
e
:
DragEvent
)
=>
{
DOM
.
addClass
(
this
.
tabsContainer
,
'
scroll
'
);
// enable support to scroll while dragging
const
target
=
e
.
target
;
if
(
target
instanceof
HTMLElement
&&
target
.
className
.
indexOf
(
'
tabs-container
'
)
===
0
)
{
DOM
.
addClass
(
this
.
tabsContainer
,
'
dropfeedback
'
);
...
...
@@ -106,16 +115,19 @@ export class TabsTitleControl extends TitleControl {
// Drag leave
this
.
toDispose
.
push
(
DOM
.
addDisposableListener
(
this
.
tabsContainer
,
DOM
.
EventType
.
DRAG_LEAVE
,
(
e
:
DragEvent
)
=>
{
DOM
.
removeClass
(
this
.
tabsContainer
,
'
dropfeedback
'
);
DOM
.
removeClass
(
this
.
tabsContainer
,
'
scroll
'
);
}));
// Drag end
this
.
toDispose
.
push
(
DOM
.
addDisposableListener
(
this
.
tabsContainer
,
DOM
.
EventType
.
DRAG_END
,
(
e
:
DragEvent
)
=>
{
DOM
.
removeClass
(
this
.
tabsContainer
,
'
dropfeedback
'
);
DOM
.
removeClass
(
this
.
tabsContainer
,
'
scroll
'
);
}));
// Drop onto tabs container
this
.
toDispose
.
push
(
DOM
.
addDisposableListener
(
this
.
tabsContainer
,
DOM
.
EventType
.
DROP
,
(
e
:
DragEvent
)
=>
{
DOM
.
removeClass
(
this
.
tabsContainer
,
'
dropfeedback
'
);
DOM
.
removeClass
(
this
.
tabsContainer
,
'
scroll
'
);
const
target
=
e
.
target
;
if
(
target
instanceof
HTMLElement
&&
target
.
className
.
indexOf
(
'
tabs-container
'
)
===
0
)
{
...
...
@@ -339,10 +351,7 @@ export class TabsTitleControl extends TitleControl {
// Update enablement of certain actions that depend on overflow
const
isOverflowing
=
(
totalContainerWidth
>
visibleContainerWidth
);
this
.
showEditorsOfLeftGroup
.
enabled
=
isOverflowing
;
this
.
showEditorsOfCenterGroup
.
enabled
=
isOverflowing
;
this
.
showEditorsOfRightGroup
.
enabled
=
isOverflowing
;
this
.
showAllEditorsAction
.
enabled
=
isOverflowing
;
this
.
showEditorsInGroupAction
.
enabled
=
isOverflowing
;
}
private
hookTabListeners
(
tab
:
HTMLElement
,
identifier
:
IEditorIdentifier
):
void
{
...
...
@@ -420,7 +429,6 @@ export class TabsTitleControl extends TitleControl {
// Drag start
this
.
tabDisposeables
.
push
(
DOM
.
addDisposableListener
(
tab
,
DOM
.
EventType
.
DRAG_START
,
(
e
:
DragEvent
)
=>
{
DOM
.
addClass
(
tab
,
'
dragged
'
);
this
.
onEditorDragStart
({
editor
,
group
});
e
.
dataTransfer
.
effectAllowed
=
'
copyMove
'
;
...
...
@@ -443,13 +451,15 @@ export class TabsTitleControl extends TitleControl {
// Drag end
this
.
tabDisposeables
.
push
(
DOM
.
addDisposableListener
(
tab
,
DOM
.
EventType
.
DRAG_END
,
(
e
:
DragEvent
)
=>
{
DOM
.
removeClass
(
tab
,
'
dragged
'
);
DOM
.
removeClass
(
tab
,
'
dropfeedback
'
);
this
.
onEditorDragEnd
();
}));
// Drop
this
.
tabDisposeables
.
push
(
DOM
.
addDisposableListener
(
tab
,
DOM
.
EventType
.
DROP
,
(
e
:
DragEvent
)
=>
{
DOM
.
removeClass
(
tab
,
'
dropfeedback
'
);
const
targetPosition
=
this
.
stacks
.
positionOfGroup
(
group
);
const
targetIndex
=
group
.
indexOf
(
editor
);
...
...
src/vs/workbench/browser/parts/editor/titleControl.ts
浏览文件 @
b7ee78d6
...
...
@@ -15,7 +15,7 @@ import DOM = require('vs/base/browser/dom');
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
BaseEditor
,
IEditorInputActionContext
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
IEditorStacksModel
,
IEditorGroup
,
IEditorIdentifier
,
EditorInput
,
IWorkbenchEditorConfiguration
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditorStacksModel
,
IEditorGroup
,
IEditorIdentifier
,
EditorInput
,
IWorkbenchEditorConfiguration
,
IStacksModelChangeEvent
}
from
'
vs/workbench/common/editor
'
;
import
{
EventType
as
BaseEventType
}
from
'
vs/base/common/events
'
;
import
{
IActionItem
,
ActionsOrientation
,
Separator
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
...
...
@@ -25,14 +25,11 @@ import {Position} from 'vs/platform/editor/common/editor';
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IMessageService
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
QuickOpenAction
}
from
'
vs/workbench/browser/quickopen
'
;
import
{
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
ShowEditorsInLeftGroupAction
,
ShowAllEditorsAction
,
ShowEditorsInCenterGroupAction
,
ShowEditorsInRightGroupAction
,
CloseEditorsInGroupAction
,
MoveGroupLeftAction
,
MoveGroupRightAction
,
SplitEditorAction
,
CloseEditorAction
,
KeepEditorAction
,
CloseOtherEditorsInGroupAction
,
CloseRightEditorsInGroupAction
}
from
'
vs/workbench/browser/parts/editor/editorActions
'
;
import
{
CloseEditorsInGroupAction
,
MoveGroupLeftAction
,
MoveGroupRightAction
,
SplitEditorAction
,
CloseEditorAction
,
KeepEditorAction
,
CloseOtherEditorsInGroupAction
,
CloseRightEditorsInGroupAction
,
ShowEditorsInGroupAction
}
from
'
vs/workbench/browser/parts/editor/editorActions
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
export
interface
IToolbarActions
{
...
...
@@ -62,14 +59,11 @@ export abstract class TitleControl {
protected
pinEditorAction
:
KeepEditorAction
;
protected
closeOtherEditorsAction
:
CloseOtherEditorsInGroupAction
;
protected
closeRightEditorsAction
:
CloseRightEditorsInGroupAction
;
protected
showEditorsOfLeftGroup
:
QuickOpenAction
;
protected
showEditorsOfCenterGroup
:
QuickOpenAction
;
protected
showEditorsOfRightGroup
:
QuickOpenAction
;
protected
moveGroupLeftAction
:
MoveGroupLeftAction
;
protected
moveGroupRightAction
:
MoveGroupRightAction
;
protected
closeEditorsInGroupAction
:
CloseEditorsInGroupAction
;
protected
splitEditorAction
:
SplitEditorAction
;
protected
show
AllEditorsAction
:
ShowAllEditors
Action
;
protected
show
EditorsInGroupAction
:
ShowEditorsInGroup
Action
;
private
previewEditors
:
boolean
;
private
showTabs
:
boolean
;
...
...
@@ -115,6 +109,13 @@ export abstract class TitleControl {
private
registerListeners
():
void
{
this
.
toDispose
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationUpdated
(
e
.
config
)));
this
.
toDispose
.
push
(
this
.
stacks
.
onModelChanged
(
e
=>
this
.
onStacksChanged
(
e
)));
}
private
onStacksChanged
(
e
:
IStacksModelChangeEvent
):
void
{
if
(
e
.
structural
)
{
this
.
updateSplitActionEnablement
();
}
}
private
onConfigurationUpdated
(
config
:
IWorkbenchEditorConfiguration
):
void
{
...
...
@@ -122,37 +123,18 @@ export abstract class TitleControl {
this
.
showTabs
=
config
.
workbench
.
editor
.
showTabs
;
}
private
updateActionEnablement
():
void
{
private
update
Split
ActionEnablement
():
void
{
if
(
!
this
.
context
)
{
return
;
}
const
group
=
this
.
context
;
const
groupCount
=
this
.
stacks
.
groups
.
length
;
// Move group
switch
(
this
.
stacks
.
positionOfGroup
(
group
))
{
case
Position
.
LEFT
:
this
.
moveGroupLeftAction
.
enabled
=
false
;
this
.
moveGroupRightAction
.
enabled
=
this
.
stacks
.
groups
.
length
>
1
;
break
;
case
Position
.
CENTER
:
this
.
moveGroupRightAction
.
enabled
=
this
.
stacks
.
groups
.
length
>
2
;
break
;
case
Position
.
RIGHT
:
this
.
moveGroupRightAction
.
enabled
=
false
;
break
;
}
// Split editor
this
.
splitEditorAction
.
enabled
=
groupCount
<
3
;
}
private
onSchedule
():
void
{
this
.
updateActionEnablement
();
if
(
this
.
refreshScheduled
)
{
this
.
doRefresh
();
}
else
{
...
...
@@ -206,15 +188,12 @@ export abstract class TitleControl {
this
.
closeRightEditorsAction
=
this
.
instantiationService
.
createInstance
(
CloseRightEditorsInGroupAction
,
CloseRightEditorsInGroupAction
.
ID
,
nls
.
localize
(
'
closeRight
'
,
"
Close to the Right
"
));
this
.
closeEditorsInGroupAction
=
this
.
instantiationService
.
createInstance
(
CloseEditorsInGroupAction
,
CloseEditorsInGroupAction
.
ID
,
nls
.
localize
(
'
closeAll
'
,
"
Close All
"
));
this
.
pinEditorAction
=
this
.
instantiationService
.
createInstance
(
KeepEditorAction
,
KeepEditorAction
.
ID
,
nls
.
localize
(
'
keepEditor
'
,
"
Keep Editor
"
));
this
.
show
AllEditorsAction
=
this
.
instantiationService
.
createInstance
(
ShowAllEditorsAction
,
ShowAllEditorsAction
.
ID
,
nls
.
localize
(
'
showEditors
'
,
"
Show Editors
"
)
);
this
.
show
EditorsInGroupAction
=
this
.
instantiationService
.
createInstance
(
ShowEditorsInGroupAction
,
ShowEditorsInGroupAction
.
ID
,
ShowEditorsInGroupAction
.
LABEL
);
this
.
splitEditorAction
=
this
.
instantiationService
.
createInstance
(
SplitEditorAction
,
SplitEditorAction
.
ID
,
SplitEditorAction
.
LABEL
);
this
.
moveGroupLeftAction
=
this
.
instantiationService
.
createInstance
(
MoveGroupLeftAction
,
MoveGroupLeftAction
.
ID
,
nls
.
localize
(
'
moveLeft
'
,
"
Move Left
"
));
this
.
moveGroupRightAction
=
this
.
instantiationService
.
createInstance
(
MoveGroupRightAction
,
MoveGroupRightAction
.
ID
,
nls
.
localize
(
'
moveRight
'
,
"
Move Right
"
));
this
.
showEditorsOfLeftGroup
=
this
.
instantiationService
.
createInstance
(
ShowEditorsInLeftGroupAction
,
ShowEditorsInLeftGroupAction
.
ID
,
nls
.
localize
(
'
showEditors
'
,
"
Show Editors
"
));
this
.
showEditorsOfCenterGroup
=
this
.
instantiationService
.
createInstance
(
ShowEditorsInCenterGroupAction
,
ShowEditorsInCenterGroupAction
.
ID
,
nls
.
localize
(
'
showEditors
'
,
"
Show Editors
"
));
this
.
showEditorsOfRightGroup
=
this
.
instantiationService
.
createInstance
(
ShowEditorsInRightGroupAction
,
ShowEditorsInRightGroupAction
.
ID
,
nls
.
localize
(
'
showEditors
'
,
"
Show Editors
"
));
[
this
.
showEditorsOfLeftGroup
,
this
.
showEditorsOfCenterGroup
,
this
.
showEditorsOfRightGroup
,
this
.
showAllEditorsAction
].
forEach
(
a
=>
a
.
class
=
'
show-group-editors-action
'
)
;
this
.
showEditorsInGroupAction
.
class
=
'
show-group-editors-action
'
;
}
protected
doCreateToolbar
(
container
:
HTMLElement
):
ToolBar
{
...
...
@@ -328,34 +307,29 @@ export abstract class TitleControl {
const
editor
=
group
.
activeEditor
;
const
primary
:
IAction
[]
=
[];
const
groupCount
=
this
.
stacks
.
groups
.
length
;
// Overflow
let
overflowAction
:
Action
;
if
(
groupCount
===
1
)
{
overflowAction
=
this
.
showAllEditorsAction
;
}
else
{
primary
.
push
(
this
.
showEditorsInGroupAction
);
// Splitting
if
(
editor
instanceof
EditorInput
&&
editor
.
supportsSplitEditor
())
{
primary
.
push
(
this
.
splitEditorAction
);
}
// Enablement
switch
(
this
.
stacks
.
positionOfGroup
(
group
))
{
case
Position
.
LEFT
:
overflowAction
=
this
.
showEditorsOfLeftGroup
;
this
.
moveGroupLeftAction
.
enabled
=
false
;
this
.
moveGroupRightAction
.
enabled
=
this
.
stacks
.
groups
.
length
>
1
;
break
;
case
Position
.
CENTER
:
overflowAction
=
(
groupCount
===
2
)
?
this
.
showEditorsOfRightGroup
:
this
.
showEditorsOfCenterGroup
;
this
.
moveGroupRightAction
.
enabled
=
this
.
stacks
.
groups
.
length
>
2
;
break
;
case
Position
.
RIGHT
:
overflowAction
=
this
.
showEditorsOfRightGroup
;
this
.
moveGroupRightAction
.
enabled
=
false
;
break
;
}
}
primary
.
push
(
overflowAction
);
// Splitting
if
(
editor
instanceof
EditorInput
&&
editor
.
supportsSplitEditor
())
{
primary
.
push
(
this
.
splitEditorAction
);
}
// Return actions
const
secondary
=
[
...
...
@@ -423,10 +397,7 @@ export abstract class TitleControl {
// Actions
[
this
.
splitEditorAction
,
this
.
showAllEditorsAction
,
this
.
showEditorsOfLeftGroup
,
this
.
showEditorsOfCenterGroup
,
this
.
showEditorsOfRightGroup
,
this
.
showEditorsInGroupAction
,
this
.
closeEditorAction
,
this
.
closeRightEditorsAction
,
this
.
closeOtherEditorsAction
,
...
...
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
b7ee78d6
...
...
@@ -1541,13 +1541,18 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
const
stacks
=
this
.
editorGroupService
.
getStacksModel
();
// Store some properties per untitled file to restore later after save is completed
const
mapUntitledToProperties
:
{
[
resource
:
string
]:
{
mime
:
string
;
encoding
:
string
;
indexInGroups
:
number
[];
}
}
=
Object
.
create
(
null
);
const
mapUntitledToProperties
:
{
[
resource
:
string
]:
{
mime
:
string
;
encoding
:
string
;
indexInGroups
:
number
[];
activeInGroups
:
boolean
[]
}
}
=
Object
.
create
(
null
);
this
.
textFileService
.
getDirty
()
.
filter
(
r
=>
r
.
scheme
===
'
untitled
'
)
// All untitled resources
.
map
(
r
=>
this
.
untitledEditorService
.
get
(
r
))
// Mapped to their inputs
.
filter
(
i
=>
!!
i
)
// If possible :)
.
forEach
(
i
=>
{
mapUntitledToProperties
[
i
.
getResource
().
toString
()]
=
{
mime
:
i
.
getMime
(),
encoding
:
i
.
getEncoding
(),
indexInGroups
:
stacks
.
groups
.
map
(
g
=>
g
.
indexOf
(
i
))
};
.
filter
(
input
=>
!!
input
)
// If possible :)
.
forEach
(
input
=>
{
mapUntitledToProperties
[
input
.
getResource
().
toString
()]
=
{
mime
:
input
.
getMime
(),
encoding
:
input
.
getEncoding
(),
indexInGroups
:
stacks
.
groups
.
map
(
g
=>
g
.
indexOf
(
input
)),
activeInGroups
:
stacks
.
groups
.
map
(
g
=>
g
.
isActive
(
input
))
};
});
// Save all
...
...
@@ -1582,7 +1587,8 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
options
:
{
pinned
:
true
,
index
:
indexInGroup
,
preserveFocus
:
true
preserveFocus
:
true
,
inactive
:
!
untitledProps
.
activeInGroups
[
index
]
}
},
position
:
index
...
...
src/vs/workbench/services/contextview/electron-browser/contextmenuService.ts
浏览文件 @
b7ee78d6
...
...
@@ -57,7 +57,7 @@ export class ContextMenuService implements IContextMenuService {
x
*=
zoom
;
y
*=
zoom
;
menu
.
popup
(
remote
.
getCurrentWindow
(),
Math
.
floor
(
x
),
Math
.
floor
(
y
));
menu
.
popup
(
remote
.
getCurrentWindow
(),
Math
.
floor
(
x
),
Math
.
floor
(
y
)
,
-
1
/* no item selected by default */
);
if
(
delegate
.
onHide
)
{
delegate
.
onHide
(
undefined
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录