Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2340d870
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,发现更多精彩内容 >>
未验证
提交
2340d870
编写于
11月 21, 2019
作者:
B
Benjamin Pasero
提交者:
GitHub
11月 21, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - remove data uri inputs (#85203)
上级
a825aaaa
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
9 addition
and
147 deletion
+9
-147
src/vs/workbench/browser/parts/editor/resourceViewer.ts
src/vs/workbench/browser/parts/editor/resourceViewer.ts
+4
-7
src/vs/workbench/common/editor/binaryEditorModel.ts
src/vs/workbench/common/editor/binaryEditorModel.ts
+0
-14
src/vs/workbench/common/editor/dataUriEditorInput.ts
src/vs/workbench/common/editor/dataUriEditorInput.ts
+0
-79
src/vs/workbench/contrib/files/browser/files.contribution.ts
src/vs/workbench/contrib/files/browser/files.contribution.ts
+1
-3
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+4
-10
src/vs/workbench/test/common/editor/dataUriEditorInput.test.ts
...s/workbench/test/common/editor/dataUriEditorInput.test.ts
+0
-34
未找到文件。
src/vs/workbench/browser/parts/editor/resourceViewer.ts
浏览文件 @
2340d870
...
...
@@ -6,7 +6,6 @@
import
*
as
DOM
from
'
vs/base/browser/dom
'
;
import
{
DomScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
import
{
Disposable
,
DisposableStore
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
'
vs/css!./media/resourceviewer
'
;
import
*
as
nls
from
'
vs/nls
'
;
...
...
@@ -132,13 +131,11 @@ class FileSeemsBinaryFileView {
label
.
textContent
=
nls
.
localize
(
'
nativeBinaryError
'
,
"
The file is not displayed in the editor because it is either binary or uses an unsupported text encoding.
"
);
container
.
appendChild
(
label
);
if
(
descriptor
.
resource
.
scheme
!==
Schemas
.
data
)
{
const
link
=
DOM
.
append
(
label
,
DOM
.
$
(
'
a.embedded-link
'
));
link
.
setAttribute
(
'
role
'
,
'
button
'
);
link
.
textContent
=
nls
.
localize
(
'
openAsText
'
,
"
Do you want to open it anyway?
"
);
const
link
=
DOM
.
append
(
label
,
DOM
.
$
(
'
a.embedded-link
'
));
link
.
setAttribute
(
'
role
'
,
'
button
'
);
link
.
textContent
=
nls
.
localize
(
'
openAsText
'
,
"
Do you want to open it anyway?
"
);
disposables
.
add
(
DOM
.
addDisposableListener
(
link
,
DOM
.
EventType
.
CLICK
,
()
=>
delegate
.
openInternalClb
(
descriptor
.
resource
)));
}
disposables
.
add
(
DOM
.
addDisposableListener
(
link
,
DOM
.
EventType
.
CLICK
,
()
=>
delegate
.
openInternalClb
(
descriptor
.
resource
)));
scrollbar
.
scanDomNode
();
...
...
src/vs/workbench/common/editor/binaryEditorModel.ts
浏览文件 @
2340d870
...
...
@@ -6,8 +6,6 @@
import
{
EditorModel
}
from
'
vs/workbench/common/editor
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
DataUri
}
from
'
vs/base/common/resources
'
;
import
{
MIME_BINARY
}
from
'
vs/base/common/mime
'
;
/**
...
...
@@ -28,18 +26,6 @@ export class BinaryEditorModel extends EditorModel {
this
.
resource
=
resource
;
this
.
name
=
name
;
this
.
mime
=
MIME_BINARY
;
if
(
resource
.
scheme
===
Schemas
.
data
)
{
const
metadata
=
DataUri
.
parseMetaData
(
resource
);
if
(
metadata
.
has
(
DataUri
.
META_DATA_SIZE
))
{
this
.
size
=
Number
(
metadata
.
get
(
DataUri
.
META_DATA_SIZE
));
}
const
metadataMime
=
metadata
.
get
(
DataUri
.
META_DATA_MIME
);
if
(
metadataMime
)
{
this
.
mime
=
metadataMime
;
}
}
}
/**
...
...
src/vs/workbench/common/editor/dataUriEditorInput.ts
已删除
100644 → 0
浏览文件 @
a825aaaa
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
EditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
BinaryEditorModel
}
from
'
vs/workbench/common/editor/binaryEditorModel
'
;
import
{
DataUri
,
basename
}
from
'
vs/base/common/resources
'
;
/**
* An editor input to present data URIs in a binary editor. Data URIs have the form of:
* data:[mime type];[meta data <key=value>;...];base64,[base64 encoded value]
*/
export
class
DataUriEditorInput
extends
EditorInput
{
static
readonly
ID
:
string
=
'
workbench.editors.dataUriEditorInput
'
;
private
readonly
name
:
string
;
private
readonly
description
:
string
|
undefined
;
constructor
(
name
:
string
|
undefined
,
description
:
string
|
undefined
,
private
readonly
resource
:
URI
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
)
{
super
();
if
(
!
name
||
!
description
)
{
const
metadata
=
DataUri
.
parseMetaData
(
this
.
resource
);
if
(
!
name
)
{
name
=
metadata
.
get
(
DataUri
.
META_DATA_LABEL
)
||
basename
(
resource
);
}
if
(
!
description
)
{
description
=
metadata
.
get
(
DataUri
.
META_DATA_DESCRIPTION
);
}
}
this
.
name
=
name
;
this
.
description
=
description
;
}
getResource
():
URI
{
return
this
.
resource
;
}
getTypeId
():
string
{
return
DataUriEditorInput
.
ID
;
}
getName
():
string
{
return
this
.
name
;
}
getDescription
():
string
|
undefined
{
return
this
.
description
;
}
resolve
():
Promise
<
BinaryEditorModel
>
{
return
this
.
instantiationService
.
createInstance
(
BinaryEditorModel
,
this
.
resource
,
this
.
getName
()).
load
();
}
matches
(
otherInput
:
unknown
):
boolean
{
if
(
super
.
matches
(
otherInput
)
===
true
)
{
return
true
;
}
// Compare by resource
if
(
otherInput
instanceof
DataUriEditorInput
)
{
return
otherInput
.
resource
.
toString
()
===
this
.
resource
.
toString
();
}
return
false
;
}
}
src/vs/workbench/contrib/files/browser/files.contribution.ts
浏览文件 @
2340d870
...
...
@@ -27,7 +27,6 @@ import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
ExplorerViewlet
,
ExplorerViewletViewsContribution
}
from
'
vs/workbench/contrib/files/browser/explorerViewlet
'
;
import
{
IEditorRegistry
,
EditorDescriptor
,
Extensions
as
EditorExtensions
}
from
'
vs/workbench/browser/editor
'
;
import
{
DataUriEditorInput
}
from
'
vs/workbench/common/editor/dataUriEditorInput
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
...
...
@@ -107,8 +106,7 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
nls
.
localize
(
'
binaryFileEditor
'
,
"
Binary File Editor
"
)
),
[
new
SyncDescriptor
<
EditorInput
>
(
FileEditorInput
),
new
SyncDescriptor
<
EditorInput
>
(
DataUriEditorInput
)
new
SyncDescriptor
<
EditorInput
>
(
FileEditorInput
)
]
);
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
2340d870
...
...
@@ -7,7 +7,6 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
import
{
IResourceInput
,
ITextEditorOptions
,
IEditorOptions
,
EditorActivation
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorInput
,
IEditor
,
GroupIdentifier
,
IFileEditorInput
,
IUntitledTextResourceInput
,
IResourceDiffInput
,
IResourceSideBySideInput
,
IEditorInputFactoryRegistry
,
Extensions
as
EditorExtensions
,
IFileInputFactory
,
EditorInput
,
SideBySideEditorInput
,
IEditorInputWithOptions
,
isEditorInputWithOptions
,
EditorOptions
,
TextEditorOptions
,
IEditorIdentifier
,
IEditorCloseEvent
,
ITextEditor
,
ITextDiffEditor
,
ITextSideBySideEditor
,
toResource
,
SideBySideEditor
,
IRevertOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
import
{
DataUriEditorInput
}
from
'
vs/workbench/common/editor/dataUriEditorInput
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
IUntitledTextEditorService
}
from
'
vs/workbench/services/untitled/common/untitledTextEditorService
'
;
...
...
@@ -29,7 +28,7 @@ import { ILabelService } from 'vs/platform/label/common/label';
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
type
CachedEditorInput
=
ResourceEditorInput
|
IFileEditorInput
|
DataUriEditorInput
;
type
CachedEditorInput
=
ResourceEditorInput
|
IFileEditorInput
;
type
OpenInEditorGroup
=
IEditorGroup
|
GroupIdentifier
|
SIDE_GROUP_TYPE
|
ACTIVE_GROUP_TYPE
;
export
class
EditorService
extends
Disposable
implements
EditorServiceImpl
{
...
...
@@ -584,8 +583,8 @@ export class EditorService extends Disposable implements EditorServiceImpl {
const
resourceInput
=
input
as
IResourceInput
;
if
(
resourceInput
.
resource
instanceof
URI
)
{
let
label
=
resourceInput
.
label
;
if
(
!
label
&&
resourceInput
.
resource
.
scheme
!==
Schemas
.
data
)
{
label
=
basename
(
resourceInput
.
resource
);
// derive the label from the path
(but not for data URIs)
if
(
!
label
)
{
label
=
basename
(
resourceInput
.
resource
);
// derive the label from the path
}
return
this
.
createOrGet
(
resourceInput
.
resource
,
this
.
instantiationService
,
label
,
resourceInput
.
description
,
resourceInput
.
encoding
,
resourceInput
.
mode
,
resourceInput
.
forceFile
)
as
EditorInput
;
...
...
@@ -609,7 +608,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
if
(
mode
)
{
input
.
setPreferredMode
(
mode
);
}
}
else
if
(
!
(
input
instanceof
DataUriEditorInput
))
{
}
else
{
if
(
encoding
)
{
input
.
setPreferredEncoding
(
encoding
);
}
...
...
@@ -628,11 +627,6 @@ export class EditorService extends Disposable implements EditorServiceImpl {
input
=
this
.
fileInputFactory
.
createFileInput
(
resource
,
encoding
,
mode
,
instantiationService
);
}
// Data URI
else
if
(
resource
.
scheme
===
Schemas
.
data
)
{
input
=
instantiationService
.
createInstance
(
DataUriEditorInput
,
label
||
basename
(
resource
),
description
,
resource
);
}
// Resource
else
{
input
=
instantiationService
.
createInstance
(
ResourceEditorInput
,
label
,
description
,
resource
,
mode
);
...
...
src/vs/workbench/test/common/editor/dataUriEditorInput.test.ts
已删除
100644 → 0
浏览文件 @
a825aaaa
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
workbenchInstantiationService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
DataUriEditorInput
}
from
'
vs/workbench/common/editor/dataUriEditorInput
'
;
import
{
BinaryEditorModel
}
from
'
vs/workbench/common/editor/binaryEditorModel
'
;
suite
(
'
DataUriEditorInput
'
,
()
=>
{
let
instantiationService
:
IInstantiationService
;
setup
(()
=>
{
instantiationService
=
workbenchInstantiationService
();
});
test
(
'
simple
'
,
()
=>
{
const
resource
=
URI
.
parse
(
'
data:image/png;label:SomeLabel;description:SomeDescription;size:1024;base64,77+9UE5
'
);
const
input
:
DataUriEditorInput
=
instantiationService
.
createInstance
(
DataUriEditorInput
,
undefined
,
undefined
,
resource
);
assert
.
equal
(
input
.
getName
(),
'
SomeLabel
'
);
assert
.
equal
(
input
.
getDescription
(),
'
SomeDescription
'
);
return
input
.
resolve
().
then
((
model
:
BinaryEditorModel
)
=>
{
assert
.
ok
(
model
);
assert
.
equal
(
model
.
getSize
(),
1024
);
assert
.
equal
(
model
.
getMime
(),
'
image/png
'
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录