Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
2cd7a70d
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 搜索 >>
未验证
提交
2cd7a70d
编写于
11月 26, 2020
作者:
J
João Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
original urls get passed along with openUrl
上级
ac9e250c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
38 addition
and
28 deletion
+38
-28
src/vs/code/electron-main/app.ts
src/vs/code/electron-main/app.ts
+14
-13
src/vs/platform/launch/electron-main/launchMainService.ts
src/vs/platform/launch/electron-main/launchMainService.ts
+4
-4
src/vs/platform/url/common/url.ts
src/vs/platform/url/common/url.ts
+2
-0
src/vs/platform/url/common/urlIpc.ts
src/vs/platform/url/common/urlIpc.ts
+2
-2
src/vs/platform/url/electron-main/electronUrlListener.ts
src/vs/platform/url/electron-main/electronUrlListener.ts
+15
-8
src/vs/workbench/contrib/url/browser/url.contribution.ts
src/vs/workbench/contrib/url/browser/url.contribution.ts
+1
-1
未找到文件。
src/vs/code/electron-main/app.ts
浏览文件 @
2cd7a70d
...
...
@@ -24,7 +24,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import
{
IStateService
}
from
'
vs/platform/state/node/state
'
;
import
{
IEnvironmentMainService
}
from
'
vs/platform/environment/electron-main/environmentMainService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
I
OpenURLOptions
,
I
URLService
}
from
'
vs/platform/url/common/url
'
;
import
{
URLHandlerChannelClient
,
URLHandlerRouter
}
from
'
vs/platform/url/common/urlIpc
'
;
import
{
ITelemetryService
,
machineIdKey
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
...
...
@@ -73,7 +73,6 @@ import { INativeHostMainService, NativeHostMainService } from 'vs/platform/nativ
import
{
ISharedProcessMainService
,
SharedProcessMainService
}
from
'
vs/platform/ipc/electron-main/sharedProcessMainService
'
;
import
{
IDialogMainService
,
DialogMainService
}
from
'
vs/platform/dialogs/electron-main/dialogs
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
mnemonicButtonLabel
,
getPathLabel
}
from
'
vs/base/common/labels
'
;
import
{
WebviewMainService
}
from
'
vs/platform/webview/electron-main/webviewMainService
'
;
import
{
IWebviewManagerService
}
from
'
vs/platform/webview/common/webviewManagerService
'
;
...
...
@@ -663,30 +662,32 @@ export class CodeApplication extends Disposable {
// Check for initial URLs to handle from protocol link invocations
const
pendingWindowOpenablesFromProtocolLinks
:
IWindowOpenable
[]
=
[];
const
pendingProtocolLinksToHandle
=
coalesce
([
const
pendingProtocolLinksToHandle
=
[
// Windows/Linux: protocol handler invokes CLI with --open-url
...
this
.
environmentService
.
args
[
'
open-url
'
]
?
this
.
environmentService
.
args
.
_urls
||
[]
:
[],
// macOS: open-url events
...((
<
any
>
global
).
getOpenUrls
()
||
[])
as
string
[]
].
map
(
pendingUrlToHandle
=>
{
].
map
(
url
=>
{
try
{
return
URI
.
parse
(
pendingUrlToHandle
);
}
catch
(
error
)
{
return
undefined
;
return
{
uri
:
URI
.
parse
(
url
),
url
};
}
catch
{
return
null
;
}
}).
filter
((
obj
):
obj
is
{
uri
:
URI
,
url
:
string
}
=>
{
if
(
!
obj
)
{
return
false
;
}
})).
filter
(
pendingUriToHandle
=>
{
// If URI should be blocked, filter it out
if
(
this
.
shouldBlockURI
(
pendingUriToHandle
))
{
if
(
this
.
shouldBlockURI
(
obj
.
uri
))
{
return
false
;
}
// Filter out any protocol link that wants to open as window so that
// we open the right set of windows on startup and not restore the
// previous workspace too.
const
windowOpenable
=
this
.
getWindowOpenableFromProtocolLink
(
pendingUriToHandle
);
const
windowOpenable
=
this
.
getWindowOpenableFromProtocolLink
(
obj
.
uri
);
if
(
windowOpenable
)
{
pendingWindowOpenablesFromProtocolLinks
.
push
(
windowOpenable
);
...
...
@@ -700,7 +701,7 @@ export class CodeApplication extends Disposable {
const
app
=
this
;
const
environmentService
=
this
.
environmentService
;
urlService
.
registerHandler
({
async
handleURL
(
uri
:
URI
):
Promise
<
boolean
>
{
async
handleURL
(
uri
:
URI
,
options
?:
IOpenURLOptions
):
Promise
<
boolean
>
{
// If URI should be blocked, behave as if it's handled
if
(
app
.
shouldBlockURI
(
uri
))
{
...
...
@@ -732,7 +733,7 @@ export class CodeApplication extends Disposable {
await
window
.
ready
();
return
urlService
.
open
(
uri
);
return
urlService
.
open
(
uri
,
options
);
}
return
false
;
...
...
src/vs/platform/launch/electron-main/launchMainService.ts
浏览文件 @
2cd7a70d
...
...
@@ -35,14 +35,14 @@ export interface IRemoteDiagnosticOptions {
includeWorkspaceMetadata
?:
boolean
;
}
function
parseOpenUrl
(
args
:
NativeParsedArgs
):
URI
[]
{
function
parseOpenUrl
(
args
:
NativeParsedArgs
):
{
uri
:
URI
,
url
:
string
}
[]
{
if
(
args
[
'
open-url
'
]
&&
args
.
_urls
&&
args
.
_urls
.
length
>
0
)
{
// --open-url must contain -- followed by the url(s)
// process.argv is used over args._ as args._ are resolved to file paths at this point
return
coalesce
(
args
.
_urls
.
map
(
url
=>
{
try
{
return
URI
.
parse
(
url
)
;
return
{
uri
:
URI
.
parse
(
url
),
url
}
;
}
catch
(
err
)
{
return
null
;
}
...
...
@@ -101,8 +101,8 @@ export class LaunchMainService implements ILaunchMainService {
// Make sure a window is open, ready to receive the url event
whenWindowReady
.
then
(()
=>
{
for
(
const
url
of
urlsToOpen
)
{
this
.
urlService
.
open
(
ur
l
);
for
(
const
{
uri
,
url
}
of
urlsToOpen
)
{
this
.
urlService
.
open
(
ur
i
,
{
originalUrl
:
url
}
);
}
});
}
...
...
src/vs/platform/url/common/url.ts
浏览文件 @
2cd7a70d
...
...
@@ -18,6 +18,8 @@ export interface IOpenURLOptions {
* might be shown to the user.
*/
trusted
?:
boolean
;
originalUrl
?:
string
;
}
export
interface
IURLHandler
{
...
...
src/vs/platform/url/common/urlIpc.ts
浏览文件 @
2cd7a70d
...
...
@@ -19,7 +19,7 @@ export class URLHandlerChannel implements IServerChannel {
call
(
_
:
unknown
,
command
:
string
,
arg
?:
any
):
Promise
<
any
>
{
switch
(
command
)
{
case
'
handleURL
'
:
return
this
.
handler
.
handleURL
(
URI
.
revive
(
arg
)
);
case
'
handleURL
'
:
return
this
.
handler
.
handleURL
(
URI
.
revive
(
arg
[
0
]),
arg
[
1
]
);
}
throw
new
Error
(
`Call not found:
${
command
}
`
);
...
...
@@ -31,7 +31,7 @@ export class URLHandlerChannelClient implements IURLHandler {
constructor
(
private
channel
:
IChannel
)
{
}
handleURL
(
uri
:
URI
,
options
?:
IOpenURLOptions
):
Promise
<
boolean
>
{
return
this
.
channel
.
call
(
'
handleURL
'
,
uri
.
toJSON
()
);
return
this
.
channel
.
call
(
'
handleURL
'
,
[
uri
.
toJSON
(),
options
]
);
}
}
...
...
src/vs/platform/url/electron-main/electronUrlListener.ts
浏览文件 @
2cd7a70d
...
...
@@ -34,13 +34,13 @@ function uriFromRawUrl(url: string): URI | null {
*/
export
class
ElectronURLListener
{
private
uris
:
URI
[]
=
[];
private
uris
:
{
uri
:
URI
,
url
:
string
}
[]
=
[];
private
retryCount
=
0
;
private
flushDisposable
:
IDisposable
=
Disposable
.
None
;
private
disposables
=
new
DisposableStore
();
constructor
(
initialUrisToHandle
:
URI
[],
initialUrisToHandle
:
{
uri
:
URI
,
url
:
string
}
[],
private
readonly
urlService
:
IURLService
,
windowsMainService
:
IWindowsMainService
,
environmentService
:
IEnvironmentMainService
...
...
@@ -64,8 +64,15 @@ export class ElectronURLListener {
return
url
;
});
const
onOpenUrl
=
Event
.
filter
<
URI
|
null
,
URI
>
(
Event
.
map
(
onOpenElectronUrl
,
uriFromRawUrl
),
(
uri
):
uri
is
URI
=>
!!
uri
);
onOpenUrl
(
this
.
urlService
.
open
,
this
.
urlService
,
this
.
disposables
);
this
.
disposables
.
add
(
onOpenElectronUrl
(
url
=>
{
const
uri
=
uriFromRawUrl
(
url
);
if
(
!
uri
)
{
return
;
}
this
.
urlService
.
open
(
uri
,
{
originalUrl
:
url
});
}));
// Send initial links to the window once it has loaded
const
isWindowReady
=
windowsMainService
.
getWindows
()
...
...
@@ -84,13 +91,13 @@ export class ElectronURLListener {
return
;
}
const
uris
:
URI
[]
=
[];
const
uris
:
{
uri
:
URI
,
url
:
string
}
[]
=
[];
for
(
const
uri
of
this
.
uris
)
{
const
handled
=
await
this
.
urlService
.
open
(
uri
);
for
(
const
obj
of
this
.
uris
)
{
const
handled
=
await
this
.
urlService
.
open
(
obj
.
uri
,
{
originalUrl
:
obj
.
url
}
);
if
(
!
handled
)
{
uris
.
push
(
uri
);
uris
.
push
(
obj
);
}
}
...
...
src/vs/workbench/contrib/url/browser/url.contribution.ts
浏览文件 @
2cd7a70d
...
...
@@ -37,7 +37,7 @@ class OpenUrlAction extends Action2 {
return
quickInputService
.
input
({
prompt
:
localize
(
'
urlToOpen
'
,
"
URL to open
"
)
}).
then
(
input
=>
{
if
(
input
)
{
const
uri
=
URI
.
parse
(
input
);
urlService
.
open
(
uri
,
{
trusted
:
true
});
urlService
.
open
(
uri
,
{
originalUrl
:
input
});
}
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录