Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
4fe451d7
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
4fe451d7
编写于
10月 15, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move DataUri so that getIconClasses can be moved, #44860
上级
ade60477
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
40 deletion
+40
-40
src/vs/base/common/resources.ts
src/vs/base/common/resources.ts
+35
-0
src/vs/workbench/browser/labels.ts
src/vs/workbench/browser/labels.ts
+2
-3
src/vs/workbench/common/editor/binaryEditorModel.ts
src/vs/workbench/common/editor/binaryEditorModel.ts
+2
-2
src/vs/workbench/common/editor/dataUriEditorInput.ts
src/vs/workbench/common/editor/dataUriEditorInput.ts
+1
-1
src/vs/workbench/common/resources.ts
src/vs/workbench/common/resources.ts
+0
-34
未找到文件。
src/vs/base/common/resources.ts
浏览文件 @
4fe451d7
...
...
@@ -185,3 +185,38 @@ export function isMalformedFileUri(candidate: URI): URI | undefined {
}
return
void
0
;
}
/**
* Data URI related helpers.
*/
export
namespace
DataUri
{
export
const
META_DATA_LABEL
=
'
label
'
;
export
const
META_DATA_DESCRIPTION
=
'
description
'
;
export
const
META_DATA_SIZE
=
'
size
'
;
export
const
META_DATA_MIME
=
'
mime
'
;
export
function
parseMetaData
(
dataUri
:
URI
):
Map
<
string
,
string
>
{
const
metadata
=
new
Map
<
string
,
string
>
();
// Given a URI of: data:image/png;size:2313;label:SomeLabel;description:SomeDescription;base64,77+9UE5...
// the metadata is: size:2313;label:SomeLabel;description:SomeDescription
const
meta
=
dataUri
.
path
.
substring
(
dataUri
.
path
.
indexOf
(
'
;
'
)
+
1
,
dataUri
.
path
.
lastIndexOf
(
'
;
'
));
meta
.
split
(
'
;
'
).
forEach
(
property
=>
{
const
[
key
,
value
]
=
property
.
split
(
'
:
'
);
if
(
key
&&
value
)
{
metadata
.
set
(
key
,
value
);
}
});
// Given a URI of: data:image/png;size:2313;label:SomeLabel;description:SomeDescription;base64,77+9UE5...
// the mime is: image/png
const
mime
=
dataUri
.
path
.
substring
(
0
,
dataUri
.
path
.
indexOf
(
'
;
'
));
if
(
mime
)
{
metadata
.
set
(
META_DATA_MIME
,
mime
);
}
return
metadata
;
}
}
src/vs/workbench/browser/labels.ts
浏览文件 @
4fe451d7
...
...
@@ -20,7 +20,6 @@ import { FileKind, FILES_ASSOCIATIONS_CONFIG } from 'vs/platform/files/common/fi
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
DataUri
}
from
'
vs/workbench/common/resources
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
export
interface
IResourceLabel
{
...
...
@@ -318,8 +317,8 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
let
name
:
string
;
let
path
:
string
;
if
(
resource
.
scheme
===
Schemas
.
data
)
{
const
metadata
=
DataUri
.
parseMetaData
(
resource
);
name
=
metadata
.
get
(
DataUri
.
META_DATA_LABEL
);
const
metadata
=
resources
.
DataUri
.
parseMetaData
(
resource
);
name
=
metadata
.
get
(
resources
.
DataUri
.
META_DATA_LABEL
);
path
=
name
;
}
else
{
name
=
cssEscape
(
resources
.
basenameOrAuthority
(
resource
).
toLowerCase
());
...
...
src/vs/workbench/common/editor/binaryEditorModel.ts
浏览文件 @
4fe451d7
...
...
@@ -8,7 +8,7 @@ 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/
workbench
/common/resources
'
;
import
{
DataUri
}
from
'
vs/
base
/common/resources
'
;
/**
* An editor model that just represents a resource that can be loaded.
...
...
@@ -89,4 +89,4 @@ export class BinaryEditorModel extends EditorModel {
return
TPromise
.
wrap
(
this
);
}
}
\ No newline at end of file
}
src/vs/workbench/common/editor/dataUriEditorInput.ts
浏览文件 @
4fe451d7
...
...
@@ -8,7 +8,7 @@ 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
}
from
'
vs/
workbench
/common/resources
'
;
import
{
DataUri
}
from
'
vs/
base
/common/resources
'
;
/**
* An editor input to present data URIs in a binary editor. Data URIs have the form of:
...
...
src/vs/workbench/common/resources.ts
浏览文件 @
4fe451d7
...
...
@@ -78,37 +78,3 @@ export class ResourceContextKey extends Disposable implements IContextKey<URI> {
return
this
.
_resourceKey
.
get
();
}
}
/**
* Data URI related helpers.
*/
export
namespace
DataUri
{
export
const
META_DATA_LABEL
=
'
label
'
;
export
const
META_DATA_DESCRIPTION
=
'
description
'
;
export
const
META_DATA_SIZE
=
'
size
'
;
export
const
META_DATA_MIME
=
'
mime
'
;
export
function
parseMetaData
(
dataUri
:
URI
):
Map
<
string
,
string
>
{
const
metadata
=
new
Map
<
string
,
string
>
();
// Given a URI of: data:image/png;size:2313;label:SomeLabel;description:SomeDescription;base64,77+9UE5...
// the metadata is: size:2313;label:SomeLabel;description:SomeDescription
const
meta
=
dataUri
.
path
.
substring
(
dataUri
.
path
.
indexOf
(
'
;
'
)
+
1
,
dataUri
.
path
.
lastIndexOf
(
'
;
'
));
meta
.
split
(
'
;
'
).
forEach
(
property
=>
{
const
[
key
,
value
]
=
property
.
split
(
'
:
'
);
if
(
key
&&
value
)
{
metadata
.
set
(
key
,
value
);
}
});
// Given a URI of: data:image/png;size:2313;label:SomeLabel;description:SomeDescription;base64,77+9UE5...
// the mime is: image/png
const
mime
=
dataUri
.
path
.
substring
(
0
,
dataUri
.
path
.
indexOf
(
'
;
'
));
if
(
mime
)
{
metadata
.
set
(
META_DATA_MIME
,
mime
);
}
return
metadata
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录