Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c21b4f4b
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,体验更适合开发者的 AI 搜索 >>
提交
c21b4f4b
编写于
6月 03, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #50957
上级
1a8ea64a
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
187 addition
and
130 deletion
+187
-130
src/vs/workbench/browser/parts/editor/editor.contribution.ts
src/vs/workbench/browser/parts/editor/editor.contribution.ts
+71
-48
src/vs/workbench/browser/parts/editor/editorCommands.ts
src/vs/workbench/browser/parts/editor/editorCommands.ts
+18
-12
src/vs/workbench/browser/parts/editor/editorGroupView.ts
src/vs/workbench/browser/parts/editor/editorGroupView.ts
+36
-4
src/vs/workbench/browser/parts/editor/media/notabstitlecontrol.css
...rkbench/browser/parts/editor/media/notabstitlecontrol.css
+0
-18
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
+15
-1
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
+2
-23
src/vs/workbench/browser/parts/editor/titleControl.ts
src/vs/workbench/browser/parts/editor/titleControl.ts
+25
-19
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+15
-0
src/vs/workbench/parts/files/electron-browser/explorerViewlet.ts
...workbench/parts/files/electron-browser/explorerViewlet.ts
+2
-2
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+1
-1
src/vs/workbench/services/editor/test/browser/editorService.test.ts
...kbench/services/editor/test/browser/editorService.test.ts
+2
-2
未找到文件。
src/vs/workbench/browser/parts/editor/editor.contribution.ts
浏览文件 @
c21b4f4b
...
...
@@ -398,7 +398,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
mac
:
openPreviousEditorKeybinding
.
mac
});
// Editor Commands
editorCommands
.
setup
();
...
...
@@ -440,73 +439,97 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
id
:
editorCommands
.
CLOSE_EDITORS_IN_GROUP_COMMAND_ID
,
title
:
nls
.
localize
(
'
closeAll
'
,
"
Close All
"
)
},
group
:
'
5_close
'
,
order
:
10
,
when
:
ContextKeyExpr
.
has
(
'
config.workbench.editor.showTabs
'
)
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
id
:
editorCommands
.
CLOSE_SAVED_EDITORS_COMMAND_ID
,
title
:
nls
.
localize
(
'
closeAllSaved
'
,
"
Close Saved
"
)
},
group
:
'
5_close
'
,
order
:
20
,
when
:
ContextKeyExpr
.
has
(
'
config.workbench.editor.showTabs
'
)
});
interface
IEditorToolItem
{
id
:
string
;
title
:
string
;
iconDark
:
string
;
iconLight
:
string
;
}
function
appendEditorToolItem
(
primary
:
IEditorToolItem
,
alternative
:
IEditorToolItem
,
when
:
ContextKeyExpr
,
order
:
number
):
void
{
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
id
:
primary
.
id
,
title
:
primary
.
title
,
iconPath
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/browser/parts/editor/media/
${
primary
.
iconDark
}
`
)).
fsPath
,
light
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/browser/parts/editor/media/
${
primary
.
iconLight
}
`
)).
fsPath
}
},
alt
:
{
id
:
alternative
.
id
,
title
:
alternative
.
title
,
iconPath
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/browser/parts/editor/media/
${
alternative
.
iconDark
}
`
)).
fsPath
,
light
:
URI
.
parse
(
require
.
toUrl
(
`vs/workbench/browser/parts/editor/media/
${
alternative
.
iconLight
}
`
)).
fsPath
}
},
group
:
'
navigation
'
,
when
,
order
});
}
// Editor Title Menu: Split Editor
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
appendEditorToolItem
(
{
id
:
SplitEditorAction
.
ID
,
title
:
nls
.
localize
(
'
splitEditorRight
'
,
"
Split Editor Right
"
),
iconPath
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/split-editor-horizontal-inverse.svg
'
)).
fsPath
,
light
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/split-editor-horizontal.svg
'
)).
fsPath
}
},
alt
:
{
iconDark
:
'
split-editor-horizontal-inverse.svg
'
,
iconLight
:
'
split-editor-horizontal.svg
'
},
{
id
:
editorCommands
.
SPLIT_EDITOR_DOWN
,
title
:
nls
.
localize
(
'
splitEditorDown
'
,
"
Split Editor Down
"
),
iconPath
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/split-editor-vertical-inverse.svg
'
)).
fsPath
,
light
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/split-editor-vertical.svg
'
)).
fsPath
}
iconDark
:
'
split-editor-vertical-inverse.svg
'
,
iconLight
:
'
split-editor-vertical.svg
'
},
group
:
'
navigation
'
,
when
:
ContextKeyExpr
.
not
(
'
splitEditorsVertically
'
),
order
:
100000
// towards the end
});
ContextKeyExpr
.
not
(
'
splitEditorsVertically
'
),
100000
/* towards the end */
);
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
appendEditorToolItem
(
{
id
:
SplitEditorAction
.
ID
,
title
:
nls
.
localize
(
'
splitEditorDown
'
,
"
Split Editor Down
"
),
iconPath
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/split-editor-vertical-inverse.svg
'
)).
fsPath
,
light
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/split-editor-vertical.svg
'
)).
fsPath
}
},
alt
:
{
iconDark
:
'
split-editor-vertical-inverse.svg
'
,
iconLight
:
'
split-editor-vertical.svg
'
},
{
id
:
editorCommands
.
SPLIT_EDITOR_RIGHT
,
title
:
nls
.
localize
(
'
splitEditorRight
'
,
"
Split Editor Right
"
),
iconPath
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/split-editor-horizontal-inverse.svg
'
)).
fsPath
,
light
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/split-editor-horizontal.svg
'
)).
fsPath
}
iconDark
:
'
split-editor-horizontal-inverse.svg
'
,
iconLight
:
'
split-editor-horizontal.svg
'
},
group
:
'
navigation
'
,
when
:
ContextKeyExpr
.
has
(
'
splitEditorsVertically
'
),
order
:
100000
// towards the end
});
ContextKeyExpr
.
has
(
'
splitEditorsVertically
'
),
100000
// towards the end
);
// Editor Title Menu: Close Group (tabs disabled)
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
appendEditorToolItem
(
{
id
:
editorCommands
.
CLOSE_EDITOR_COMMAND_ID
,
title
:
nls
.
localize
(
'
close
'
,
"
Close
"
),
iconPath
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/close-editor-inverse.svg
'
)).
fsPath
,
light
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/close-editor.svg
'
)).
fsPath
}
iconDark
:
'
close-editor-inverse.svg
'
,
iconLight
:
'
close-editor.svg
'
},
{
id
:
editorCommands
.
CLOSE_EDITORS_IN_GROUP_COMMAND_ID
,
title
:
nls
.
localize
(
'
closeAll
'
,
"
Close All
"
),
iconDark
:
'
closeall-editors-inverse.svg
'
,
iconLight
:
'
closeall-editors.svg
'
},
alt
:
{
ContextKeyExpr
.
and
(
ContextKeyExpr
.
not
(
'
config.workbench.editor.showTabs
'
),
ContextKeyExpr
.
not
(
'
groupActiveEditorDirty
'
)),
1000000
// towards the end
);
appendEditorToolItem
(
{
id
:
editorCommands
.
CLOSE_EDITOR_COMMAND_ID
,
title
:
nls
.
localize
(
'
close
'
,
"
Close
"
),
iconDark
:
'
close-dirty-inverse.svg
'
,
iconLight
:
'
close-dirty.svg
'
},
{
id
:
editorCommands
.
CLOSE_EDITORS_IN_GROUP_COMMAND_ID
,
title
:
nls
.
localize
(
'
closeAll
'
,
"
Close All
"
),
iconPath
:
{
dark
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/closeall-editors-inverse.svg
'
)).
fsPath
,
light
:
URI
.
parse
(
require
.
toUrl
(
'
vs/workbench/browser/parts/editor/media/closeall-editors.svg
'
)).
fsPath
}
iconDark
:
'
closeall-editors-inverse.svg
'
,
iconLight
:
'
closeall-editors.svg
'
},
group
:
'
navigation
'
,
when
:
ContextKeyExpr
.
not
(
'
config.workbench.editor.showTabs
'
),
order
:
1000000
// towards the end
});
ContextKeyExpr
.
and
(
ContextKeyExpr
.
not
(
'
config.workbench.editor.showTabs
'
),
ContextKeyExpr
.
has
(
'
groupActiveEditorDirty
'
)),
1000000
// towards the end
);
// Editor Commands for Command Palette
MenuRegistry
.
appendMenuItem
(
MenuId
.
CommandPalette
,
{
command
:
{
id
:
editorCommands
.
KEEP_EDITOR_COMMAND_ID
,
title
:
nls
.
localize
(
'
keepEditor
'
,
"
Keep Editor
"
),
category
},
when
:
ContextKeyExpr
.
has
(
'
config.workbench.editor.enablePreview
'
)
});
...
...
src/vs/workbench/browser/parts/editor/editorCommands.ts
浏览文件 @
c21b4f4b
...
...
@@ -425,8 +425,10 @@ function registerCloseEditorCommands() {
handler
:
(
accessor
,
resourceOrContext
:
URI
|
IEditorCommandsContext
,
context
?:
IEditorCommandsContext
)
=>
{
const
editorGroupService
=
accessor
.
get
(
IEditorGroupsService
);
const
contexts
=
getMultiSelectedEditorContexts
(
getCommandsContext
(
resourceOrContext
,
context
),
accessor
.
get
(
IListService
),
editorGroupService
);
if
(
contexts
.
length
===
0
&&
editorGroupService
.
activeGroup
)
{
contexts
.
push
({
groupId
:
editorGroupService
.
activeGroup
.
id
});
// If command is triggered from the command palette use the active group
const
activeGroup
=
editorGroupService
.
activeGroup
;
if
(
contexts
.
length
===
0
)
{
contexts
.
push
({
groupId
:
activeGroup
.
id
});
// active group as fallback
}
return
TPromise
.
join
(
distinct
(
contexts
.
map
(
c
=>
c
.
groupId
)).
map
(
groupId
=>
...
...
@@ -464,15 +466,20 @@ function registerCloseEditorCommands() {
handler
:
(
accessor
,
resourceOrContext
:
URI
|
IEditorCommandsContext
,
context
?:
IEditorCommandsContext
)
=>
{
const
editorGroupService
=
accessor
.
get
(
IEditorGroupsService
);
const
contexts
=
getMultiSelectedEditorContexts
(
getCommandsContext
(
resourceOrContext
,
context
),
accessor
.
get
(
IListService
),
editorGroupService
);
const
activeGroup
=
editorGroupService
.
activeGroup
;
if
(
contexts
.
length
===
0
&&
activeGroup
&&
activeGroup
.
activeEditor
)
{
contexts
.
push
({
groupId
:
activeGroup
.
id
,
editorIndex
:
activeGroup
.
getIndexOfEditor
(
activeGroup
.
activeEditor
)
});
if
(
contexts
.
length
===
0
&&
activeGroup
.
activeEditor
)
{
contexts
.
push
({
groupId
:
activeGroup
.
id
,
editorIndex
:
activeGroup
.
getIndexOfEditor
(
activeGroup
.
activeEditor
)
});
// active editor as fallback
}
const
groupIds
=
distinct
(
contexts
.
map
(
context
=>
context
.
groupId
));
return
TPromise
.
join
(
groupIds
.
map
(
groupId
=>
{
const
group
=
editorGroupService
.
getGroup
(
groupId
);
const
editors
=
contexts
.
filter
(
c
=>
c
.
groupId
===
groupId
).
map
(
c
=>
group
.
getEditor
(
c
.
editorIndex
));
const
editors
=
contexts
.
filter
(
context
=>
context
.
groupId
===
groupId
)
.
map
(
context
=>
typeof
context
.
editorIndex
===
'
number
'
?
group
.
getEditor
(
context
.
editorIndex
)
:
group
.
activeEditor
);
return
group
.
closeEditors
(
editors
);
}));
}
...
...
@@ -509,19 +516,18 @@ function registerCloseEditorCommands() {
const
editorGroupService
=
accessor
.
get
(
IEditorGroupsService
);
const
contexts
=
getMultiSelectedEditorContexts
(
getCommandsContext
(
resourceOrContext
,
context
),
accessor
.
get
(
IListService
),
editorGroupService
);
if
(
contexts
.
length
===
0
)
{
// Cover the case when run from command palette
const
activeGroup
=
editorGroupService
.
activeGroup
;
if
(
activeGroup
&&
activeGroup
.
activeEditor
)
{
contexts
.
push
({
groupId
:
activeGroup
.
id
,
editorIndex
:
activeGroup
.
getIndexOfEditor
(
activeGroup
.
activeEditor
)
});
}
const
activeGroup
=
editorGroupService
.
activeGroup
;
if
(
contexts
.
length
===
0
&&
activeGroup
.
activeEditor
)
{
contexts
.
push
({
groupId
:
activeGroup
.
id
,
editorIndex
:
activeGroup
.
getIndexOfEditor
(
activeGroup
.
activeEditor
)
});
// active editor as fallback
}
const
groupIds
=
distinct
(
contexts
.
map
(
context
=>
context
.
groupId
));
return
TPromise
.
join
(
groupIds
.
map
(
groupId
=>
{
const
group
=
editorGroupService
.
getGroup
(
groupId
);
const
editors
=
contexts
.
filter
(
c
=>
c
.
groupId
===
groupId
).
map
(
c
=>
group
.
getEditor
(
c
.
editorIndex
));
const
editors
=
contexts
.
filter
(
context
=>
context
.
groupId
===
groupId
)
.
map
(
context
=>
typeof
context
.
editorIndex
===
'
number
'
?
group
.
getEditor
(
context
.
editorIndex
)
:
group
.
activeEditor
);
const
editorsToClose
=
group
.
editors
.
filter
(
e
=>
editors
.
indexOf
(
e
)
===
-
1
);
return
group
.
closeEditors
(
editorsToClose
);
...
...
src/vs/workbench/browser/parts/editor/editorGroupView.ts
浏览文件 @
c21b4f4b
...
...
@@ -8,7 +8,7 @@
import
'
vs/css!./media/editorgroupview
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
EditorGroup
,
IEditorOpenOptions
,
EditorCloseEvent
,
ISerializedEditorGroup
,
isSerializedEditorGroup
}
from
'
vs/workbench/common/editor/editorGroup
'
;
import
{
EditorInput
,
EditorOptions
,
GroupIdentifier
,
ConfirmResult
,
SideBySideEditorInput
,
CloseDirection
,
IEditorCloseEvent
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorInput
,
EditorOptions
,
GroupIdentifier
,
ConfirmResult
,
SideBySideEditorInput
,
CloseDirection
,
IEditorCloseEvent
,
EditorGroupActiveEditorDirtyContext
}
from
'
vs/workbench/common/editor
'
;
import
{
Event
,
Emitter
,
once
}
from
'
vs/base/common/event
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
addClass
,
addClasses
,
Dimension
,
trackFocus
,
toggleClass
,
removeClass
,
addDisposableListener
,
EventType
,
EventHelper
,
findParentWithClass
,
clearNode
,
isAncestor
}
from
'
vs/base/browser/dom
'
;
...
...
@@ -27,7 +27,7 @@ import { ProgressService } from 'vs/workbench/services/progress/browser/progress
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
isPromiseCanceledError
,
isErrorWithActions
,
IErrorWithActions
}
from
'
vs/base/common/errors
'
;
import
{
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Severity
,
INotificationService
,
INotificationActions
}
from
'
vs/platform/notification/common/notification
'
;
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
@@ -172,12 +172,16 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
this
.
_register
(
attachProgressBarStyler
(
this
.
progressBar
,
this
.
themeService
));
this
.
progressBar
.
hide
();
// Scoped instantiator
// Scoped services
const
scopedContextKeyService
=
this
.
_register
(
this
.
contextKeyService
.
createScoped
(
this
.
element
));
this
.
scopedInstantiationService
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
(
[
IContextKeyService
,
this
.
_register
(
this
.
contextKeyService
.
createScoped
(
this
.
element
))
],
[
IContextKeyService
,
scopedContextKeyService
],
[
IProgressService
,
new
ProgressService
(
this
.
progressBar
)]
));
// Context keys
this
.
handleGroupContextKeys
(
scopedContextKeyService
);
// Title container
this
.
titleContainer
=
document
.
createElement
(
'
div
'
);
addClass
(
this
.
titleContainer
,
'
title
'
);
...
...
@@ -205,6 +209,34 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
this
.
updateStyles
();
}
private
handleGroupContextKeys
(
contextKeyServcie
:
IContextKeyService
):
void
{
const
groupActiveEditorDirtyContextKey
=
EditorGroupActiveEditorDirtyContext
.
bindTo
(
contextKeyServcie
);
let
activeEditorListener
:
IDisposable
;
const
observeActiveEditor
=
()
=>
{
activeEditorListener
=
dispose
(
activeEditorListener
);
const
activeEditor
=
this
.
_group
.
activeEditor
;
if
(
activeEditor
)
{
groupActiveEditorDirtyContextKey
.
set
(
activeEditor
.
isDirty
());
activeEditorListener
=
activeEditor
.
onDidChangeDirty
(()
=>
groupActiveEditorDirtyContextKey
.
set
(
activeEditor
.
isDirty
()));
}
else
{
groupActiveEditorDirtyContextKey
.
set
(
false
);
}
};
// Track the active editor and update context key that reflects
// the dirty state of this editor
this
.
_register
(
this
.
onDidGroupChange
(
e
=>
{
if
(
e
.
kind
===
GroupChangeKind
.
EDITOR_ACTIVE
)
{
observeActiveEditor
();
}
}));
observeActiveEditor
();
}
private
registerContainerListeners
():
void
{
// Open new file via doubleclick on empty container
...
...
src/vs/workbench/browser/parts/editor/media/notabstitlecontrol.css
浏览文件 @
c21b4f4b
...
...
@@ -26,22 +26,4 @@
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container.active
>
.title
.title-actions
{
opacity
:
1
;
}
.vs
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title.dirty
.title-actions
.close-editor-action
{
background
:
url('close-dirty.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title.dirty
.title-actions
.close-editor-action
,
.hc-black
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title.dirty
.title-actions
.close-editor-action
{
background
:
url('close-dirty-inverse.svg')
center
center
no-repeat
;
}
.vs
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title.dirty
.title-actions
.close-editor-action
:hover
{
background
:
url('close.svg')
center
center
no-repeat
;
}
.vs-dark
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title.dirty
.title-actions
.close-editor-action
:hover
,
.hc-black
.monaco-workbench
>
.part.editor
>
.content
.editor-group-container
>
.title.dirty
.title-actions
.close-editor-action
:hover
{
background
:
url('close-inverse.svg')
center
center
no-repeat
;
}
\ No newline at end of file
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
浏览文件 @
c21b4f4b
...
...
@@ -7,12 +7,14 @@
import
'
vs/css!./media/notabstitlecontrol
'
;
import
{
toResource
,
Verbosity
,
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
TitleControl
}
from
'
vs/workbench/browser/parts/editor/titleControl
'
;
import
{
TitleControl
,
IToolbarActions
}
from
'
vs/workbench/browser/parts/editor/titleControl
'
;
import
{
ResourceLabel
}
from
'
vs/workbench/browser/labels
'
;
import
{
TAB_ACTIVE_FOREGROUND
,
TAB_UNFOCUSED_ACTIVE_FOREGROUND
}
from
'
vs/workbench/common/theme
'
;
import
{
EventType
as
TouchEventType
,
GestureEvent
,
Gesture
}
from
'
vs/base/browser/touch
'
;
import
{
addDisposableListener
,
EventType
,
addClass
,
EventHelper
,
removeClass
}
from
'
vs/base/browser/dom
'
;
import
{
IEditorPartOptions
}
from
'
vs/workbench/browser/parts/editor/editor
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
CLOSE_EDITOR_COMMAND_ID
}
from
'
vs/workbench/browser/parts/editor/editorCommands
'
;
export
class
NoTabsTitleControl
extends
TitleControl
{
private
titleContainer
:
HTMLElement
;
...
...
@@ -205,4 +207,16 @@ export class NoTabsTitleControl extends TitleControl {
default
:
return
Verbosity
.
MEDIUM
;
}
}
protected
prepareEditorActions
(
editorActions
:
IToolbarActions
):
{
primaryEditorActions
:
IAction
[],
secondaryEditorActions
:
IAction
[]
}
{
const
isGroupActive
=
this
.
accessor
.
activeGroup
===
this
.
group
;
// Group active: show all actions
if
(
isGroupActive
)
{
return
super
.
prepareEditorActions
(
editorActions
);
}
// Group inactive: only show close action
return
{
primaryEditorActions
:
editorActions
.
primary
.
filter
(
action
=>
action
.
id
===
CLOSE_EDITOR_COMMAND_ID
),
secondaryEditorActions
:
[]
};
}
}
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
浏览文件 @
c21b4f4b
...
...
@@ -6,11 +6,9 @@
'
use strict
'
;
import
'
vs/css!./media/tabstitlecontrol
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
shorten
}
from
'
vs/base/common/labels
'
;
import
{
ActionRunner
,
IAction
}
from
'
vs/base/common/actions
'
;
import
{
toResource
,
GroupIdentifier
,
IEditorInput
,
Verbosity
}
from
'
vs/workbench/common/editor
'
;
import
{
toResource
,
GroupIdentifier
,
IEditorInput
,
Verbosity
,
EditorCommandsContextActionRunner
}
from
'
vs/workbench/common/editor
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
EventType
as
TouchEventType
,
GestureEvent
,
Gesture
}
from
'
vs/base/browser/touch
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
...
...
@@ -393,7 +391,7 @@ export class TabsTitleControl extends TitleControl {
addClass
(
tabCloseContainer
,
'
tab-close
'
);
tabContainer
.
appendChild
(
tabCloseContainer
);
const
tabActionRunner
=
new
TabActionRunner
(()
=>
this
.
group
.
id
,
index
);
const
tabActionRunner
=
new
EditorCommandsContextActionRunner
({
groupId
:
this
.
group
.
id
,
editorIndex
:
index
}
);
const
tabActionBar
=
new
ActionBar
(
tabCloseContainer
,
{
ariaLabel
:
localize
(
'
araLabelTabActions
'
,
"
Tab actions
"
),
actionRunner
:
tabActionRunner
});
tabActionBar
.
push
(
this
.
closeOneEditorAction
,
{
icon
:
true
,
label
:
false
,
keybinding
:
this
.
getKeybindingLabel
(
this
.
closeOneEditorAction
)
});
...
...
@@ -1011,25 +1009,6 @@ export class TabsTitleControl extends TitleControl {
}
}
class
TabActionRunner
extends
ActionRunner
{
constructor
(
private
groupId
:
()
=>
GroupIdentifier
,
private
index
:
number
)
{
super
();
}
run
(
action
:
IAction
,
context
?:
any
):
TPromise
<
void
>
{
const
groupId
=
this
.
groupId
();
if
(
typeof
groupId
!==
'
number
'
)
{
return
TPromise
.
as
(
void
0
);
}
return
super
.
run
(
action
,
{
groupId
,
editorIndex
:
this
.
index
});
}
}
registerThemingParticipant
((
theme
:
ITheme
,
collector
:
ICssStyleCollector
)
=>
{
// Styling with Outline color (e.g. high contrast theme)
...
...
src/vs/workbench/browser/parts/editor/titleControl.ts
浏览文件 @
c21b4f4b
...
...
@@ -12,7 +12,7 @@ import { IAction, Action, IRunEvent } from 'vs/base/common/actions';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
{
toResource
,
IEditorCommandsContext
,
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
toResource
,
IEditorCommandsContext
,
IEditorInput
,
EditorCommandsContextActionRunner
}
from
'
vs/workbench/common/editor
'
;
import
{
IActionItem
,
ActionsOrientation
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
...
...
@@ -91,15 +91,18 @@ export abstract class TitleControl extends Themable {
protected
abstract
create
(
parent
:
HTMLElement
):
void
;
protected
createEditorActionsToolBar
(
container
:
HTMLElement
):
void
{
const
context
=
{
groupId
:
this
.
group
.
id
}
as
IEditorCommandsContext
;
this
.
editorActionsToolbar
=
this
.
_register
(
new
ToolBar
(
container
,
this
.
contextMenuService
,
{
actionItemProvider
:
action
=>
this
.
actionItemProvider
(
action
as
Action
),
orientation
:
ActionsOrientation
.
HORIZONTAL
,
ariaLabel
:
localize
(
'
araLabelEditorActions
'
,
"
Editor actions
"
),
getKeyBinding
:
action
=>
this
.
getKeybinding
(
action
)
getKeyBinding
:
action
=>
this
.
getKeybinding
(
action
),
actionRunner
:
this
.
_register
(
new
EditorCommandsContextActionRunner
(
context
))
}));
// Context
this
.
editorActionsToolbar
.
context
=
{
groupId
:
this
.
group
.
id
}
as
IEditorCommandsC
ontext
;
this
.
editorActionsToolbar
.
context
=
c
ontext
;
// Action Run Handling
this
.
_register
(
this
.
editorActionsToolbar
.
actionRunner
.
onDidRun
((
e
:
IRunEvent
)
=>
{
...
...
@@ -138,21 +141,9 @@ export abstract class TitleControl extends Themable {
}
protected
updateEditorActionsToolbar
():
void
{
const
isGroupActive
=
this
.
accessor
.
activeGroup
===
this
.
group
;
// Update Editor Actions Toolbar
let
primaryEditorActions
:
IAction
[]
=
[];
let
secondaryEditorActions
:
IAction
[]
=
[];
const
editorActions
=
this
.
getEditorActions
();
// Primary actions only for the active group
if
(
isGroupActive
)
{
primaryEditorActions
=
prepareActions
(
editorActions
.
primary
);
}
// Secondary actions for all groups
secondaryEditorActions
=
prepareActions
(
editorActions
.
secondary
);
const
{
primaryEditorActions
,
secondaryEditorActions
}
=
this
.
prepareEditorActions
(
this
.
getEditorActions
());
// Only update if something actually has changed
const
primaryEditorActionIds
=
primaryEditorActions
.
map
(
a
=>
a
.
id
);
...
...
@@ -170,6 +161,23 @@ export abstract class TitleControl extends Themable {
}
}
protected
prepareEditorActions
(
editorActions
:
IToolbarActions
):
{
primaryEditorActions
:
IAction
[];
secondaryEditorActions
:
IAction
[];
}
{
let
primaryEditorActions
:
IAction
[];
let
secondaryEditorActions
:
IAction
[];
// Primary actions only for the active group
if
(
this
.
accessor
.
activeGroup
===
this
.
group
)
{
primaryEditorActions
=
prepareActions
(
editorActions
.
primary
);
}
else
{
primaryEditorActions
=
[];
}
// Secondary actions for all groups
secondaryEditorActions
=
prepareActions
(
editorActions
.
secondary
);
return
{
primaryEditorActions
,
secondaryEditorActions
};
}
private
getEditorActions
():
IToolbarActions
{
const
primary
:
IAction
[]
=
[];
const
secondary
:
IAction
[]
=
[];
...
...
@@ -199,9 +207,7 @@ export abstract class TitleControl extends Themable {
const
titleBarMenu
=
this
.
menuService
.
createMenu
(
MenuId
.
EditorTitle
,
scopedContextKeyService
);
this
.
editorToolBarMenuDisposables
.
push
(
titleBarMenu
);
this
.
editorToolBarMenuDisposables
.
push
(
titleBarMenu
.
onDidChange
(()
=>
{
// Update editor toolbar whenever contributed actions change
this
.
updateEditorActionsToolbar
();
this
.
updateEditorActionsToolbar
();
// Update editor toolbar whenever contributed actions change
}));
fillInActionBarActions
(
titleBarMenu
,
{
arg
:
this
.
resourceContext
.
get
(),
shouldForwardArgs
:
true
},
{
primary
,
secondary
});
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
c21b4f4b
...
...
@@ -20,8 +20,10 @@ import { Schemas } from 'vs/base/common/network';
import
{
LRUCache
}
from
'
vs/base/common/map
'
;
import
{
IEditorGroupsService
,
IEditorGroup
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
ICompositeControl
}
from
'
vs/workbench/common/composite
'
;
import
{
ActionRunner
,
IAction
}
from
'
vs/base/common/actions
'
;
export
const
EditorsVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
editorIsOpen
'
,
false
);
export
const
EditorGroupActiveEditorDirtyContext
=
new
RawContextKey
<
boolean
>
(
'
groupActiveEditorDirty
'
,
false
);
export
const
NoEditorsVisibleContext
:
ContextKeyExpr
=
EditorsVisibleContext
.
toNegated
();
export
const
TextCompareEditorVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
textCompareEditorVisible
'
,
false
);
export
const
ActiveEditorGroupEmptyContext
=
new
RawContextKey
<
boolean
>
(
'
activeEditorGroupEmpty
'
,
false
);
...
...
@@ -924,6 +926,19 @@ export interface IEditorCommandsContext {
editorIndex
?:
number
;
}
export
class
EditorCommandsContextActionRunner
extends
ActionRunner
{
constructor
(
private
context
:
IEditorCommandsContext
)
{
super
();
}
run
(
action
:
IAction
,
context
?:
any
):
TPromise
<
void
>
{
return
super
.
run
(
action
,
this
.
context
);
}
}
export
interface
IEditorCloseEvent
extends
IEditorIdentifier
{
replaced
:
boolean
;
index
:
number
;
...
...
src/vs/workbench/parts/files/electron-browser/explorerViewlet.ts
浏览文件 @
c21b4f4b
...
...
@@ -31,7 +31,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
Delegating
Workbench
EditorService
}
from
'
vs/workbench/services/editor/browser/editorService
'
;
import
{
DelegatingEditorService
}
from
'
vs/workbench/services/editor/browser/editorService
'
;
import
{
IEditorGroup
,
IEditorGroupsService
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
...
...
@@ -189,7 +189,7 @@ export class ExplorerViewlet extends PersistentViewsViewlet implements IExplorer
// without causing the animation in the opened editors view to kick in and change scroll position.
// We try to be smart and only use the delay if we recognize that the user action is likely to cause
// a new entry in the opened editors view.
const
delegatingEditorService
=
this
.
instantiationService
.
createInstance
(
Delegating
Workbench
EditorService
);
const
delegatingEditorService
=
this
.
instantiationService
.
createInstance
(
DelegatingEditorService
);
delegatingEditorService
.
setEditorOpenHandler
((
group
:
IEditorGroup
,
editor
:
IEditorInput
,
options
?:
IEditorOptions
)
=>
{
let
openEditorsView
=
this
.
getOpenEditorsView
();
if
(
openEditorsView
)
{
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
c21b4f4b
...
...
@@ -594,7 +594,7 @@ export interface IEditorOpenHandler {
* The delegating workbench editor service can be used to override the behaviour of the openEditor()
* method by providing a IEditorOpenHandler.
*/
export
class
Delegating
Workbench
EditorService
extends
EditorService
{
export
class
DelegatingEditorService
extends
EditorService
{
private
editorOpenHandler
:
IEditorOpenHandler
;
constructor
(
...
...
src/vs/workbench/services/editor/test/browser/editorService.test.ts
浏览文件 @
c21b4f4b
...
...
@@ -15,7 +15,7 @@ import { EditorInput, EditorOptions, IFileEditorInput, IEditorInput } from 'vs/w
import
{
workbenchInstantiationService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
import
{
TestThemeService
}
from
'
vs/platform/theme/test/common/testThemeService
'
;
import
{
EditorService
,
Delegating
Workbench
EditorService
}
from
'
vs/workbench/services/editor/browser/editorService
'
;
import
{
EditorService
,
DelegatingEditorService
}
from
'
vs/workbench/services/editor/browser/editorService
'
;
import
{
IEditorGroup
,
IEditorGroupsService
,
GroupDirection
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
EditorPart
}
from
'
vs/workbench/browser/parts/editor/editorPart
'
;
import
{
Dimension
}
from
'
vs/base/browser/dom
'
;
...
...
@@ -260,7 +260,7 @@ suite('Editor service', () => {
const
ed
=
instantiationService
.
createInstance
(
MyEditor
,
'
my.editor
'
);
const
inp
=
instantiationService
.
createInstance
(
ResourceEditorInput
,
'
name
'
,
'
description
'
,
URI
.
parse
(
'
my://resource
'
));
const
delegate
=
instantiationService
.
createInstance
(
Delegating
Workbench
EditorService
);
const
delegate
=
instantiationService
.
createInstance
(
DelegatingEditorService
);
delegate
.
setEditorOpenHandler
((
group
:
IEditorGroup
,
input
:
IEditorInput
,
options
?:
EditorOptions
)
=>
{
assert
.
strictEqual
(
input
,
inp
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录