Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a0bfd49a
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,发现更多精彩内容 >>
提交
a0bfd49a
编写于
5月 23, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use replaceEditors() for BaseSaveFileAction
上级
5fcf4f07
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
31 deletion
+40
-31
src/vs/platform/editor/common/editor.ts
src/vs/platform/editor/common/editor.ts
+5
-0
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+5
-0
src/vs/workbench/parts/files/browser/editors/fileEditorInput.ts
.../workbench/parts/files/browser/editors/fileEditorInput.ts
+5
-1
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+20
-28
src/vs/workbench/parts/files/common/files.ts
src/vs/workbench/parts/files/common/files.ts
+2
-0
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+3
-2
未找到文件。
src/vs/platform/editor/common/editor.ts
浏览文件 @
a0bfd49a
...
...
@@ -44,6 +44,11 @@ export interface IResourceInput {
*/
mime
?:
string
;
/**
* The encoding of the text input if known.
*/
encoding
?:
string
;
/**
* Optional options to use when opening the text input.
*/
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
a0bfd49a
...
...
@@ -187,6 +187,11 @@ export interface IFileEditorInput extends IEditorInput, IEncodingSupport {
* Sets the absolute file resource URI this input is about.
*/
setResource
(
resource
:
URI
):
void
;
/**
* Sets the preferred encodingt to use for this input.
*/
setPreferredEncoding
(
encoding
:
string
):
void
;
}
/**
...
...
src/vs/workbench/parts/files/browser/editors/fileEditorInput.ts
浏览文件 @
a0bfd49a
...
...
@@ -43,7 +43,7 @@ export class FileEditorInput extends CommonFileEditorInput {
private
verboseDescription
:
string
;
/**
* An editor input whos contents are retrieved from file services.
* An editor input who
'
s contents are retrieved from file services.
*/
constructor
(
resource
:
URI
,
...
...
@@ -89,6 +89,10 @@ export class FileEditorInput extends CommonFileEditorInput {
this
.
mime
=
mime
;
}
public
setPreferredEncoding
(
encoding
:
string
):
void
{
this
.
preferredEncoding
=
encoding
;
}
public
getEncoding
():
string
{
let
textModel
=
CACHE
.
get
(
this
.
resource
);
if
(
textModel
)
{
...
...
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
a0bfd49a
...
...
@@ -28,7 +28,7 @@ import {EventType as WorkbenchEventType, EditorEvent} from 'vs/workbench/common/
import
{
LocalFileChangeEvent
,
VIEWLET_ID
,
ITextFileService
,
TextFileChangeEvent
,
EventType
as
FileEventType
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFileService
,
IFileStat
,
IImportResult
}
from
'
vs/platform/files/common/files
'
;
import
{
DiffEditorInput
,
toDiffLabel
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
asFileEditorInput
,
getUntitledOrFileResource
,
TextEditorOptions
,
EditorOptions
,
UntitledEditorInput
,
ConfirmResult
}
from
'
vs/workbench/common/editor
'
;
import
{
asFileEditorInput
,
getUntitledOrFileResource
,
EditorOptions
,
UntitledEditorInput
,
ConfirmResult
}
from
'
vs/workbench/common/editor
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/browser/editors/fileEditorInput
'
;
import
{
FileStat
,
NewStatPlaceholder
}
from
'
vs/workbench/parts/files/common/explorerViewModel
'
;
import
{
ExplorerView
}
from
'
vs/workbench/parts/files/browser/views/explorerView
'
;
...
...
@@ -40,7 +40,7 @@ import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/edito
import
{
IQuickOpenService
}
from
'
vs/workbench/services/quickopen/common/quickOpenService
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/common/viewletService
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Position
,
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
IInstantiationService
,
IConstructorSignature2
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IMessageService
,
IMessageWithAction
,
IConfirmation
,
Severity
,
CancelAction
}
from
'
vs/platform/message/common/message
'
;
...
...
@@ -1404,8 +1404,6 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
// Save As (or Save untitled with associated path)
if
(
this
.
isSaveAs
()
||
source
.
scheme
===
'
untitled
'
)
{
let
positionsOfSource
=
findSaveAsPositions
(
this
.
editorService
,
source
);
let
mimeOfSource
:
string
;
if
(
source
.
scheme
===
'
untitled
'
)
{
let
selectedMime
=
this
.
untitledEditorService
.
get
(
source
).
getMime
();
...
...
@@ -1423,9 +1421,10 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
}
let
selectionOfSource
:
Selection
;
if
(
positionsOfSource
.
length
)
{
const
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
instanceof
BaseTextEditor
&&
positionsOfSource
.
indexOf
(
activeEditor
.
position
)
>=
0
)
{
const
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
instanceof
BaseTextEditor
)
{
const
activeResource
=
getUntitledOrFileResource
(
activeEditor
.
input
);
if
(
activeResource
.
toString
()
===
source
.
toString
())
{
selectionOfSource
=
<
Selection
>
activeEditor
.
getSelection
();
}
}
...
...
@@ -1448,31 +1447,24 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
}
return
savePromise
.
then
((
target
)
=>
{
if
(
!
target
)
{
return
;
if
(
!
target
||
target
.
toString
()
===
source
.
toString
()
)
{
return
;
// save canceled or same resource used
}
// Reopen editors for the resource based on the positions
let
reopenPromise
=
TPromise
.
as
(
null
);
if
(
target
.
toString
()
!==
source
.
toString
()
&&
positionsOfSource
.
length
)
{
let
targetInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
target
,
mimeOfSource
,
encodingOfSource
);
let
options
=
new
TextEditorOptions
();
options
.
pinned
=
true
;
if
(
selectionOfSource
)
{
options
.
selection
(
selectionOfSource
.
startLineNumber
,
selectionOfSource
.
startColumn
,
selectionOfSource
.
endLineNumber
,
selectionOfSource
.
endColumn
);
const
replaceWith
:
IResourceInput
=
{
resource
:
target
,
mime
:
mimeOfSource
,
encoding
:
encodingOfSource
,
options
:
{
pinned
:
true
,
selection
:
selectionOfSource
}
};
reopenPromise
=
this
.
editorService
.
openEditors
(
positionsOfSource
.
map
(
p
=>
{
return
{
position
:
p
,
input
:
targetInput
,
options
};
}));
}
return
reopenPromise
;
return
this
.
editorService
.
replaceEditors
([{
toReplace
:
{
resource
:
source
},
replaceWith
:
replaceWith
}]).
then
(()
=>
true
);
});
}
...
...
src/vs/workbench/parts/files/common/files.ts
浏览文件 @
a0bfd49a
...
...
@@ -50,6 +50,8 @@ export abstract class FileEditorInput extends EditorInput implements IFileEditor
public
abstract
getMime
():
string
;
public
abstract
setPreferredEncoding
(
encoding
:
string
):
void
;
public
abstract
setEncoding
(
encoding
:
string
,
mode
:
EncodingMode
):
void
;
public
abstract
getEncoding
():
string
;
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
a0bfd49a
...
...
@@ -288,7 +288,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
// Base Text Editor Support for file resources
else
if
(
this
.
fileInputDescriptor
&&
resourceInput
.
resource
instanceof
URI
&&
resourceInput
.
resource
.
scheme
===
network
.
Schemas
.
file
)
{
return
this
.
createFileInput
(
resourceInput
.
resource
,
resourceInput
.
mime
);
return
this
.
createFileInput
(
resourceInput
.
resource
,
resourceInput
.
mime
,
resourceInput
.
encoding
);
}
// Treat an URI as ResourceEditorInput
...
...
@@ -302,10 +302,11 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
return
TPromise
.
as
<
EditorInput
>
(
null
);
}
private
createFileInput
(
resource
:
URI
,
mime
?:
string
):
TPromise
<
IFileEditorInput
>
{
private
createFileInput
(
resource
:
URI
,
mime
?:
string
,
encoding
?:
string
):
TPromise
<
IFileEditorInput
>
{
return
this
.
instantiationService
.
createInstance
(
this
.
fileInputDescriptor
).
then
((
typedFileInput
)
=>
{
typedFileInput
.
setResource
(
resource
);
typedFileInput
.
setMime
(
mime
||
guessMimeTypes
(
resource
.
fsPath
).
join
(
'
,
'
));
typedFileInput
.
setPreferredEncoding
(
encoding
);
return
typedFileInput
;
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录