Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
64496f82
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
64496f82
编写于
1月 14, 2021
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow using 'default' to force fall back to VS Code's default opener
上级
6cceb4ea
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
13 deletion
+29
-13
src/vs/workbench/contrib/externalUriOpener/common/configuration.ts
...rkbench/contrib/externalUriOpener/common/configuration.ts
+7
-0
src/vs/workbench/contrib/externalUriOpener/common/externalUriOpenerService.ts
...trib/externalUriOpener/common/externalUriOpenerService.ts
+22
-13
未找到文件。
src/vs/workbench/contrib/externalUriOpener/common/configuration.ts
浏览文件 @
64496f82
...
...
@@ -8,6 +8,7 @@ import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuratio
import
*
as
nls
from
'
vs/nls
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
defaultExternalUriOpenerId
}
from
'
vs/workbench/contrib/externalUriOpener/common/contributedOpeners
'
;
export
const
externalUriOpenersSettingId
=
'
workbench.externalUriOpeners
'
;
...
...
@@ -59,6 +60,12 @@ export const externalUriOpenersConfigurationNode: IConfigurationNode = {
type
:
'
string
'
,
description
:
nls
.
localize
(
'
externalUriOpeners.id
'
,
"
The id of the opener.
"
),
},
{
type
:
'
string
'
,
description
:
nls
.
localize
(
'
externalUriOpeners.id
'
,
"
The id of the opener.
"
),
enum
:
[
defaultExternalUriOpenerId
],
enumDescriptions
:
[
nls
.
localize
(
'
externalUriOpeners.defaultId
'
,
"
Open using VS Code's standard opener.
"
)],
},
externalUriOpenerIdSchemaAddition
]
}
...
...
src/vs/workbench/contrib/externalUriOpener/common/externalUriOpenerService.ts
浏览文件 @
64496f82
...
...
@@ -17,6 +17,7 @@ import { IExternalOpener, IOpenerService } from 'vs/platform/opener/common/opene
import
{
IQuickInputService
,
IQuickPickItem
,
IQuickPickSeparator
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ExternalUriOpenerConfiguration
,
externalUriOpenersSettingId
}
from
'
vs/workbench/contrib/externalUriOpener/common/configuration
'
;
import
{
defaultExternalUriOpenerId
}
from
'
vs/workbench/contrib/externalUriOpener/common/contributedOpeners
'
;
import
{
testUrlMatchesGlob
}
from
'
vs/workbench/contrib/url/common/urlGlob
'
;
import
{
IPreferencesService
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
...
...
@@ -70,12 +71,7 @@ export class ExternalUriOpenerService extends Disposable implements IExternalUri
const
targetUri
=
typeof
href
===
'
string
'
?
URI
.
parse
(
href
)
:
href
;
const
allOpeners
=
new
Map
<
string
,
IExternalUriOpener
>
();
await
Promise
.
all
(
Iterable
.
map
(
this
.
_providers
,
async
(
provider
)
=>
{
for
await
(
const
opener
of
provider
.
getOpeners
(
targetUri
))
{
allOpeners
.
set
(
opener
.
id
,
opener
);
}
}));
const
allOpeners
=
await
this
.
getAllOpenersForUri
(
targetUri
);
if
(
allOpeners
.
size
===
0
)
{
return
false
;
...
...
@@ -84,7 +80,8 @@ export class ExternalUriOpenerService extends Disposable implements IExternalUri
// First check to see if we have a configured opener
const
configuredOpener
=
this
.
getConfiguredOpenerForUri
(
allOpeners
,
targetUri
);
if
(
configuredOpener
)
{
return
configuredOpener
.
openExternalUri
(
targetUri
,
ctx
,
token
);
// Skip the `canOpen` check here since the opener was specifically requested.
return
configuredOpener
===
'
default
'
?
false
:
configuredOpener
.
openExternalUri
(
targetUri
,
ctx
,
token
);
}
// Then check to see if there is a valid opener
...
...
@@ -97,7 +94,6 @@ export class ExternalUriOpenerService extends Disposable implements IExternalUri
case
modes
.
ExternalUriOpenerPriority
.
Preferred
:
validOpeners
.
push
({
opener
,
priority
});
break
;
}
}));
if
(
validOpeners
.
length
===
0
)
{
...
...
@@ -119,13 +115,26 @@ export class ExternalUriOpenerService extends Disposable implements IExternalUri
return
this
.
showOpenerPrompt
(
validOpeners
.
map
(
x
=>
x
.
opener
),
targetUri
,
ctx
,
token
);
}
private
getConfiguredOpenerForUri
(
openers
:
Map
<
string
,
IExternalUriOpener
>
,
targetUri
:
URI
):
IExternalUriOpener
|
undefined
{
private
async
getAllOpenersForUri
(
targetUri
:
URI
):
Promise
<
Map
<
string
,
IExternalUriOpener
>>
{
const
allOpeners
=
new
Map
<
string
,
IExternalUriOpener
>
();
await
Promise
.
all
(
Iterable
.
map
(
this
.
_providers
,
async
(
provider
)
=>
{
for
await
(
const
opener
of
provider
.
getOpeners
(
targetUri
))
{
allOpeners
.
set
(
opener
.
id
,
opener
);
}
}));
return
allOpeners
;
}
private
getConfiguredOpenerForUri
(
openers
:
Map
<
string
,
IExternalUriOpener
>
,
targetUri
:
URI
):
IExternalUriOpener
|
'
default
'
|
undefined
{
const
config
=
this
.
configurationService
.
getValue
<
readonly
ExternalUriOpenerConfiguration
[]
>
(
externalUriOpenersSettingId
)
||
[];
for
(
const
{
id
,
uri
}
of
config
)
{
const
entry
=
openers
.
get
(
id
);
if
(
entry
)
{
if
(
testUrlMatchesGlob
(
targetUri
.
toString
(),
uri
))
{
// Skip the `canOpen` check here since the opener was specifically requested.
if
(
testUrlMatchesGlob
(
targetUri
.
toString
(),
uri
))
{
if
(
id
===
defaultExternalUriOpenerId
)
{
return
'
default
'
;
}
const
entry
=
openers
.
get
(
id
);
if
(
entry
)
{
return
entry
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录