Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
edf44e41
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,发现更多精彩内容 >>
提交
edf44e41
编写于
5月 16, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some polish and bugfixing
上级
e346ba2b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
68 addition
and
53 deletion
+68
-53
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+33
-22
src/vs/workbench/browser/parts/editor/media/sidebyside.css
src/vs/workbench/browser/parts/editor/media/sidebyside.css
+4
-0
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
...workbench/browser/parts/editor/sideBySideEditorControl.ts
+28
-26
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+3
-5
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
edf44e41
...
...
@@ -717,8 +717,12 @@ export class EditorPart extends Part implements IEditorPart {
// Side by Side Control
this
.
sideBySideControl
=
this
.
instantiationService
.
createInstance
(
SideBySideEditorControl
,
contentArea
);
const
unbind
=
this
.
sideBySideControl
.
onGroupFocusChanged
(()
=>
this
.
onGroupFocusChanged
());
this
.
toUnbind
.
push
(()
=>
unbind
.
dispose
());
const
focusListener
=
this
.
sideBySideControl
.
onGroupFocusChanged
(()
=>
this
.
onGroupFocusChanged
());
this
.
toUnbind
.
push
(()
=>
focusListener
.
dispose
());
const
titleClickListener
=
this
.
sideBySideControl
.
onEditorTitleDoubleclick
((
position
)
=>
this
.
onEditorTitleDoubleclick
(
position
));
this
.
toUnbind
.
push
(()
=>
titleClickListener
.
dispose
());
// get settings
this
.
memento
=
this
.
getMemento
(
this
.
storageService
,
MementoScope
.
WORKSPACE
);
...
...
@@ -726,6 +730,32 @@ export class EditorPart extends Part implements IEditorPart {
return
contentArea
;
}
private
onGroupFocusChanged
():
void
{
// Update stacks model
let
activePosition
=
this
.
sideBySideControl
.
getActivePosition
();
if
(
typeof
activePosition
===
'
number
'
)
{
this
.
stacksModel
.
setActive
(
this
.
groupAt
(
activePosition
));
}
// Emit as editor input change event so that clients get aware of new active editor
let
activeEditor
=
this
.
sideBySideControl
.
getActiveEditor
();
if
(
activeEditor
)
{
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
activeEditor
,
activeEditor
.
getId
(),
activeEditor
.
input
,
null
,
activeEditor
.
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
activeEditor
,
activeEditor
.
getId
(),
activeEditor
.
input
,
null
,
activeEditor
.
position
));
}
// Update Title Area
this
.
doUpdateEditorTitleArea
();
}
private
onEditorTitleDoubleclick
(
position
:
Position
):
void
{
const
editor
=
this
.
visibleEditors
[
position
];
if
(
editor
)
{
this
.
pinEditor
(
position
,
editor
.
input
);
}
}
public
openEditors
(
editors
:
{
input
:
EditorInput
,
position
:
Position
,
options
?:
EditorOptions
}[]):
TPromise
<
BaseEditor
[]
>
{
if
(
!
editors
.
length
)
{
return
TPromise
.
as
<
BaseEditor
[]
>
([]);
...
...
@@ -749,7 +779,7 @@ export class EditorPart extends Part implements IEditorPart {
let
editorState
:
IEditorPartUIState
=
this
.
memento
[
EditorPart
.
EDITOR_PART_UI_STATE_STORAGE_KEY
];
let
widthRatios
=
editorState
.
widthRatio
;
let
activePosition
:
Position
;
let
activePosition
:
Position
;
if
(
this
.
stacksModel
.
groups
.
length
)
{
activePosition
=
this
.
stacksModel
.
positionOfGroup
(
this
.
stacksModel
.
activeGroup
);
}
...
...
@@ -893,25 +923,6 @@ export class EditorPart extends Part implements IEditorPart {
}
}
private
onGroupFocusChanged
():
void
{
// Update stacks model
let
activePosition
=
this
.
sideBySideControl
.
getActivePosition
();
if
(
typeof
activePosition
===
'
number
'
)
{
this
.
stacksModel
.
setActive
(
this
.
groupAt
(
activePosition
));
}
// Emit as editor input change event so that clients get aware of new active editor
let
activeEditor
=
this
.
sideBySideControl
.
getActiveEditor
();
if
(
activeEditor
)
{
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGING
,
new
EditorEvent
(
activeEditor
,
activeEditor
.
getId
(),
activeEditor
.
input
,
null
,
activeEditor
.
position
));
this
.
emit
(
WorkbenchEventType
.
EDITOR_INPUT_CHANGED
,
new
EditorEvent
(
activeEditor
,
activeEditor
.
getId
(),
activeEditor
.
input
,
null
,
activeEditor
.
position
));
}
// Update Title Area
this
.
doUpdateEditorTitleArea
();
}
private
doUpdateEditorTitleArea
():
void
{
if
(
this
.
sideBySideControl
)
{
const
titleAreaState
:
ITitleAreaState
[]
=
this
.
getVisibleEditors
().
map
((
e
,
index
)
=>
{
...
...
src/vs/workbench/browser/parts/editor/media/sidebyside.css
浏览文件 @
edf44e41
...
...
@@ -86,6 +86,10 @@
width
:
12px
;
/* move the actions close to the label */
}
.monaco-workbench
>
.part.editor
>
.content
.inactive
.title
.title-label-actions
{
opacity
:
0.5
;
}
.monaco-workbench
>
.part.editor
>
.content
>
.one-editor-container
>
.title
.title-label
{
padding-left
:
0
;
/* remove padding because we have the title label actions to the left */
}
...
...
src/vs/workbench/browser/parts/editor/sideBySideEditorControl.ts
浏览文件 @
edf44e41
...
...
@@ -26,7 +26,6 @@ import DOM = require('vs/base/browser/dom');
import
{
IActionItem
,
ActionsOrientation
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
import
{
IWorkbenchEditorService
,
GroupArrangement
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IQuickOpenService
}
from
'
vs/workbench/services/quickopen/common/quickOpenService
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
Position
,
POSITIONS
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
...
...
@@ -61,6 +60,7 @@ export interface ITitleAreaState {
export
interface
ISideBySideEditorControl
{
onGroupFocusChanged
:
Event
<
void
>
;
onEditorTitleDoubleclick
:
Event
<
Position
>
;
show
(
editor
:
BaseEditor
,
container
:
Builder
,
position
:
Position
,
preserveActive
:
boolean
,
widthRatios
?:
number
[]):
void
;
hide
(
editor
:
BaseEditor
,
container
:
Builder
,
position
:
Position
,
layoutAndRochade
:
boolean
):
Rochade
;
...
...
@@ -139,12 +139,12 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
private
visibleEditorFocusTrackers
:
DOM
.
IFocusTracker
[];
private
_onGroupFocusChanged
:
Emitter
<
void
>
;
private
_onEditorTitleDoubleclick
:
Emitter
<
Position
>
;
constructor
(
parent
:
Builder
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IMessageService
private
messageService
:
IMessageService
,
@
IQuickOpenService
private
quickOpenService
:
IQuickOpenService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IContextMenuService
private
contextMenuService
:
IContextMenuService
,
@
IEventService
private
eventService
:
IEventService
,
...
...
@@ -171,6 +171,7 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this
.
mapActionsToEditors
=
arrays
.
fill
(
POSITIONS
.
length
,
()
=>
Object
.
create
(
null
));
this
.
_onGroupFocusChanged
=
new
Emitter
<
void
>
();
this
.
_onEditorTitleDoubleclick
=
new
Emitter
<
Position
>
();
this
.
closeEditorAction
=
POSITIONS
.
map
((
position
)
=>
this
.
instantiationService
.
createInstance
(
CloseEditorAction
,
CLOSE_EDITOR_ACTION_ID
,
CLOSE_EDITOR_ACTION_LABEL
));
POSITIONS
.
map
((
position
)
=>
this
.
closeEditorAction
[
position
].
setPosition
(
position
)
||
(
this
.
closeEditorAction
[
position
].
class
=
'
close-editor-action
'
));
...
...
@@ -205,6 +206,10 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
return
this
.
_onGroupFocusChanged
.
event
;
}
public
get
onEditorTitleDoubleclick
():
Event
<
Position
>
{
return
this
.
_onEditorTitleDoubleclick
.
event
;
}
public
show
(
editor
:
BaseEditor
,
container
:
Builder
,
position
:
Position
,
preserveActive
:
boolean
,
widthRatios
?:
number
[]):
void
{
let
visibleEditorCount
=
this
.
getVisibleEditorCount
();
...
...
@@ -770,14 +775,19 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
}
private
fillTitleArea
(
parent
:
Builder
,
position
:
Position
):
void
{
let
ignoreClick
=
false
;
let
wasDragged
=
false
;
// Detect double click and emit
parent
.
on
(
DOM
.
EventType
.
DBLCLICK
,
(
e
:
MouseEvent
)
=>
{
DOM
.
EventHelper
.
stop
(
e
);
this
.
_onEditorTitleDoubleclick
.
fire
(
position
);
});
// Allow to reorder positions by dragging the title
parent
.
on
(
DOM
.
EventType
.
MOUSE_DOWN
,
(
e
:
MouseEvent
)
=>
{
// Reset flag
ignoreClick
=
false
;
wasDragged
=
false
;
// Return early if there is only one editor active or the user clicked into the toolbar
...
...
@@ -952,13 +962,8 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this
.
layoutContainers
();
}
// Ignore next click if the user dragged the title some distance
if
(
wasDragged
)
{
ignoreClick
=
true
;
}
// Otherwise if not dragging, make editor group active unless already active
else
if
(
position
!==
this
.
getActivePosition
())
{
// If not dragging, make editor group active unless already active
if
(
!
wasDragged
&&
position
!==
this
.
getActivePosition
())
{
this
.
editorService
.
focusGroup
(
position
);
}
...
...
@@ -990,25 +995,16 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this
.
editorTitleToolbar
[
position
].
setActions
([
this
.
closeEditorAction
[
position
]])();
});
// Left Title Labe
l (click opens quick open unless we are configured to ignore click or we are not the active title)
// Left Title Labe
parent
.
div
({
'
class
'
:
'
title-label
'
},
(
div
)
=>
{
let
clickHandler
=
(
e
:
MouseEvent
)
=>
{
if
(
ignoreClick
)
{
return
;
}
DOM
.
EventHelper
.
stop
(
e
,
true
);
this
.
quickOpenService
.
show
();
};
// Clickable label (focus editor and bring up quick open)
this
.
titleLabel
[
position
]
=
$
(
div
).
a
().
on
(
DOM
.
EventType
.
CLICK
,
clickHandler
);
// Label
this
.
titleLabel
[
position
]
=
$
(
div
).
a
();
// Subtle Description
this
.
titleDescription
[
position
]
=
$
(
div
).
span
()
.
on
(
DOM
.
EventType
.
CLICK
,
clickHandler
)
;
this
.
titleDescription
[
position
]
=
$
(
div
).
span
();
});
// Right Actions Container
...
...
@@ -1138,12 +1134,13 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
// Update all title areas that relate to given input if provided
if
(
arg1
instanceof
EditorInput
)
{
const
input
:
EditorInput
=
arg1
;
const
input
:
EditorInput
=
arg1
;
// Update the input title actions in each position according to the new status
POSITIONS
.
forEach
((
position
)
=>
{
if
(
this
.
visibleEditors
[
position
]
&&
isInputRelated
(
this
.
visibleEditors
[
position
].
input
,
input
))
{
this
.
closeEditorAction
[
position
].
class
=
!!
input
.
getStatus
().
decoration
?
'
close-editor-decorated-action
'
:
'
close-editor-action
'
;
const
status
=
input
.
getStatus
();
this
.
closeEditorAction
[
position
].
class
=
(
status
&&
status
.
decoration
)
?
'
close-editor-decorated-action
'
:
'
close-editor-action
'
;
}
});
}
...
...
@@ -1269,6 +1266,10 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
// Set Primary/Secondary Actions
this
.
editorActionsToolbar
[
position
].
setActions
(
primaryActions
,
secondaryActions
)();
// Update title actions accordingly
const
status
=
input
.
getStatus
();
this
.
closeEditorAction
[
position
].
class
=
(
status
&&
status
.
decoration
)
?
'
close-editor-decorated-action
'
:
'
close-editor-action
'
;
}
public
setLoading
(
position
:
Position
,
input
:
EditorInput
):
void
{
...
...
@@ -1659,5 +1660,6 @@ export class SideBySideEditorControl implements ISideBySideEditorControl, IVerti
this
.
visibleEditorContainers
=
null
;
this
.
_onGroupFocusChanged
.
dispose
();
this
.
_onEditorTitleDoubleclick
.
dispose
();
}
}
\ No newline at end of file
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
edf44e41
...
...
@@ -1465,9 +1465,9 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
if
(
target
.
toString
()
!==
source
.
toString
()
&&
positionsOfSource
.
length
)
{
let
targetInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
target
,
mimeOfSource
,
encodingOfSource
);
let
options
:
TextEditorOptions
;
let
options
=
new
TextEditorOptions
();
options
.
pinned
=
true
;
if
(
selectionOfSource
)
{
options
=
new
TextEditorOptions
();
options
.
selection
(
selectionOfSource
.
startLineNumber
,
selectionOfSource
.
startColumn
,
selectionOfSource
.
endLineNumber
,
selectionOfSource
.
endColumn
);
}
...
...
@@ -1592,9 +1592,7 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
let
encodingOfSource
:
string
=
mapUntitledToProperties
[
res
.
source
.
toString
()]
&&
mapUntitledToProperties
[
res
.
source
.
toString
()].
encoding
;
let
targetInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
res
.
target
,
mimeOfSource
,
encodingOfSource
);
let
options
=
new
EditorOptions
();
options
.
preserveFocus
=
true
;
let
options
=
EditorOptions
.
create
({
preserveFocus
:
true
,
pinned
:
true
});
positions
.
forEach
((
position
)
=>
{
reopenPromises
.
push
(()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录