Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ef13c350
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,发现更多精彩内容 >>
提交
ef13c350
编写于
4月 10, 2019
作者:
A
Alex Ross
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix more remote file picker edge cases
Fixes #71963
上级
4cce7c07
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
34 deletion
+40
-34
src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts
...vs/workbench/services/dialogs/browser/remoteFileDialog.ts
+40
-34
未找到文件。
src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts
浏览文件 @
ef13c350
...
...
@@ -135,7 +135,7 @@ export class RemoteFileDialog {
private
remoteUriFrom
(
path
:
string
):
URI
{
path
=
path
.
replace
(
/
\\
/g
,
'
/
'
);
return
URI
.
from
({
scheme
:
this
.
scheme
,
authority
:
this
.
remoteAuthority
,
path
}
);
return
resources
.
toLocalResource
(
URI
.
from
({
scheme
:
this
.
scheme
,
path
}),
this
.
remoteAuthority
);
}
private
getScheme
(
defaultUri
:
URI
|
undefined
,
available
:
string
[]
|
undefined
):
string
{
...
...
@@ -188,6 +188,8 @@ export class RemoteFileDialog {
let
isResolving
=
false
;
let
isAcceptHandled
=
false
;
this
.
currentFolder
=
homedir
;
this
.
userEnteredPathSegment
=
''
;
this
.
autoCompletePathSegment
=
''
;
this
.
filePickBox
.
buttons
=
[
this
.
acceptButton
];
this
.
filePickBox
.
onDidTriggerButton
(
_
=>
{
// accept button
...
...
@@ -362,12 +364,12 @@ export class RemoteFileDialog {
}
catch
(
e
)
{
// do nothing
}
if
(
stat
&&
stat
.
isDirectory
&&
(
resources
.
basename
(
valueUri
)
!==
'
.
'
))
{
if
(
stat
&&
stat
.
isDirectory
&&
(
resources
.
basename
(
valueUri
)
!==
'
.
'
)
&&
this
.
endsWithSlash
(
value
)
)
{
await
this
.
updateItems
(
valueUri
);
return
true
;
}
else
{
const
inputUriDirname
=
resources
.
dirname
(
valueUri
);
if
(
!
resources
.
isEqual
(
this
.
currentFolder
,
inputUriDirname
,
true
))
{
if
(
!
resources
.
isEqual
(
this
.
remoteUriFrom
(
this
.
trimTrailingSlash
(
this
.
pathFromUri
(
this
.
currentFolder
)))
,
inputUriDirname
,
true
))
{
let
statWithoutTrailing
:
IFileStat
|
undefined
;
try
{
statWithoutTrailing
=
await
this
.
fileService
.
resolve
(
inputUriDirname
);
...
...
@@ -386,8 +388,9 @@ export class RemoteFileDialog {
private
setActiveItems
(
value
:
string
)
{
const
inputBasename
=
resources
.
basename
(
this
.
remoteUriFrom
(
value
));
if
((
value
!==
this
.
constructFullUserPath
().
substring
(
0
,
value
.
length
))
&&
resources
.
isEqual
(
resources
.
dirname
(
this
.
remoteUriFrom
(
this
.
filePickBox
.
value
)),
this
.
currentFolder
,
true
))
{
// Make sure that the folder whose children we are currently viewing matches the path in the input
const
userPath
=
this
.
constructFullUserPath
();
if
(
userPath
===
value
.
substring
(
0
,
userPath
.
length
))
{
let
hasMatch
=
false
;
for
(
let
i
=
0
;
i
<
this
.
filePickBox
.
items
.
length
;
i
++
)
{
const
item
=
<
FileQuickPickItem
>
this
.
filePickBox
.
items
[
i
];
...
...
@@ -402,40 +405,42 @@ export class RemoteFileDialog {
this
.
filePickBox
.
activeItems
=
[];
}
}
else
{
this
.
userEnteredPathSegment
=
inputBasename
;
if
(
inputBasename
!==
resources
.
basename
(
this
.
currentFolder
))
{
this
.
userEnteredPathSegment
=
inputBasename
;
}
else
{
this
.
userEnteredPathSegment
=
''
;
}
this
.
autoCompletePathSegment
=
''
;
}
}
private
setAutoComplete
(
startingValue
:
string
,
startingBasename
:
string
,
quickPickItem
:
FileQuickPickItem
,
force
:
boolean
=
false
):
boolean
{
const
itemBasename
=
(
quickPickItem
.
label
===
'
..
'
)
?
quickPickItem
.
label
:
resources
.
basename
(
quickPickItem
.
uri
);
const
itemPathLabel
=
(
itemBasename
===
'
..
'
)
?
this
.
pathAppend
(
this
.
currentFolder
,
itemBasename
)
:
this
.
pathFromUri
(
quickPickItem
.
uri
);
if
(
!
equalsIgnoreCase
(
this
.
trimTrailingSlash
(
this
.
filePickBox
.
value
),
itemPathLabel
))
{
// Either force the autocomplete, or the old value should be one smaller than the new value and match the new value.
if
(
!
force
&&
(
itemBasename
.
length
>=
startingBasename
.
length
+
1
)
&&
equalsIgnoreCase
(
itemBasename
.
substr
(
0
,
startingBasename
.
length
),
startingBasename
))
{
this
.
userEnteredPathSegment
=
startingBasename
;
this
.
activeItem
=
quickPickItem
;
// Changing the active items will trigger the onDidActiveItemsChanged. Clear the autocomplete first, then set it after.
this
.
autoCompletePathSegment
=
''
;
this
.
filePickBox
.
activeItems
=
[
quickPickItem
];
this
.
autoCompletePathSegment
=
itemBasename
.
substr
(
startingBasename
.
length
);
this
.
insertText
(
startingValue
+
this
.
autoCompletePathSegment
,
this
.
autoCompletePathSegment
);
this
.
filePickBox
.
valueSelection
=
[
startingValue
.
length
,
this
.
filePickBox
.
value
.
length
];
return
true
;
}
else
if
(
force
&&
(
quickPickItem
.
label
!==
(
this
.
userEnteredPathSegment
+
this
.
autoCompletePathSegment
)))
{
this
.
userEnteredPathSegment
=
''
;
this
.
autoCompletePathSegment
=
itemBasename
;
this
.
activeItem
=
quickPickItem
;
this
.
filePickBox
.
valueSelection
=
[
this
.
pathFromUri
(
this
.
currentFolder
,
true
).
length
,
this
.
filePickBox
.
value
.
length
];
// use insert text to preserve undo buffer
this
.
insertText
(
this
.
pathAppend
(
this
.
currentFolder
,
itemBasename
),
itemBasename
);
this
.
filePickBox
.
valueSelection
=
[
this
.
filePickBox
.
value
.
length
-
itemBasename
.
length
,
this
.
filePickBox
.
value
.
length
];
return
true
;
}
// Either force the autocomplete, or the old value should be one smaller than the new value and match the new value.
if
(
!
force
&&
(
itemBasename
.
length
>=
startingBasename
.
length
)
&&
equalsIgnoreCase
(
itemBasename
.
substr
(
0
,
startingBasename
.
length
),
startingBasename
))
{
this
.
userEnteredPathSegment
=
startingBasename
;
this
.
activeItem
=
quickPickItem
;
// Changing the active items will trigger the onDidActiveItemsChanged. Clear the autocomplete first, then set it after.
this
.
autoCompletePathSegment
=
''
;
this
.
filePickBox
.
activeItems
=
[
quickPickItem
];
this
.
autoCompletePathSegment
=
itemBasename
.
substr
(
startingBasename
.
length
);
this
.
insertText
(
startingValue
+
this
.
autoCompletePathSegment
,
this
.
autoCompletePathSegment
);
this
.
filePickBox
.
valueSelection
=
[
startingValue
.
length
,
this
.
filePickBox
.
value
.
length
];
return
true
;
}
else
if
(
force
&&
(
quickPickItem
.
label
!==
(
this
.
userEnteredPathSegment
+
this
.
autoCompletePathSegment
)))
{
this
.
userEnteredPathSegment
=
''
;
this
.
autoCompletePathSegment
=
itemBasename
;
this
.
activeItem
=
quickPickItem
;
this
.
filePickBox
.
valueSelection
=
[
this
.
pathFromUri
(
this
.
currentFolder
,
true
).
length
,
this
.
filePickBox
.
value
.
length
];
// use insert text to preserve undo buffer
this
.
insertText
(
this
.
pathAppend
(
this
.
currentFolder
,
itemBasename
),
itemBasename
);
this
.
filePickBox
.
valueSelection
=
[
this
.
filePickBox
.
value
.
length
-
itemBasename
.
length
,
this
.
filePickBox
.
value
.
length
];
return
true
;
}
else
{
this
.
userEnteredPathSegment
=
startingBasename
;
this
.
autoCompletePathSegment
=
''
;
return
false
;
}
this
.
userEnteredPathSegment
=
startingBasename
;
this
.
autoCompletePathSegment
=
''
;
return
false
;
}
private
insertText
(
wholeValue
:
string
,
insertText
:
string
)
{
...
...
@@ -554,11 +559,11 @@ export class RemoteFileDialog {
}
private
async
updateItems
(
newFolder
:
URI
,
trailing
?:
string
)
{
this
.
currentFolder
=
newFolder
;
this
.
userEnteredPathSegment
=
trailing
?
trailing
:
''
;
this
.
autoCompletePathSegment
=
''
;
this
.
filePickBox
.
valueSelection
=
[
0
,
this
.
filePickBox
.
value
.
length
];
const
newValue
=
trailing
?
this
.
pathFromUri
(
resources
.
joinPath
(
newFolder
,
trailing
))
:
this
.
pathFromUri
(
newFolder
,
true
);
this
.
currentFolder
=
this
.
remoteUriFrom
(
this
.
pathFromUri
(
newFolder
,
true
));
this
.
insertText
(
newValue
,
newValue
);
this
.
filePickBox
.
busy
=
true
;
return
this
.
createItems
(
this
.
currentFolder
).
then
(
items
=>
{
...
...
@@ -586,7 +591,8 @@ export class RemoteFileDialog {
private
pathAppend
(
uri
:
URI
,
additional
:
string
):
string
{
if
((
additional
===
'
..
'
)
||
(
additional
===
'
.
'
))
{
return
this
.
pathFromUri
(
uri
)
+
this
.
labelService
.
getSeparator
(
uri
.
scheme
,
uri
.
authority
)
+
additional
;
const
basePath
=
this
.
pathFromUri
(
uri
);
return
basePath
+
(
this
.
endsWithSlash
(
basePath
)
?
''
:
this
.
labelService
.
getSeparator
(
uri
.
scheme
,
uri
.
authority
))
+
additional
;
}
else
{
return
this
.
pathFromUri
(
resources
.
joinPath
(
uri
,
additional
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录