Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
d1023ee9
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,发现更多精彩内容 >>
提交
d1023ee9
编写于
10月 04, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt: no more mime in editor service
上级
ab011457
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
14 addition
and
41 deletion
+14
-41
src/vs/platform/editor/common/editor.ts
src/vs/platform/editor/common/editor.ts
+0
-5
src/vs/workbench/parts/files/browser/editors/textFileEditor.ts
...s/workbench/parts/files/browser/editors/textFileEditor.ts
+1
-2
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+2
-18
src/vs/workbench/parts/files/browser/views/explorerView.ts
src/vs/workbench/parts/files/browser/views/explorerView.ts
+1
-1
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
+1
-1
src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts
...workbench/parts/files/common/editors/fileEditorTracker.ts
+3
-4
src/vs/workbench/parts/git/browser/gitActions.contribution.ts
...vs/workbench/parts/git/browser/gitActions.contribution.ts
+0
-1
src/vs/workbench/parts/git/browser/gitActions.ts
src/vs/workbench/parts/git/browser/gitActions.ts
+0
-2
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+4
-4
src/vs/workbench/test/browser/services.test.ts
src/vs/workbench/test/browser/services.test.ts
+2
-3
未找到文件。
src/vs/platform/editor/common/editor.ts
浏览文件 @
d1023ee9
...
...
@@ -52,11 +52,6 @@ export interface IResourceInput {
*/
resource
:
URI
;
/**
* The mime type of the text input if known.
*/
mime
?:
string
;
/**
* The encoding of the text input if known.
*/
...
...
src/vs/workbench/parts/files/browser/editors/textFileEditor.ts
浏览文件 @
d1023ee9
...
...
@@ -8,7 +8,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
nls
=
require
(
'
vs/nls
'
);
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
{
MIME_BINARY
,
MIME_TEXT
}
from
'
vs/base/common/mime
'
;
import
{
MIME_BINARY
}
from
'
vs/base/common/mime
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
{
IEditorViewState
}
from
'
vs/editor/common/editorCommon
'
;
...
...
@@ -182,7 +182,6 @@ export class TextFileEditor extends BaseTextEditor {
// Open
return
this
.
editorService
.
openEditor
({
resource
:
input
.
getResource
(),
mime
:
MIME_TEXT
,
options
:
{
pinned
:
true
// new file gets pinned by default
}
...
...
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
d1023ee9
...
...
@@ -10,7 +10,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
nls
=
require
(
'
vs/nls
'
);
import
{
isWindows
,
isLinux
,
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
sequence
,
ITask
}
from
'
vs/base/common/async
'
;
import
{
MIME_TEXT
,
isUnspecific
,
isBinaryMime
,
guessMimeTypes
}
from
'
vs/base/common/mime
'
;
import
{
isBinaryMime
,
guessMimeTypes
}
from
'
vs/base/common/mime
'
;
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
errors
=
require
(
'
vs/base/common/errors
'
);
...
...
@@ -1422,14 +1422,6 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
// Save As (or Save untitled with associated path)
if
(
this
.
isSaveAs
()
||
source
.
scheme
===
'
untitled
'
)
{
let
mimeOfSource
:
string
;
if
(
source
.
scheme
===
'
untitled
'
)
{
const
selectedMime
=
this
.
untitledEditorService
.
get
(
source
).
getMime
();
if
(
!
isUnspecific
(
selectedMime
))
{
mimeOfSource
=
[
selectedMime
,
MIME_TEXT
].
join
(
'
,
'
);
}
}
let
encodingOfSource
:
string
;
if
(
source
.
scheme
===
'
untitled
'
)
{
encodingOfSource
=
this
.
untitledEditorService
.
get
(
source
).
getEncoding
();
...
...
@@ -1471,7 +1463,6 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
const
replaceWith
:
IResourceInput
=
{
resource
:
target
,
mime
:
mimeOfSource
,
encoding
:
encodingOfSource
,
options
:
{
pinned
:
true
,
...
...
@@ -1563,14 +1554,13 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
const
stacks
=
this
.
editorGroupService
.
getStacksModel
();
// Store some properties per untitled file to restore later after save is completed
const
mapUntitledToProperties
:
{
[
resource
:
string
]:
{
mime
:
string
;
encoding
:
string
;
indexInGroups
:
number
[];
activeInGroups
:
boolean
[]
}
}
=
Object
.
create
(
null
);
const
mapUntitledToProperties
:
{
[
resource
:
string
]:
{
encoding
:
string
;
indexInGroups
:
number
[];
activeInGroups
:
boolean
[]
}
}
=
Object
.
create
(
null
);
this
.
textFileService
.
getDirty
()
.
filter
(
r
=>
r
.
scheme
===
'
untitled
'
)
// All untitled resources
.
map
(
r
=>
this
.
untitledEditorService
.
get
(
r
))
// Mapped to their inputs
.
filter
(
input
=>
!!
input
)
// If possible :)
.
forEach
(
input
=>
{
mapUntitledToProperties
[
input
.
getResource
().
toString
()]
=
{
mime
:
input
.
getMime
(),
encoding
:
input
.
getEncoding
(),
indexInGroups
:
stacks
.
groups
.
map
(
g
=>
g
.
indexOf
(
input
)),
activeInGroups
:
stacks
.
groups
.
map
(
g
=>
g
.
isActive
(
input
))
...
...
@@ -1593,18 +1583,12 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
return
;
}
let
mimeOfSource
:
string
;
if
(
!
isUnspecific
(
untitledProps
.
mime
))
{
mimeOfSource
=
[
untitledProps
.
mime
,
MIME_TEXT
].
join
(
'
,
'
);
}
// For each position where the untitled file was opened
untitledProps
.
indexInGroups
.
forEach
((
indexInGroup
,
index
)
=>
{
if
(
indexInGroup
>=
0
)
{
untitledToReopen
.
push
({
input
:
{
resource
:
result
.
target
,
mime
:
mimeOfSource
,
encoding
:
untitledProps
.
encoding
,
options
:
{
pinned
:
true
,
...
...
src/vs/workbench/parts/files/browser/views/explorerView.ts
浏览文件 @
d1023ee9
...
...
@@ -282,7 +282,7 @@ export class ExplorerView extends CollapsibleViewletView {
private
openFocusedElement
(
preserveFocus
?:
boolean
):
void
{
const
stat
:
FileStat
=
this
.
explorerViewer
.
getFocus
();
if
(
stat
&&
!
stat
.
isDirectory
)
{
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
mime
:
stat
.
mime
,
options
:
{
preserveFocus
,
revealIfVisible
:
true
}
}).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
options
:
{
preserveFocus
,
revealIfVisible
:
true
}
}).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
...
...
src/vs/workbench/parts/files/browser/views/explorerViewer.ts
浏览文件 @
d1023ee9
...
...
@@ -611,7 +611,7 @@ export class FileController extends DefaultController {
if
(
stat
&&
!
stat
.
isDirectory
)
{
this
.
telemetryService
.
publicLog
(
'
workbenchActionExecuted
'
,
{
id
:
'
workbench.files.openFile
'
,
from
:
'
explorer
'
});
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
mime
:
stat
.
mime
,
options
:
{
preserveFocus
,
pinned
}
},
sideBySide
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
options
:
{
preserveFocus
,
pinned
}
},
sideBySide
).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
...
...
src/vs/workbench/parts/files/common/editors/fileEditorTracker.ts
浏览文件 @
d1023ee9
...
...
@@ -6,7 +6,6 @@
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
{
MIME_UNKNOWN
}
from
'
vs/base/common/mime
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
...
...
@@ -71,11 +70,11 @@ export class FileEditorTracker implements IWorkbenchContribution {
const
before
=
e
.
getBefore
();
const
after
=
e
.
getAfter
();
this
.
handleMovedFileInOpenedEditors
(
before
?
before
.
resource
:
null
,
after
?
after
.
resource
:
null
,
after
?
after
.
mime
:
null
);
this
.
handleMovedFileInOpenedEditors
(
before
?
before
.
resource
:
null
,
after
?
after
.
resource
:
null
);
}
}
private
handleMovedFileInOpenedEditors
(
oldResource
:
URI
,
newResource
:
URI
,
mimeHint
?:
string
):
void
{
private
handleMovedFileInOpenedEditors
(
oldResource
:
URI
,
newResource
:
URI
):
void
{
const
stacks
=
this
.
editorGroupService
.
getStacksModel
();
stacks
.
groups
.
forEach
(
group
=>
{
group
.
getEditors
().
forEach
(
input
=>
{
...
...
@@ -93,7 +92,7 @@ export class FileEditorTracker implements IWorkbenchContribution {
}
// Reopen
this
.
editorService
.
openEditor
({
resource
:
reopenFileResource
,
mime
:
mimeHint
||
MIME_UNKNOWN
,
options
:
{
preserveFocus
:
true
,
pinned
:
group
.
isPinned
(
input
),
index
:
group
.
indexOf
(
input
),
inactive
:
!
group
.
isActive
(
input
)
}
},
stacks
.
positionOfGroup
(
group
)).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
editorService
.
openEditor
({
resource
:
reopenFileResource
,
options
:
{
preserveFocus
:
true
,
pinned
:
group
.
isPinned
(
input
),
index
:
group
.
indexOf
(
input
),
inactive
:
!
group
.
isActive
(
input
)
}
},
stacks
.
positionOfGroup
(
group
)).
done
(
null
,
errors
.
onUnexpectedError
);
}
}
});
...
...
src/vs/workbench/parts/git/browser/gitActions.contribution.ts
浏览文件 @
d1023ee9
...
...
@@ -189,7 +189,6 @@ class OpenInEditorAction extends baseeditor.EditorInputAction {
return
this
.
fileService
.
resolveFile
(
resource
).
then
(
stat
=>
{
return
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
mime
:
stat
.
mime
,
options
:
{
forceOpen
:
true
}
...
...
src/vs/workbench/parts/git/browser/gitActions.ts
浏览文件 @
d1023ee9
...
...
@@ -173,7 +173,6 @@ export class OpenFileAction extends GitAction {
return
this
.
fileService
.
resolveFile
(
resource
)
.
then
(
stat
=>
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
mime
:
stat
.
mime
,
options
:
{
forceOpen
:
true
}
}));
}
...
...
@@ -395,7 +394,6 @@ export abstract class BaseUndoAction extends GitAction {
return
this
.
fileService
.
resolveFile
(
this
.
contextService
.
toResource
(
path
)).
then
((
stat
:
IFileStat
)
=>
{
return
this
.
editorService
.
openEditor
({
resource
:
stat
.
resource
,
mime
:
stat
.
mime
,
options
:
{
forceOpen
:
true
}
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
d1023ee9
...
...
@@ -6,8 +6,8 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
network
=
require
(
'
vs/base/common/network
'
);
import
{
guessMimeTypes
}
from
'
vs/base/common/mime
'
;
import
network
=
require
(
'
vs/base/common/network
'
);
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
basename
,
dirname
}
from
'
vs/base/common/paths
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
...
...
@@ -263,7 +263,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
,
resourceInput
.
encoding
);
return
this
.
createFileInput
(
resourceInput
.
resource
,
resourceInput
.
encoding
);
}
// Treat an URI as ResourceEditorInput
...
...
@@ -277,10 +277,10 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
return
TPromise
.
as
<
EditorInput
>
(
null
);
}
private
createFileInput
(
resource
:
URI
,
mime
?:
string
,
encoding
?:
string
):
TPromise
<
IFileEditorInput
>
{
private
createFileInput
(
resource
:
URI
,
encoding
?:
string
):
TPromise
<
IFileEditorInput
>
{
return
this
.
instantiationService
.
createInstance
(
this
.
fileInputDescriptor
).
then
((
typedFileInput
)
=>
{
typedFileInput
.
setResource
(
resource
);
typedFileInput
.
setMime
(
mime
||
guessMimeTypes
(
resource
.
fsPath
).
join
(
'
,
'
));
typedFileInput
.
setMime
(
guessMimeTypes
(
resource
.
fsPath
).
join
(
'
,
'
));
typedFileInput
.
setPreferredEncoding
(
encoding
);
return
typedFileInput
;
...
...
src/vs/workbench/test/browser/services.test.ts
浏览文件 @
d1023ee9
...
...
@@ -299,13 +299,12 @@ suite('Workbench UI Services', () => {
});
// Open Untyped Input
service
.
openEditor
({
resource
:
toResource
(
'
/index.html
'
),
mime
:
'
text/html
'
,
options
:
{
selection
:
{
startLineNumber
:
1
,
startColumn
:
1
}
}
}).
then
((
editor
)
=>
{
service
.
openEditor
({
resource
:
toResource
(
'
/index.html
'
),
options
:
{
selection
:
{
startLineNumber
:
1
,
startColumn
:
1
}
}
}).
then
((
editor
)
=>
{
assert
.
strictEqual
(
editor
,
activeEditor
);
assert
(
openedEditorInput
instanceof
FileEditorInput
);
let
contentInput
=
<
FileEditorInput
>
openedEditorInput
;
assert
.
strictEqual
(
contentInput
.
getResource
().
fsPath
,
toResource
(
'
/index.html
'
).
fsPath
);
assert
.
strictEqual
(
contentInput
.
getMime
(),
'
text/html
'
);
assert
(
openedEditorOptions
instanceof
TextEditorOptions
);
let
textEditorOptions
=
<
TextEditorOptions
>
openedEditorOptions
;
...
...
@@ -327,7 +326,7 @@ suite('Workbench UI Services', () => {
});
// Resolve Editor Model (Untyped Input)
service
.
resolveEditorModel
({
resource
:
toResource
(
'
/index.html
'
)
,
mime
:
'
text/html
'
},
true
).
then
((
model
)
=>
{
service
.
resolveEditorModel
({
resource
:
toResource
(
'
/index.html
'
)
},
true
).
then
((
model
)
=>
{
assert
(
model
instanceof
TextFileEditorModel
);
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录