Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
d5026ed3
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,发现更多精彩内容 >>
提交
d5026ed3
编写于
8月 20, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #79453
上级
df0dd2ed
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
63 addition
and
84 deletion
+63
-84
src/vs/editor/browser/services/openerService.ts
src/vs/editor/browser/services/openerService.ts
+10
-9
src/vs/platform/opener/common/opener.ts
src/vs/platform/opener/common/opener.ts
+2
-8
src/vs/platform/url/electron-browser/urlService.ts
src/vs/platform/url/electron-browser/urlService.ts
+7
-3
src/vs/workbench/api/browser/mainThreadWindow.ts
src/vs/workbench/api/browser/mainThreadWindow.ts
+1
-1
src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts
...rkbench/contrib/files/browser/editors/binaryFileEditor.ts
+1
-1
src/vs/workbench/electron-browser/window.ts
src/vs/workbench/electron-browser/window.ts
+36
-9
src/vs/workbench/services/files/common/workspaceWatcher.ts
src/vs/workbench/services/files/common/workspaceWatcher.ts
+2
-2
src/vs/workbench/services/integrity/node/integrityService.ts
src/vs/workbench/services/integrity/node/integrityService.ts
+1
-1
src/vs/workbench/services/opener/electron-browser/openerService.ts
...rkbench/services/opener/electron-browser/openerService.ts
+0
-46
src/vs/workbench/workbench.common.main.ts
src/vs/workbench/workbench.common.main.ts
+3
-0
src/vs/workbench/workbench.desktop.main.ts
src/vs/workbench/workbench.desktop.main.ts
+0
-1
src/vs/workbench/workbench.web.main.ts
src/vs/workbench/workbench.web.main.ts
+0
-3
未找到文件。
src/vs/editor/browser/services/openerService.ts
浏览文件 @
d5026ed3
...
...
@@ -19,10 +19,11 @@ import { localize } from 'vs/nls';
import
{
IProductService
}
from
'
vs/platform/product/common/product
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
export
class
OpenerService
implements
IOpenerService
{
_serviceBrand
:
any
;
_serviceBrand
!
:
ServiceIdentifier
<
any
>
;
private
readonly
_opener
=
new
LinkedList
<
IOpener
>
();
...
...
@@ -41,7 +42,7 @@ export class OpenerService implements IOpenerService {
return
{
dispose
:
remove
};
}
async
open
(
resource
:
URI
,
options
?:
{
openToSide
?:
boolean
}):
Promise
<
boolean
>
{
async
open
(
resource
:
URI
,
options
?:
{
openToSide
?:
boolean
,
openExternal
?:
boolean
}):
Promise
<
boolean
>
{
// no scheme ?!?
if
(
!
resource
.
scheme
)
{
return
Promise
.
resolve
(
false
);
...
...
@@ -57,13 +58,13 @@ export class OpenerService implements IOpenerService {
return
this
.
_doOpen
(
resource
,
options
);
}
private
_doOpen
(
resource
:
URI
,
options
?:
{
openToSide
?:
boolean
}):
Promise
<
boolean
>
{
private
_doOpen
(
resource
:
URI
,
options
?:
{
openToSide
?:
boolean
,
openExternal
?:
boolean
}):
Promise
<
boolean
>
{
const
{
scheme
,
authority
,
path
,
query
,
fragment
}
=
resource
;
if
(
equalsIgnoreCase
(
scheme
,
Schemas
.
mailto
))
{
if
(
equalsIgnoreCase
(
scheme
,
Schemas
.
mailto
)
||
(
options
&&
options
.
openExternal
)
)
{
// open default mail application
return
this
.
o
penExternal
(
resource
);
return
this
.
_doO
penExternal
(
resource
);
}
if
(
equalsIgnoreCase
(
scheme
,
Schemas
.
http
)
||
equalsIgnoreCase
(
scheme
,
Schemas
.
https
))
{
...
...
@@ -78,7 +79,7 @@ export class OpenerService implements IOpenerService {
const
domainToOpen
=
`
${
scheme
}
://
${
authority
}
`
;
if
(
isDomainTrusted
(
domainToOpen
,
trustedDomains
))
{
return
this
.
o
penExternal
(
resource
);
return
this
.
_doO
penExternal
(
resource
);
}
else
{
return
this
.
_dialogService
.
show
(
Severity
.
Info
,
...
...
@@ -97,11 +98,11 @@ export class OpenerService implements IOpenerService {
cancelId
:
1
}).
then
((
choice
)
=>
{
if
(
choice
===
0
)
{
return
this
.
o
penExternal
(
resource
);
return
this
.
_doO
penExternal
(
resource
);
}
else
if
(
choice
===
2
)
{
return
this
.
_commandService
.
executeCommand
(
'
workbench.action.configureTrustedDomains
'
,
domainToOpen
).
then
((
pickedDomains
:
string
[])
=>
{
if
(
pickedDomains
.
indexOf
(
domainToOpen
)
!==
-
1
)
{
return
this
.
o
penExternal
(
resource
);
return
this
.
_doO
penExternal
(
resource
);
}
return
Promise
.
resolve
(
false
);
});
...
...
@@ -152,7 +153,7 @@ export class OpenerService implements IOpenerService {
}
}
o
penExternal
(
resource
:
URI
):
Promise
<
boolean
>
{
private
_doO
penExternal
(
resource
:
URI
):
Promise
<
boolean
>
{
dom
.
windowOpenNoOpener
(
encodeURI
(
resource
.
toString
(
true
)));
return
Promise
.
resolve
(
true
);
...
...
src/vs/platform/opener/common/opener.ts
浏览文件 @
d5026ed3
...
...
@@ -11,6 +11,7 @@ export const IOpenerService = createDecorator<IOpenerService>('openerService');
export
interface
IOpener
{
open
(
resource
:
URI
,
options
?:
{
openToSide
?:
boolean
}):
Promise
<
boolean
>
;
open
(
resource
:
URI
,
options
?:
{
openExternal
?:
boolean
}):
Promise
<
boolean
>
;
}
export
interface
IOpenerService
{
...
...
@@ -29,18 +30,11 @@ export interface IOpenerService {
* @return A promise that resolves when the opening is done.
*/
open
(
resource
:
URI
,
options
?:
{
openToSide
?:
boolean
}):
Promise
<
boolean
>
;
/**
* Opens a URL externally.
*
* @param url A resource to open externally.
*/
openExternal
(
resource
:
URI
):
Promise
<
boolean
>
;
open
(
resource
:
URI
,
options
?:
{
openExternal
?:
boolean
}):
Promise
<
boolean
>
;
}
export
const
NullOpenerService
:
IOpenerService
=
Object
.
freeze
({
_serviceBrand
:
undefined
,
registerOpener
()
{
return
{
dispose
()
{
}
};
},
open
()
{
return
Promise
.
resolve
(
false
);
},
openExternal
()
{
return
Promise
.
resolve
(
false
);
}
});
src/vs/platform/url/electron-browser/urlService.ts
浏览文件 @
d5026ed3
...
...
@@ -27,12 +27,16 @@ export class RelayURLService extends URLService implements IURLHandler {
openerService
.
registerOpener
(
this
);
}
async
open
(
uri
:
URI
):
Promise
<
boolean
>
{
if
(
uri
.
scheme
!==
product
.
urlProtoco
l
)
{
async
open
(
resource
:
URI
,
options
?:
{
openToSide
?:
boolean
,
openExternal
?:
boolean
}
):
Promise
<
boolean
>
{
if
(
options
&&
options
.
openExterna
l
)
{
return
false
;
}
return
await
this
.
urlService
.
open
(
uri
);
if
(
resource
.
scheme
!==
product
.
urlProtocol
)
{
return
false
;
}
return
await
this
.
urlService
.
open
(
resource
);
}
handleURL
(
uri
:
URI
):
Promise
<
boolean
>
{
...
...
src/vs/workbench/api/browser/mainThreadWindow.ts
浏览文件 @
d5026ed3
...
...
@@ -59,7 +59,7 @@ export class MainThreadWindow implements MainThreadWindowShape {
}
}
return
this
.
openerService
.
open
External
(
uri
);
return
this
.
openerService
.
open
(
uri
,
{
openExternal
:
true
}
);
}
private
getOrCreateTunnel
(
remotePort
:
number
):
Promise
<
RemoteTunnel
>
|
undefined
{
...
...
src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.ts
浏览文件 @
d5026ed3
...
...
@@ -38,7 +38,7 @@ export class BinaryFileEditor extends BaseBinaryResourceEditor {
BinaryFileEditor
.
ID
,
{
openInternal
:
(
input
,
options
)
=>
this
.
openInternal
(
input
,
options
),
openExternal
:
resource
=>
this
.
openerService
.
open
External
(
resource
)
openExternal
:
resource
=>
this
.
openerService
.
open
(
resource
,
{
openExternal
:
true
}
)
},
telemetryService
,
themeService
,
...
...
src/vs/workbench/electron-browser/window.ts
浏览文件 @
d5026ed3
...
...
@@ -54,6 +54,8 @@ import { IPreferencesService } from '../services/preferences/common/preferences'
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IMenubarService
,
IMenubarData
,
IMenubarMenu
,
IMenubarKeybinding
,
IMenubarMenuItemSubmenu
,
IMenubarMenuItemAction
,
MenubarMenuItem
}
from
'
vs/platform/menubar/node/menubar
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
const
TextInputActions
:
IAction
[]
=
[
new
Action
(
'
undo
'
,
nls
.
localize
(
'
undo
'
,
"
Undo
"
),
undefined
,
true
,
()
=>
Promise
.
resolve
(
document
.
execCommand
(
'
undo
'
))),
...
...
@@ -101,7 +103,8 @@ export class ElectronWindow extends Disposable {
@
IAccessibilityService
private
readonly
accessibilityService
:
IAccessibilityService
,
@
IWorkspaceContextService
private
readonly
contextService
:
IWorkspaceContextService
,
@
ITextFileService
private
readonly
textFileService
:
ITextFileService
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IOpenerService
private
readonly
openerService
:
IOpenerService
)
{
super
();
...
...
@@ -312,13 +315,8 @@ export class ElectronWindow extends Disposable {
this
.
_register
(
this
.
instantiationService
.
createInstance
(
NativeMenubarControl
));
}
// Handle window.open() calls
const
$this
=
this
;
window
.
open
=
function
(
url
:
string
,
target
:
string
,
features
:
string
,
replace
:
boolean
):
Window
|
null
{
$this
.
windowsService
.
openExternal
(
url
);
return
null
;
};
// Handle open calls
this
.
setupOpenHandlers
();
// Emit event when vscode is ready
this
.
lifecycleService
.
when
(
LifecyclePhase
.
Ready
).
then
(()
=>
ipc
.
send
(
'
vscode:workbenchReady
'
,
this
.
windowService
.
windowId
));
...
...
@@ -356,6 +354,35 @@ export class ElectronWindow extends Disposable {
}
}
private
setupOpenHandlers
():
void
{
// Handle window.open() calls
const
$this
=
this
;
window
.
open
=
function
(
url
:
string
,
target
:
string
,
features
:
string
,
replace
:
boolean
):
Window
|
null
{
$this
.
windowsService
.
openExternal
(
url
);
return
null
;
};
// Handle external open calls
this
.
openerService
.
registerOpener
({
async
open
(
resource
:
URI
,
options
?:
{
openToSide
?:
boolean
;
openExternal
?:
boolean
;
}
|
undefined
):
Promise
<
boolean
>
{
if
(
!
options
||
!
options
.
openExternal
)
{
return
false
;
// only override behaviour for external open()
}
const
success
=
await
$this
.
windowsService
.
openExternal
(
encodeURI
(
resource
.
toString
(
true
)));
if
(
!
success
&&
resource
.
scheme
===
Schemas
.
file
)
{
await
$this
.
windowsService
.
showItemInFolder
(
resource
);
return
true
;
}
return
success
;
}
});
}
private
updateTouchbarMenu
():
void
{
if
(
!
isMacintosh
)
{
return
;
// macOS only
...
...
@@ -741,4 +768,4 @@ class NativeMenubarControl extends MenubarControl {
return
undefined
;
}
}
\ No newline at end of file
}
src/vs/workbench/services/files/common/workspaceWatcher.ts
浏览文件 @
d5026ed3
...
...
@@ -79,7 +79,7 @@ export class WorkspaceWatcher extends Disposable {
localize
(
'
netVersionError
'
,
"
The Microsoft .NET Framework 4.5 is required. Please follow the link to install it.
"
),
[{
label
:
localize
(
'
installNet
'
,
"
Download .NET Framework 4.5
"
),
run
:
()
=>
this
.
openerService
.
open
External
(
URI
.
parse
(
'
https://go.microsoft.com/fwlink/?LinkId=786533
'
))
run
:
()
=>
this
.
openerService
.
open
(
URI
.
parse
(
'
https://go.microsoft.com/fwlink/?LinkId=786533
'
))
}],
{
sticky
:
true
,
...
...
@@ -95,7 +95,7 @@ export class WorkspaceWatcher extends Disposable {
localize
(
'
enospcError
'
,
"
Unable to watch for file changes in this large workspace. Please follow the instructions link to resolve this issue.
"
),
[{
label
:
localize
(
'
learnMore
'
,
"
Instructions
"
),
run
:
()
=>
this
.
openerService
.
open
External
(
URI
.
parse
(
'
https://go.microsoft.com/fwlink/?linkid=867693
'
))
run
:
()
=>
this
.
openerService
.
open
(
URI
.
parse
(
'
https://go.microsoft.com/fwlink/?linkid=867693
'
))
}],
{
sticky
:
true
,
...
...
src/vs/workbench/services/integrity/node/integrityService.ts
浏览文件 @
d5026ed3
...
...
@@ -93,7 +93,7 @@ export class IntegrityServiceImpl implements IIntegrityService {
[
{
label
:
nls
.
localize
(
'
integrity.moreInformation
'
,
"
More Information
"
),
run
:
()
=>
this
.
openerService
.
open
External
(
URI
.
parse
(
product
.
checksumFailMoreInfoUrl
))
run
:
()
=>
this
.
openerService
.
open
(
URI
.
parse
(
product
.
checksumFailMoreInfoUrl
))
},
{
label
:
nls
.
localize
(
'
integrity.dontShowAgain
'
,
"
Don't Show Again
"
),
...
...
src/vs/workbench/services/opener/electron-browser/openerService.ts
已删除
100644 → 0
浏览文件 @
df0dd2ed
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
OpenerService
as
BaseOpenerService
}
from
'
vs/editor/browser/services/openerService
'
;
import
{
IWindowsService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IDialogService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/product
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
export
class
OpenerService
extends
BaseOpenerService
{
_serviceBrand
!
:
ServiceIdentifier
<
any
>
;
constructor
(
@
ICodeEditorService
codeEditorService
:
ICodeEditorService
,
@
ICommandService
commandService
:
ICommandService
,
@
IWindowsService
private
readonly
windowsService
:
IWindowsService
,
@
IStorageService
readonly
storageService
:
IStorageService
,
@
IDialogService
readonly
dialogService
:
IDialogService
,
@
IProductService
readonly
productService
:
IProductService
)
{
super
(
codeEditorService
,
commandService
,
storageService
,
dialogService
,
productService
);
}
async
openExternal
(
resource
:
URI
):
Promise
<
boolean
>
{
const
success
=
this
.
windowsService
.
openExternal
(
encodeURI
(
resource
.
toString
(
true
)));
if
(
!
success
&&
resource
.
scheme
===
Schemas
.
file
)
{
await
this
.
windowsService
.
showItemInFolder
(
resource
);
return
true
;
}
return
success
;
}
}
registerSingleton
(
IOpenerService
,
OpenerService
,
true
);
src/vs/workbench/workbench.common.main.ts
浏览文件 @
d5026ed3
...
...
@@ -96,6 +96,8 @@ import { IMenuService } from 'vs/platform/actions/common/actions';
import
{
MenuService
}
from
'
vs/platform/actions/common/menuService
'
;
import
{
IDownloadService
}
from
'
vs/platform/download/common/download
'
;
import
{
DownloadService
}
from
'
vs/platform/download/common/downloadService
'
;
import
{
OpenerService
}
from
'
vs/editor/browser/services/openerService
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
registerSingleton
(
IExtensionGalleryService
,
ExtensionGalleryService
,
true
);
registerSingleton
(
IContextViewService
,
ContextViewService
,
true
);
...
...
@@ -108,6 +110,7 @@ registerSingleton(IModelService, ModelServiceImpl, true);
registerSingleton
(
ITextResourceConfigurationService
,
TextResourceConfigurationService
);
registerSingleton
(
IMenuService
,
MenuService
,
true
);
registerSingleton
(
IDownloadService
,
DownloadService
,
true
);
registerSingleton
(
IOpenerService
,
OpenerService
,
true
);
//#endregion
...
...
src/vs/workbench/workbench.desktop.main.ts
浏览文件 @
d5026ed3
...
...
@@ -48,7 +48,6 @@ import 'vs/workbench/services/extensionManagement/node/extensionManagementServic
import
'
vs/workbench/services/accessibility/node/accessibilityService
'
;
import
'
vs/workbench/services/remote/node/tunnelService
'
;
import
'
vs/workbench/services/backup/node/backupFileService
'
;
import
'
vs/workbench/services/opener/electron-browser/openerService
'
;
import
'
vs/workbench/services/credentials/node/credentialsService
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
...
...
src/vs/workbench/workbench.web.main.ts
浏览文件 @
d5026ed3
...
...
@@ -56,8 +56,6 @@ import { ContextMenuService } from 'vs/platform/contextview/browser/contextMenuS
import
{
IBackupFileService
}
from
'
vs/workbench/services/backup/common/backup
'
;
import
{
BackupFileService
}
from
'
vs/workbench/services/backup/common/backupFileService
'
;
import
{
ExtensionManagementService
}
from
'
vs/workbench/services/extensionManagement/common/extensionManagementService
'
;
import
{
OpenerService
}
from
'
vs/editor/browser/services/openerService
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
registerSingleton
(
IRequestService
,
RequestService
,
true
);
registerSingleton
(
IExtensionManagementService
,
ExtensionManagementService
);
...
...
@@ -67,7 +65,6 @@ registerSingleton(IClipboardService, BrowserClipboardService, true);
registerSingleton
(
IAccessibilityService
,
BrowserAccessibilityService
,
true
);
registerSingleton
(
ILifecycleService
,
BrowserLifecycleService
);
registerSingleton
(
IContextMenuService
,
ContextMenuService
);
registerSingleton
(
IOpenerService
,
OpenerService
,
true
);
//#endregion
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录