Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
85d4bf7a
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,发现更多精彩内容 >>
提交
85d4bf7a
编写于
2月 09, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - make dnd fit for remote resources
上级
47c74f5a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
23 deletion
+24
-23
src/vs/workbench/browser/dnd.ts
src/vs/workbench/browser/dnd.ts
+24
-23
未找到文件。
src/vs/workbench/browser/dnd.ts
浏览文件 @
85d4bf7a
...
...
@@ -162,8 +162,8 @@ export class ResourcesDropHandler {
}
public
handleDrop
(
event
:
DragEvent
,
afterDrop
:
()
=>
void
,
targetPosition
:
Position
,
targetIndex
?:
number
):
void
{
const
resources
=
extractResources
(
event
).
filter
(
r
=>
r
.
resource
.
scheme
===
Schemas
.
file
||
r
.
resource
.
scheme
===
Schemas
.
untitled
);
if
(
!
r
esources
.
length
)
{
const
untitledOrFileResources
=
extractResources
(
event
).
filter
(
r
=>
this
.
fileService
.
canHandleResource
(
r
.
resource
)
||
r
.
resource
.
scheme
===
Schemas
.
untitled
);
if
(
!
untitledOrFileR
esources
.
length
)
{
return
;
}
...
...
@@ -171,26 +171,26 @@ export class ResourcesDropHandler {
return
this
.
windowService
.
focusWindow
().
then
(()
=>
{
// Check for special things being dropped
return
this
.
doHandleDrop
(
r
esources
).
then
(
isWorkspaceOpening
=>
{
return
this
.
doHandleDrop
(
untitledOrFileR
esources
).
then
(
isWorkspaceOpening
=>
{
if
(
isWorkspaceOpening
)
{
return
void
0
;
// return early if the drop operation resulted in this window changing to a workspace
}
// Add external ones to recently open list unless dropped resource is a workspace
const
externalResources
=
resources
.
filter
(
d
=>
d
.
isExternal
).
map
(
d
=>
d
.
resource
);
if
(
externalResources
.
length
)
{
this
.
windowsService
.
addRecentlyOpened
(
externalResources
.
map
(
resource
=>
resource
.
fsPath
));
const
resourcesToAddToHistory
=
untitledOrFileResources
.
filter
(
d
=>
d
.
isExternal
&&
d
.
resource
.
scheme
!==
Schemas
.
untitled
).
map
(
d
=>
d
.
resource
);
if
(
resourcesToAddToHistory
.
length
)
{
this
.
windowsService
.
addRecentlyOpened
(
resourcesToAddToHistory
.
map
(
resource
=>
resource
.
fsPath
));
}
// Open in Editor
return
this
.
editorService
.
openEditors
(
resources
.
map
(
r
=>
{
return
this
.
editorService
.
openEditors
(
untitledOrFileResources
.
map
(
untitledOrFileResource
=>
{
return
{
input
:
{
resource
:
r
.
resource
,
resource
:
untitledOrFileResource
.
resource
,
options
:
{
pinned
:
true
,
index
:
targetIndex
,
viewState
:
(
r
as
IDraggedEditor
).
viewState
viewState
:
(
untitledOrFileResource
as
IDraggedEditor
).
viewState
}
},
position
:
targetPosition
...
...
@@ -204,17 +204,20 @@ export class ResourcesDropHandler {
}).
done
(
null
,
onUnexpectedError
);
}
private
doHandleDrop
(
r
esources
:
(
IDraggedResource
|
IDraggedEditor
)[]):
TPromise
<
boolean
>
{
private
doHandleDrop
(
untitledOrFileR
esources
:
(
IDraggedResource
|
IDraggedEditor
)[]):
TPromise
<
boolean
>
{
// Check for dirty editors being dropped
const
resourcesWithBackups
:
IDraggedEditor
[]
=
r
esources
.
filter
(
resource
=>
!
resource
.
isExternal
&&
!!
(
resource
as
IDraggedEditor
).
backupResource
);
const
resourcesWithBackups
:
IDraggedEditor
[]
=
untitledOrFileR
esources
.
filter
(
resource
=>
!
resource
.
isExternal
&&
!!
(
resource
as
IDraggedEditor
).
backupResource
);
if
(
resourcesWithBackups
.
length
>
0
)
{
return
TPromise
.
join
(
resourcesWithBackups
.
map
(
resourceWithBackup
=>
this
.
handleDirtyEditorDrop
(
resourceWithBackup
))).
then
(()
=>
false
);
}
// Check for workspace file being dropped if we are allowed to do so
if
(
this
.
options
.
allowWorkspaceOpen
&&
resources
.
some
(
r
=>
r
.
isExternal
))
{
return
this
.
handleWorkspaceFileDrop
(
resources
);
if
(
this
.
options
.
allowWorkspaceOpen
)
{
const
externalFileOnDiskResources
=
untitledOrFileResources
.
filter
(
d
=>
d
.
isExternal
&&
d
.
resource
.
scheme
===
Schemas
.
file
).
map
(
d
=>
d
.
resource
);
if
(
externalFileOnDiskResources
.
length
>
0
)
{
return
this
.
handleWorkspaceFileDrop
(
externalFileOnDiskResources
);
}
}
return
TPromise
.
as
(
false
);
...
...
@@ -249,31 +252,29 @@ export class ResourcesDropHandler {
return
DefaultEndOfLine
.
LF
;
}
private
handleWorkspaceFileDrop
(
resources
:
(
IDraggedResource
|
IDraggedEditor
)[]):
TPromise
<
boolean
>
{
const
externalResources
=
resources
.
filter
(
d
=>
d
.
isExternal
).
map
(
d
=>
d
.
resource
);
const
externalWorkspaceResources
:
{
workspaces
:
URI
[],
folders
:
URI
[]
}
=
{
private
handleWorkspaceFileDrop
(
fileOnDiskResources
:
URI
[]):
TPromise
<
boolean
>
{
const
workspaceResources
:
{
workspaces
:
URI
[],
folders
:
URI
[]
}
=
{
workspaces
:
[],
folders
:
[]
};
return
TPromise
.
join
(
externalResources
.
map
(
r
esource
=>
{
return
TPromise
.
join
(
fileOnDiskResources
.
map
(
fileOnDiskR
esource
=>
{
// Check for Workspace
if
(
extname
(
r
esource
.
fsPath
)
===
`.
${
WORKSPACE_EXTENSION
}
`
)
{
externalWorkspaceResources
.
workspaces
.
push
(
r
esource
);
if
(
extname
(
fileOnDiskR
esource
.
fsPath
)
===
`.
${
WORKSPACE_EXTENSION
}
`
)
{
workspaceResources
.
workspaces
.
push
(
fileOnDiskR
esource
);
return
void
0
;
}
// Check for Folder
return
this
.
fileService
.
resolveFile
(
r
esource
).
then
(
stat
=>
{
return
this
.
fileService
.
resolveFile
(
fileOnDiskR
esource
).
then
(
stat
=>
{
if
(
stat
.
isDirectory
)
{
externalW
orkspaceResources
.
folders
.
push
(
stat
.
resource
);
w
orkspaceResources
.
folders
.
push
(
stat
.
resource
);
}
},
error
=>
void
0
);
})).
then
(
_
=>
{
const
{
workspaces
,
folders
}
=
externalW
orkspaceResources
;
const
{
workspaces
,
folders
}
=
w
orkspaceResources
;
// Return early if no external resource is a folder or workspace
if
(
workspaces
.
length
===
0
&&
folders
.
length
===
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录