Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d3082d70
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,发现更多精彩内容 >>
提交
d3082d70
编写于
5月 12, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - reduce drop operations a bit
上级
5e271907
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
33 deletion
+74
-33
src/vs/workbench/browser/dnd.ts
src/vs/workbench/browser/dnd.ts
+8
-0
src/vs/workbench/browser/parts/editor2/nextEditorDropTarget.ts
...s/workbench/browser/parts/editor2/nextEditorDropTarget.ts
+66
-33
未找到文件。
src/vs/workbench/browser/dnd.ts
浏览文件 @
d3082d70
...
...
@@ -469,6 +469,8 @@ export interface IDragAndDropObserverCallbacks {
onDragLeave
:
(
e
:
DragEvent
)
=>
void
;
onDrop
:
(
e
:
DragEvent
)
=>
void
;
onDragEnd
:
(
e
:
DragEvent
)
=>
void
;
onDragOver
?:
(
e
:
DragEvent
)
=>
void
;
}
export
class
DragAndDropObserver
extends
Disposable
{
...
...
@@ -492,6 +494,12 @@ export class DragAndDropObserver extends Disposable {
this
.
callbacks
.
onDragEnter
(
e
);
}));
this
.
_register
(
addDisposableListener
(
this
.
element
,
EventType
.
DRAG_OVER
,
(
e
:
DragEvent
)
=>
{
if
(
this
.
callbacks
.
onDragOver
)
{
this
.
callbacks
.
onDragOver
(
e
);
}
}));
this
.
_register
(
addDisposableListener
(
this
.
element
,
EventType
.
DRAG_LEAVE
,
(
e
:
DragEvent
)
=>
{
this
.
counter
--
;
...
...
src/vs/workbench/browser/parts/editor2/nextEditorDropTarget.ts
浏览文件 @
d3082d70
...
...
@@ -6,7 +6,7 @@
'
use strict
'
;
import
'
vs/css!./media/nextEditorDropTarget
'
;
import
{
LocalSelectionTransfer
,
DraggedEditorIdentifier
,
ResourcesDropHandler
,
DraggedEditorGroupIdentifier
}
from
'
vs/workbench/browser/dnd
'
;
import
{
LocalSelectionTransfer
,
DraggedEditorIdentifier
,
ResourcesDropHandler
,
DraggedEditorGroupIdentifier
,
DragAndDropObserver
}
from
'
vs/workbench/browser/dnd
'
;
import
{
addDisposableListener
,
EventType
,
EventHelper
,
isAncestor
,
toggleClass
,
addClass
}
from
'
vs/base/browser/dom
'
;
import
{
INextEditorGroupsAccessor
,
EDITOR_TITLE_HEIGHT
,
INextEditorGroupView
,
getActiveTextEditorOptions
}
from
'
vs/workbench/browser/parts/editor2/editor2
'
;
import
{
EDITOR_DRAG_AND_DROP_BACKGROUND
,
Themable
}
from
'
vs/workbench/common/theme
'
;
...
...
@@ -83,39 +83,38 @@ class DropOverlay extends Themable {
}
private
registerListeners
():
void
{
this
.
_register
(
new
DragAndDropObserver
(
this
.
container
,
{
onDragEnter
:
e
=>
void
0
,
onDragOver
:
e
=>
{
// Update the dropEffect to "copy" if there is no local data to be dragged because
// in that case we can only copy the data into and not move it from its source
if
(
!
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
)
&&
!
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
)
)
{
e
.
dataTransfer
.
dropEffect
=
'
copy
'
;
}
// Update position and drop effect on drag over
this
.
_register
(
addDisposableListener
(
this
.
container
,
EventType
.
DRAG_OVER
,
(
e
:
DragEvent
)
=>
{
// Update the dropEffect to "copy" if there is no local data to be dragged because
// in that case we can only copy the data into and not move it from its source
if
(
!
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
)
&&
!
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
)
)
{
e
.
dataTransfer
.
dropEffect
=
'
copy
'
;
}
// Position overlay
this
.
positionOverlay
(
e
.
offsetX
,
e
.
offsetY
);
},
// Position overlay
this
.
positionOverlay
(
e
.
offsetX
,
e
.
offsetY
);
}));
onDragLeave
:
e
=>
this
.
dispose
(),
onDragEnd
:
e
=>
this
.
dispose
(),
// Handle drop
this
.
_register
(
addDisposableListener
(
this
.
container
,
EventType
.
DROP
,
(
e
:
DragEvent
)
=>
{
EventHelper
.
stop
(
e
,
true
);
onDrop
:
e
=>
{
EventHelper
.
stop
(
e
,
true
);
// Dispose overlay
this
.
dispose
();
// Dispose overlay
this
.
dispose
();
// Handle drop
this
.
handleDrop
(
e
);
// Handle drop
this
.
handleDrop
(
e
);
}
}));
// Dispose on drag end
this
.
_register
(
addDisposableListener
(
this
.
container
,
EventType
.
DRAG_END
,
()
=>
this
.
dispose
()));
this
.
_register
(
addDisposableListener
(
this
.
container
,
EventType
.
DRAG_LEAVE
,
()
=>
this
.
dispose
()));
this
.
_register
(
addDisposableListener
(
this
.
container
,
EventType
.
MOUSE_OVER
,
()
=>
{
// Under some circumstances we have seen reports where the drop overlay is not being
// cleaned up and as such the editor area remains under the overlay so that you cannot
// type into the editor anymore. This seems related to using VMs and DND via host and
...
...
@@ -143,7 +142,7 @@ class DropOverlay extends Themable {
return
targetGroup
;
};
// Check for group transfer
from title control
// Check for group transfer
if
(
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
))
{
const
draggedEditorGroup
=
this
.
groupTransfer
.
getData
(
DraggedEditorGroupIdentifier
.
prototype
)[
0
].
identifier
;
...
...
@@ -176,7 +175,7 @@ class DropOverlay extends Themable {
this
.
groupTransfer
.
clearData
(
DraggedEditorGroupIdentifier
.
prototype
);
}
// Check for editor transfer
from title control
// Check for editor transfer
else
if
(
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
))
{
const
draggedEditor
=
this
.
editorTransfer
.
getData
(
DraggedEditorIdentifier
.
prototype
)[
0
].
identifier
;
const
targetGroup
=
ensureTargetGroup
();
...
...
@@ -335,6 +334,9 @@ export class NextEditorDropTarget extends Themable {
}
private
onDragEnter
(
event
:
DragEvent
):
void
{
this
.
counter
++
;
// Validate transfer
if
(
!
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
)
&&
!
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
)
&&
...
...
@@ -345,7 +347,6 @@ export class NextEditorDropTarget extends Themable {
}
// Signal DND start
this
.
counter
++
;
this
.
updateContainer
(
true
);
const
target
=
event
.
target
as
HTMLElement
;
...
...
@@ -358,10 +359,27 @@ export class NextEditorDropTarget extends Themable {
// Create overlay over target
if
(
!
this
.
overlay
)
{
const
groupView
=
this
.
findGroupView
(
target
);
if
(
groupView
)
{
this
.
_overlay
=
new
DropOverlay
(
this
.
accessor
,
groupView
,
this
.
themeService
,
this
.
instantiationService
);
const
sourceGroupView
=
this
.
findSourceGroupView
();
const
targetGroupView
=
this
.
findTargetGroupView
(
target
);
if
(
!
targetGroupView
)
{
return
;
// we need a target at least
}
if
(
sourceGroupView
===
targetGroupView
)
{
const
isGroupTransfer
=
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
);
if
(
isGroupTransfer
)
{
return
;
// do not allow to drop group on itself
}
const
isEditorTransfer
=
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
);
if
(
isEditorTransfer
&&
sourceGroupView
.
count
<
2
)
{
return
;
// do not allow to drop editor on itself unless there are 2 editors at least
}
}
// Show overlay
this
.
_overlay
=
new
DropOverlay
(
this
.
accessor
,
targetGroupView
,
this
.
themeService
,
this
.
instantiationService
);
}
}
}
...
...
@@ -381,7 +399,22 @@ export class NextEditorDropTarget extends Themable {
this
.
disposeOverlay
();
}
private
findGroupView
(
child
:
HTMLElement
):
INextEditorGroupView
{
private
findSourceGroupView
():
INextEditorGroupView
{
// Check for group transfer
if
(
this
.
groupTransfer
.
hasData
(
DraggedEditorGroupIdentifier
.
prototype
))
{
return
this
.
accessor
.
getGroup
(
this
.
groupTransfer
.
getData
(
DraggedEditorGroupIdentifier
.
prototype
)[
0
].
identifier
);
}
// Check for editor transfer
else
if
(
this
.
editorTransfer
.
hasData
(
DraggedEditorIdentifier
.
prototype
))
{
return
this
.
accessor
.
getGroup
(
this
.
editorTransfer
.
getData
(
DraggedEditorIdentifier
.
prototype
)[
0
].
identifier
.
group
.
id
);
}
return
void
0
;
}
private
findTargetGroupView
(
child
:
HTMLElement
):
INextEditorGroupView
{
const
groups
=
this
.
accessor
.
groups
;
for
(
let
i
=
0
;
i
<
groups
.
length
;
i
++
)
{
const
groupView
=
groups
[
i
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录