Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e83b2322
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,发现更多精彩内容 >>
提交
e83b2322
编写于
5月 04, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - some cleanup
上级
6b82e441
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
137 addition
and
154 deletion
+137
-154
src/vs/workbench/browser/parts/editor2/editor2.ts
src/vs/workbench/browser/parts/editor2/editor2.ts
+2
-2
src/vs/workbench/browser/parts/editor2/nextEditorControl.ts
src/vs/workbench/browser/parts/editor2/nextEditorControl.ts
+1
-1
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
...vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
+94
-102
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
+2
-15
src/vs/workbench/browser/parts/editor2/nextNoTabsTitleControl.ts
...workbench/browser/parts/editor2/nextNoTabsTitleControl.ts
+31
-30
src/vs/workbench/browser/parts/editor2/nextTabsTitleControl.ts
...s/workbench/browser/parts/editor2/nextTabsTitleControl.ts
+7
-2
src/vs/workbench/browser/parts/editor2/nextTitleControl.ts
src/vs/workbench/browser/parts/editor2/nextTitleControl.ts
+0
-2
未找到文件。
src/vs/workbench/browser/parts/editor2/editor2.ts
浏览文件 @
e83b2322
...
...
@@ -35,7 +35,7 @@ export function impactsEditorPartOptions(event: IConfigurationChangeEvent): bool
}
export
function
getEditorPartOptions
(
config
:
IWorkbenchEditorConfiguration
):
INextEditorPartOptions
{
le
t
options
:
INextEditorPartOptions
=
assign
(
Object
.
create
(
null
),
DEFAULT_EDITOR_PART_OPTIONS
);
cons
t
options
:
INextEditorPartOptions
=
assign
(
Object
.
create
(
null
),
DEFAULT_EDITOR_PART_OPTIONS
);
if
(
!
config
||
!
config
.
workbench
)
{
return
options
;
...
...
@@ -46,7 +46,7 @@ export function getEditorPartOptions(config: IWorkbenchEditorConfiguration): INe
}
if
(
config
.
workbench
.
editor
)
{
options
=
assign
(
options
,
config
.
workbench
.
editor
);
assign
(
options
,
config
.
workbench
.
editor
);
}
return
options
;
...
...
src/vs/workbench/browser/parts/editor2/nextEditorControl.ts
浏览文件 @
e83b2322
...
...
@@ -102,7 +102,7 @@ export class NextEditorControl extends Disposable {
private
doInstantiateEditorControl
(
descriptor
:
IEditorDescriptor
):
BaseEditor
{
// Return early if already instantiated
const
existingControl
=
this
.
controls
.
filter
(
e
=>
descriptor
.
describes
(
e
))[
0
];
const
existingControl
=
this
.
controls
.
filter
(
control
=>
descriptor
.
describes
(
control
))[
0
];
if
(
existingControl
)
{
return
existingControl
;
}
...
...
src/vs/workbench/browser/parts/editor2/nextEditorGroupView.ts
浏览文件 @
e83b2322
...
...
@@ -26,14 +26,13 @@ import { IProgressService } from 'vs/platform/progress/common/progress';
import
{
ProgressService
}
from
'
vs/workbench/services/progress/browser/progressService
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
onUnexpectedError
,
isPromiseCanceledError
,
isErrorWithActions
,
IErrorWithActions
}
from
'
vs/base/common/errors
'
;
import
{
isPromiseCanceledError
,
isErrorWithActions
,
IErrorWithActions
}
from
'
vs/base/common/errors
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
dispose
}
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
'
;
import
{
RunOnceWorker
}
from
'
vs/base/common/async
'
;
import
{
IConfigurationService
,
IConfigurationChangeEvent
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
getCodeEditor
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
EventType
as
TouchEventType
,
GestureEvent
}
from
'
vs/base/browser/touch
'
;
import
{
NextTitleControl
}
from
'
vs/workbench/browser/parts/editor2/nextTitleControl
'
;
...
...
@@ -43,7 +42,8 @@ import { NextNoTabsTitleControl } from './nextNoTabsTitleControl';
export
class
NextEditorGroupView
extends
Themable
implements
INextEditorGroupView
{
private
static
readonly
EDITOR_TITLE_HEIGHT
=
35
;
private
static
readonly
ENABLE_PREVIEW_SETTING
=
'
workbench.editor.enablePreview
'
;
private
static
readonly
EDITOR_MIN_WIDTH
=
170
;
private
static
readonly
EDITOR_MIN_HEIGHT
=
70
;
//#region factory
...
...
@@ -106,8 +106,7 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
@
IThemeService
themeService
:
IThemeService
,
@
IPartService
private
partService
:
IPartService
,
@
INotificationService
private
notificationService
:
INotificationService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
@
ITelemetryService
private
telemetryService
:
ITelemetryService
)
{
super
(
themeService
);
...
...
@@ -135,9 +134,6 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
this
.
_register
(
this
.
_group
.
onDidEditorBecomeDirty
(
editor
=>
this
.
onDidEditorBecomeDirty
(
editor
)));
this
.
_register
(
this
.
_group
.
onDidEditorLabelChange
(
editor
=>
this
.
onDidEditorLabelChange
(
editor
)));
// Configuration Changes
this
.
_register
(
this
.
configurationService
.
onDidChangeConfiguration
(
e
=>
this
.
onDidChangeConfiguration
(
e
)));
// Option Changes
this
.
_register
(
this
.
accessor
.
onDidEditorPartOptionsChange
(
e
=>
this
.
onDidEditorPartOptionsChange
(
e
)));
}
...
...
@@ -224,16 +220,6 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
}
}
private
onDidChangeConfiguration
(
event
:
IConfigurationChangeEvent
):
void
{
// Pin preview editor once user disables preview
if
(
event
.
affectsConfiguration
(
NextEditorGroupView
.
ENABLE_PREVIEW_SETTING
))
{
if
(
!
this
.
configurationService
.
getValue
<
string
>
(
NextEditorGroupView
.
ENABLE_PREVIEW_SETTING
))
{
this
.
pinEditor
(
this
.
_group
.
previewEditor
);
}
}
}
private
onDidEditorPartOptionsChange
(
event
:
INextEditorPartOptionsChangeEvent
):
void
{
// Title container
...
...
@@ -251,9 +237,9 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
clearNode
(
this
.
titleContainer
);
// Recreate new and open editor
const
titleAreaControl
=
this
.
doCreateOrGetTitle
Control
();
this
.
createTitleArea
Control
();
if
(
this
.
group
.
activeEditor
)
{
titleAreaControl
.
openEditor
(
this
.
group
.
activeEditor
);
t
his
.
t
itleAreaControl
.
openEditor
(
this
.
group
.
activeEditor
);
}
}
...
...
@@ -265,6 +251,11 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
// Styles
this
.
updateStyles
();
// Pin preview editor once user disables preview
if
(
event
.
oldPartOptions
.
enablePreview
&&
!
event
.
newPartOptions
.
enablePreview
)
{
this
.
pinEditor
(
this
.
_group
.
previewEditor
);
}
}
private
onDidEditorBecomeDirty
(
editor
:
EditorInput
):
void
{
...
...
@@ -383,6 +374,43 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
toggleClass
(
this
.
titleContainer
,
'
show-file-icons
'
,
this
.
accessor
.
partOptions
.
showIcons
);
}
private
createScopedInstantiationService
():
void
{
this
.
scopedInstantiationService
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
(
[
IContextKeyService
,
this
.
_register
(
this
.
contextKeyService
.
createScoped
(
this
.
element
))],
[
IProgressService
,
new
ProgressService
(
this
.
progressBar
)]
));
}
private
createTitleAreaControl
():
NextTitleControl
{
if
(
!
this
.
scopedInstantiationService
)
{
this
.
createScopedInstantiationService
();
}
if
(
this
.
accessor
.
partOptions
.
showTabs
)
{
this
.
titleAreaControl
=
this
.
scopedInstantiationService
.
createInstance
(
NextTabsTitleControl
,
this
.
titleContainer
,
this
.
accessor
,
this
);
}
else
{
this
.
titleAreaControl
=
this
.
scopedInstantiationService
.
createInstance
(
NextNoTabsTitleControl
,
this
.
titleContainer
,
this
.
accessor
,
this
);
}
this
.
doLayoutTitleControl
();
return
this
.
titleAreaControl
;
}
private
createEditorControl
():
NextEditorControl
{
if
(
!
this
.
scopedInstantiationService
)
{
this
.
createScopedInstantiationService
();
}
this
.
editorControl
=
this
.
_register
(
this
.
scopedInstantiationService
.
createInstance
(
NextEditorControl
,
this
.
editorContainer
,
this
.
_group
.
id
));
this
.
doLayoutEditorControl
();
return
this
.
editorControl
;
}
//region INextEditorGroupView
get
group
():
EditorGroup
{
return
this
.
_group
;
}
...
...
@@ -407,8 +435,12 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
return
this
.
_group
.
count
===
0
;
}
//#endregion
//#region INextEditorGroup
//#region basics()
get
id
():
GroupIdentifier
{
return
this
.
_group
.
id
;
}
...
...
@@ -445,6 +477,33 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
return
this
.
_group
.
indexOf
(
editor
);
}
isOpened
(
editor
:
EditorInput
):
boolean
{
return
this
.
_group
.
contains
(
editor
);
}
focus
():
void
{
if
(
this
.
activeControl
)
{
this
.
activeControl
.
focus
();
}
else
{
this
.
element
.
focus
();
}
}
pinEditor
(
editor
:
EditorInput
=
this
.
activeEditor
):
void
{
if
(
editor
&&
!
this
.
_group
.
isPinned
(
editor
))
{
// Update model
this
.
_group
.
pin
(
editor
);
// Forward to title control
if
(
this
.
titleAreaControl
)
{
this
.
titleAreaControl
.
pinEditor
(
editor
);
}
}
}
//#endregion
//#region openEditor()
openEditor
(
editor
:
EditorInput
,
options
?:
EditorOptions
):
Thenable
<
void
>
{
...
...
@@ -480,13 +539,15 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
// Update model
this
.
_group
.
openEditor
(
editor
,
openEditorOptions
);
// Forward to title control
this
.
doCreateOrGetTitleControl
().
openEditor
(
editor
);
// Forward to title control (create lazily)
const
titleAreaControl
=
this
.
titleAreaControl
||
this
.
createTitleAreaControl
();
titleAreaControl
.
openEditor
(
editor
);
// Forward to editor control if the active editor changed
// Forward to editor control if the active editor changed
(create lazily)
let
openEditorPromise
:
Thenable
<
void
>
;
if
(
openEditorOptions
.
active
)
{
openEditorPromise
=
this
.
doCreateOrGetEditorControl
().
openEditor
(
editor
,
options
).
then
(
result
=>
{
const
editorControl
=
this
.
editorControl
||
this
.
createEditorControl
();
openEditorPromise
=
editorControl
.
openEditor
(
editor
,
options
).
then
(
result
=>
{
// Editor change event
if
(
result
.
editorChanged
)
{
...
...
@@ -528,46 +589,9 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
// Recover by closing the active editor (if the input is still the active one)
if
(
this
.
activeEditor
===
editor
)
{
this
.
doCloseActiveEditor
(
!
(
options
&&
options
.
preserveFocus
)
/* still preserve focus as needed */
,
true
/* from error */
);
}
}
private
doCreateOrGetScopedInstantiationService
():
IInstantiationService
{
if
(
!
this
.
scopedInstantiationService
)
{
this
.
scopedInstantiationService
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
(
[
IContextKeyService
,
this
.
_register
(
this
.
contextKeyService
.
createScoped
(
this
.
element
))],
[
IProgressService
,
new
ProgressService
(
this
.
progressBar
)]
));
}
return
this
.
scopedInstantiationService
;
const
focusNext
=
!
options
||
!
options
.
preserveFocus
;
this
.
doCloseActiveEditor
(
focusNext
,
true
/* from error */
);
}
private
doCreateOrGetTitleControl
():
NextTitleControl
{
if
(
!
this
.
titleAreaControl
)
{
const
instantiator
=
this
.
doCreateOrGetScopedInstantiationService
();
if
(
this
.
accessor
.
partOptions
.
showTabs
)
{
this
.
titleAreaControl
=
instantiator
.
createInstance
(
NextTabsTitleControl
,
this
.
titleContainer
,
this
.
accessor
,
this
);
}
else
{
this
.
titleAreaControl
=
instantiator
.
createInstance
(
NextNoTabsTitleControl
,
this
.
titleContainer
,
this
.
accessor
,
this
);
}
this
.
doLayoutTitleControl
();
}
return
this
.
titleAreaControl
;
}
private
doCreateOrGetEditorControl
():
NextEditorControl
{
if
(
!
this
.
editorControl
)
{
const
instantiator
=
this
.
doCreateOrGetScopedInstantiationService
();
this
.
editorControl
=
this
.
_register
(
instantiator
.
createInstance
(
NextEditorControl
,
this
.
editorContainer
,
this
.
_group
.
id
));
this
.
doLayoutEditorControl
();
}
return
this
.
editorControl
;
}
//#endregion
...
...
@@ -625,7 +649,7 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
target
.
openEditor
(
editor
,
options
);
// ...and a close afterwards
this
.
doCloseEditor
(
editor
,
false
/* do not
activate
next one behind if any */
);
this
.
doCloseEditor
(
editor
,
false
/* do not
focus
next one behind if any */
);
}
//#endregion
...
...
@@ -648,7 +672,7 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
private
doCloseEditor
(
editor
:
EditorInput
,
focusNext
=
this
.
accessor
.
activeGroup
===
this
):
void
{
// Closing the active editor of the group is a bit more work
if
(
this
.
activeEditor
&&
this
.
activeEditor
.
matches
(
editor
))
{
if
(
this
.
group
.
isActive
(
editor
))
{
this
.
doCloseActiveEditor
(
focusNext
);
}
...
...
@@ -681,11 +705,8 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
this
.
ignoreOpenEditorErrors
=
true
;
}
this
.
openEditor
(
nextActiveEditor
,
!
focusNext
?
EditorOptions
.
create
({
preserveFocus
:
true
})
:
null
).
then
(()
=>
{
this
.
ignoreOpenEditorErrors
=
false
;
},
error
=>
{
onUnexpectedError
(
error
);
const
options
=
!
focusNext
?
EditorOptions
.
create
({
preserveFocus
:
true
})
:
void
0
;
this
.
openEditor
(
nextActiveEditor
,
options
).
then
(()
=>
{
this
.
ignoreOpenEditorErrors
=
false
;
});
}
else
{
...
...
@@ -775,35 +796,6 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
//#endregion
//#region other INextEditorGroup methods
isOpened
(
editor
:
EditorInput
):
boolean
{
return
this
.
_group
.
contains
(
editor
);
}
focus
():
void
{
if
(
this
.
activeControl
)
{
this
.
activeControl
.
focus
();
}
else
{
this
.
element
.
focus
();
}
}
pinEditor
(
editor
:
EditorInput
=
this
.
activeEditor
):
void
{
if
(
editor
&&
!
this
.
_group
.
isPinned
(
editor
))
{
// Update model
this
.
_group
.
pin
(
editor
);
// Forward to title control
if
(
this
.
titleAreaControl
)
{
this
.
titleAreaControl
.
pinEditor
(
editor
);
}
}
}
//#endregion
//#endregion
//#region Themable
...
...
@@ -832,12 +824,12 @@ export class NextEditorGroupView extends Themable implements INextEditorGroupVie
readonly
element
:
HTMLElement
=
document
.
createElement
(
'
div
'
);
readonly
minimumWidth
=
170
;
readonly
minimumHeight
=
70
;
readonly
minimumWidth
=
NextEditorGroupView
.
EDITOR_MIN_WIDTH
;
readonly
minimumHeight
=
NextEditorGroupView
.
EDITOR_MIN_HEIGHT
;
readonly
maximumWidth
=
Number
.
POSITIVE_INFINITY
;
readonly
maximumHeight
=
Number
.
POSITIVE_INFINITY
;
get
onDidChange
()
{
return
Event
.
None
;
}
get
onDidChange
()
{
return
Event
.
None
;
}
// only needed if minimum sizes ever change
layout
(
width
:
number
,
height
:
number
):
void
{
this
.
_dimension
=
new
Dimension
(
width
,
height
);
...
...
src/vs/workbench/browser/parts/editor2/nextEditorPart.ts
浏览文件 @
e83b2322
...
...
@@ -154,22 +154,9 @@ export class NextEditorPart extends Part implements INextEditorGroupsService, IN
// Open Editor if we Copy
const
activeEditor
=
fromGroupView
.
activeEditor
;
if
(
copy
&&
activeEditor
)
{
// Copy over as much view state from active control as posisble
let
options
:
EditorOptions
;
const
activeCodeEditorControl
=
getCodeEditor
(
fromGroupView
.
activeControl
);
if
(
activeCodeEditorControl
)
{
options
=
TextEditorOptions
.
fromEditor
(
activeCodeEditorControl
);
}
else
{
options
=
new
EditorOptions
();
}
// Set pinned state accordingly
if
(
copy
===
CopyKind
.
GROUP
)
{
options
.
pinned
=
fromGroupView
.
isPinned
(
activeEditor
);
// copy group preserves all pinned state
}
else
{
options
.
pinned
=
true
;
// copy of single editor is a sign of importance, so pin it
}
const
options
=
activeCodeEditorControl
?
TextEditorOptions
.
fromEditor
(
activeCodeEditorControl
)
:
new
EditorOptions
();
options
.
pinned
=
(
copy
===
CopyKind
.
GROUP
)
?
fromGroupView
.
isPinned
(
activeEditor
)
:
true
;
newGroupView
.
openEditor
(
activeEditor
,
options
);
}
...
...
src/vs/workbench/browser/parts/editor2/nextNoTabsTitleControl.ts
浏览文件 @
e83b2322
...
...
@@ -129,7 +129,7 @@ export class NextNoTabsTitleControl extends NextTitleControl {
}
}
pr
otected
redraw
():
void
{
pr
ivate
redraw
():
void
{
const
editor
=
this
.
group
.
activeEditor
;
this
.
lastRenderedEditor
=
editor
;
...
...
@@ -138,10 +138,10 @@ export class NextNoTabsTitleControl extends NextTitleControl {
removeClass
(
this
.
titleContainer
,
'
dirty
'
);
this
.
editorLabel
.
clear
();
this
.
clearEditorActionsToolbar
();
return
;
}
// Otherwise render it
else
{
const
isEditorPinned
=
this
.
group
.
isPinned
(
this
.
group
.
activeEditor
);
const
isGroupActive
=
this
.
accessor
.
activeGroup
===
this
.
group
;
...
...
@@ -175,6 +175,7 @@ export class NextNoTabsTitleControl extends NextTitleControl {
// Update Editor Actions Toolbar
this
.
updateEditorActionsToolbar
();
}
}
private
getVerbosity
(
style
:
string
):
Verbosity
{
switch
(
style
)
{
...
...
src/vs/workbench/browser/parts/editor2/nextTabsTitleControl.ts
浏览文件 @
e83b2322
...
...
@@ -678,7 +678,7 @@ export class NextTabsTitleControl extends NextTitleControl {
}
}
pr
otected
redraw
():
void
{
pr
ivate
redraw
():
void
{
// For each tab
this
.
forEachTab
((
editor
,
index
,
tabContainer
,
tabLabelWidget
,
tabLabel
)
=>
{
...
...
@@ -751,6 +751,8 @@ export class NextTabsTitleControl extends NextTitleControl {
}
private
redrawEditorActive
(
isGroupActive
:
boolean
,
editor
:
IEditorInput
,
tabContainer
:
HTMLElement
,
tabLabelWidget
:
ResourceLabel
):
void
{
// Tab is active
if
(
this
.
group
.
activeEditor
===
editor
)
{
// Container
...
...
@@ -770,7 +772,10 @@ export class NextTabsTitleControl extends NextTitleControl {
// Label
tabLabelWidget
.
element
.
style
.
color
=
this
.
getColor
(
isGroupActive
?
TAB_ACTIVE_FOREGROUND
:
TAB_UNFOCUSED_ACTIVE_FOREGROUND
);
}
else
{
}
// Tab is inactive
else
{
// Containr
removeClass
(
tabContainer
,
'
active
'
);
...
...
src/vs/workbench/browser/parts/editor2/nextTitleControl.ts
浏览文件 @
e83b2322
...
...
@@ -95,8 +95,6 @@ export abstract class NextTitleControl extends Themable {
protected
abstract
create
(
parent
:
HTMLElement
):
void
;
protected
abstract
redraw
():
void
;
protected
createEditorActionsToolBar
(
container
:
HTMLElement
):
void
{
this
.
editorActionsToolbar
=
this
.
_register
(
new
ToolBar
(
container
,
this
.
contextMenuService
,
{
actionItemProvider
:
action
=>
this
.
actionItemProvider
(
action
as
Action
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录