Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
985de26b
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
985de26b
编写于
6月 18, 2019
作者:
A
Alex Ross
提交者:
GitHub
6月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add availableFileSystems to save as (#75681)
This adds the suggested filename to the local path
上级
d6b3a85b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
19 deletion
+29
-19
src/vs/workbench/browser/actions/workspaceActions.ts
src/vs/workbench/browser/actions/workspaceActions.ts
+11
-3
src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts
...vs/workbench/services/dialogs/browser/remoteFileDialog.ts
+11
-11
src/vs/workbench/services/textfile/common/textFileService.ts
src/vs/workbench/services/textfile/common/textFileService.ts
+6
-5
src/vs/workbench/services/textfile/common/textfiles.ts
src/vs/workbench/services/textfile/common/textfiles.ts
+1
-0
未找到文件。
src/vs/workbench/browser/actions/workspaceActions.ts
浏览文件 @
985de26b
...
...
@@ -17,6 +17,9 @@ import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
ITextFileService
,
ISaveOptions
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
toResource
}
from
'
vs/workbench/common/editor
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
class
OpenFileAction
extends
Action
{
...
...
@@ -62,13 +65,18 @@ export class SaveLocalFileAction extends Action {
constructor
(
id
:
string
,
label
:
string
,
@
IFileDialogService
private
readonly
dialogService
:
IFileDialogService
@
ITextFileService
private
readonly
textFileService
:
ITextFileService
,
@
IEditorService
private
readonly
editorService
:
IEditorService
)
{
super
(
id
,
label
);
}
run
(
event
?:
any
,
data
?:
ITelemetryData
):
Promise
<
any
>
{
return
this
.
dialogService
.
pickFileToSave
({
availableFileSystems
:
[
Schemas
.
file
]
});
async
run
(
event
?:
any
,
data
?:
ITelemetryData
):
Promise
<
any
>
{
let
resource
:
URI
|
undefined
=
toResource
(
this
.
editorService
.
activeEditor
);
const
options
:
ISaveOptions
=
{
force
:
true
,
availableFileSystems
:
[
Schemas
.
file
]
};
if
(
resource
)
{
return
this
.
textFileService
.
saveAs
(
resource
,
undefined
,
options
);
}
}
}
...
...
src/vs/workbench/services/dialogs/browser/remoteFileDialog.ts
浏览文件 @
985de26b
...
...
@@ -98,7 +98,7 @@ export class RemoteFileDialog {
}
public
async
showOpenDialog
(
options
:
IOpenDialogOptions
=
{}):
Promise
<
URI
|
undefined
>
{
this
.
scheme
=
this
.
getScheme
(
options
.
defaultUri
,
options
.
availableFileSystems
);
this
.
scheme
=
this
.
getScheme
(
options
.
availableFileSystems
);
this
.
userHome
=
await
this
.
getUserHome
();
const
newOptions
=
await
this
.
getOptions
(
options
);
if
(
!
newOptions
)
{
...
...
@@ -109,7 +109,7 @@ export class RemoteFileDialog {
}
public
async
showSaveDialog
(
options
:
ISaveDialogOptions
):
Promise
<
URI
|
undefined
>
{
this
.
scheme
=
this
.
getScheme
(
options
.
defaultUri
,
options
.
availableFileSystems
);
this
.
scheme
=
this
.
getScheme
(
options
.
availableFileSystems
);
this
.
userHome
=
await
this
.
getUserHome
();
this
.
requiresTrailing
=
true
;
const
newOptions
=
await
this
.
getOptions
(
options
,
true
);
...
...
@@ -128,9 +128,13 @@ export class RemoteFileDialog {
}
private
getOptions
(
options
:
ISaveDialogOptions
|
IOpenDialogOptions
,
isSave
:
boolean
=
false
):
IOpenDialogOptions
|
undefined
{
let
defaultUri
=
options
.
defaultUri
;
const
filename
=
(
defaultUri
&&
isSave
&&
(
resources
.
dirname
(
defaultUri
).
path
===
'
/
'
))
?
resources
.
basename
(
defaultUri
)
:
undefined
;
if
(
!
defaultUri
||
filename
)
{
let
defaultUri
:
URI
|
undefined
=
undefined
;
let
filename
:
string
|
undefined
=
undefined
;
if
(
options
.
defaultUri
)
{
defaultUri
=
(
this
.
scheme
===
options
.
defaultUri
.
scheme
)
?
options
.
defaultUri
:
undefined
;
filename
=
isSave
?
resources
.
basename
(
options
.
defaultUri
)
:
undefined
;
}
if
(
!
defaultUri
)
{
defaultUri
=
this
.
userHome
;
if
(
filename
)
{
defaultUri
=
resources
.
joinPath
(
defaultUri
,
filename
);
...
...
@@ -150,8 +154,8 @@ export class RemoteFileDialog {
return
resources
.
toLocalResource
(
URI
.
from
({
scheme
:
this
.
scheme
,
path
}),
this
.
scheme
===
Schemas
.
file
?
undefined
:
this
.
remoteAuthority
);
}
private
getScheme
(
defaultUri
:
URI
|
undefined
,
available
:
string
[]
|
undefined
):
string
{
return
defaultUri
?
defaultUri
.
scheme
:
(
available
?
available
[
0
]
:
Schemas
.
file
)
;
private
getScheme
(
available
:
string
[]
|
undefined
):
string
{
return
available
?
available
[
0
]
:
Schemas
.
file
;
}
private
async
getRemoteAgentEnvironment
():
Promise
<
IRemoteAgentEnvironment
|
null
>
{
...
...
@@ -254,12 +258,8 @@ export class RemoteFileDialog {
if
(
this
.
options
.
availableFileSystems
&&
(
this
.
options
.
availableFileSystems
.
length
>
1
))
{
this
.
options
.
availableFileSystems
.
shift
();
}
this
.
options
.
defaultUri
=
undefined
;
this
.
filePickBox
.
hide
();
if
(
isSave
)
{
// Remove defaultUri and filters to get a consistant experience with the keybinding.
this
.
options
.
defaultUri
=
undefined
;
this
.
options
.
filters
=
undefined
;
return
this
.
fileDialogService
.
showSaveDialog
(
this
.
options
).
then
(
result
=>
{
doResolve
(
this
,
result
);
});
...
...
src/vs/workbench/services/textfile/common/textFileService.ts
浏览文件 @
985de26b
...
...
@@ -648,18 +648,19 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
return
result
;
}
protected
async
promptForPath
(
resource
:
URI
,
defaultUri
:
URI
):
Promise
<
URI
|
undefined
>
{
protected
async
promptForPath
(
resource
:
URI
,
defaultUri
:
URI
,
availableFileSystems
?:
string
[]
):
Promise
<
URI
|
undefined
>
{
// Help user to find a name for the file by opening it first
await
this
.
editorService
.
openEditor
({
resource
,
options
:
{
revealIfOpened
:
true
,
preserveFocus
:
true
,
}
});
return
this
.
fileDialogService
.
pickFileToSave
(
this
.
getSaveDialogOptions
(
defaultUri
));
return
this
.
fileDialogService
.
pickFileToSave
(
this
.
getSaveDialogOptions
(
defaultUri
,
availableFileSystems
));
}
private
getSaveDialogOptions
(
defaultUri
:
URI
):
ISaveDialogOptions
{
private
getSaveDialogOptions
(
defaultUri
:
URI
,
availableFileSystems
?:
string
[]
):
ISaveDialogOptions
{
const
options
:
ISaveDialogOptions
=
{
defaultUri
,
title
:
nls
.
localize
(
'
saveAsTitle
'
,
"
Save As
"
)
title
:
nls
.
localize
(
'
saveAsTitle
'
,
"
Save As
"
),
availableFileSystems
,
};
// Filters are only enabled on Windows where they work properly
...
...
@@ -765,7 +766,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
dialogPath
=
this
.
suggestFileName
(
resource
);
}
targetResource
=
await
this
.
promptForPath
(
resource
,
dialogPath
);
targetResource
=
await
this
.
promptForPath
(
resource
,
dialogPath
,
options
?
options
.
availableFileSystems
:
undefined
);
}
if
(
!
targetResource
)
{
...
...
src/vs/workbench/services/textfile/common/textfiles.ts
浏览文件 @
985de26b
...
...
@@ -428,6 +428,7 @@ export interface ISaveOptions {
overwriteEncoding
?:
boolean
;
skipSaveParticipants
?:
boolean
;
writeElevated
?:
boolean
;
availableFileSystems
?:
string
[];
}
export
interface
ILoadOptions
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录