Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
904e4260
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,发现更多精彩内容 >>
提交
904e4260
编写于
2月 28, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce RevivedWebviewEditorInput
上级
98c084ff
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
24 deletion
+43
-24
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
+2
-2
src/vs/workbench/contrib/webview/electron-browser/webviewEditorInput.ts
...ch/contrib/webview/electron-browser/webviewEditorInput.ts
+27
-7
src/vs/workbench/contrib/webview/electron-browser/webviewEditorInputFactory.ts
...rib/webview/electron-browser/webviewEditorInputFactory.ts
+2
-2
src/vs/workbench/contrib/webview/electron-browser/webviewEditorService.ts
.../contrib/webview/electron-browser/webviewEditorService.ts
+12
-13
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
浏览文件 @
904e4260
...
...
@@ -11,7 +11,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import
{
ExtHostContext
,
ExtHostWebviewsShape
,
IExtHostContext
,
MainContext
,
MainThreadWebviewsShape
,
WebviewPanelHandle
,
WebviewPanelShowOptions
,
WebviewInsetHandle
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
editorGroupToViewColumn
,
EditorViewColumn
,
viewColumnToEditorGroup
}
from
'
vs/workbench/api/shared/editor
'
;
import
{
WebviewEditor
}
from
'
vs/workbench/contrib/webview/electron-browser/webviewEditor
'
;
import
{
WebviewEditorInput
}
from
'
vs/workbench/contrib/webview/electron-browser/webviewEditorInput
'
;
import
{
WebviewEditorInput
,
RevivedWebviewEditorInput
}
from
'
vs/workbench/contrib/webview/electron-browser/webviewEditorInput
'
;
import
{
ICreateWebViewShowOptions
,
IWebviewEditorService
,
WebviewInputOptions
,
WebviewReviver
}
from
'
vs/workbench/contrib/webview/electron-browser/webviewEditorService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
...
...
@@ -246,7 +246,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
return
false
;
}
return
this
.
_revivers
.
has
(
webview
.
state
.
viewType
)
||
!!
webview
.
reviver
;
return
this
.
_revivers
.
has
(
webview
.
state
.
viewType
)
||
!!
(
webview
as
RevivedWebviewEditorInput
)
.
reviver
;
}
private
_onBeforeShutdown
():
boolean
{
...
...
src/vs/workbench/contrib/webview/electron-browser/webviewEditorInput.ts
浏览文件 @
904e4260
...
...
@@ -64,8 +64,6 @@ export class WebviewEditorInput extends EditorInput {
private
_scrollYPercentage
:
number
=
0
;
private
_state
:
any
;
private
_revived
:
boolean
=
false
;
public
readonly
extensionLocation
:
URI
|
undefined
;
private
readonly
_id
:
number
;
...
...
@@ -77,7 +75,6 @@ export class WebviewEditorInput extends EditorInput {
state
:
any
,
events
:
WebviewEvents
,
extensionLocation
:
URI
|
undefined
,
public
readonly
reviver
:
(
input
:
WebviewEditorInput
)
=>
Promise
<
void
>
|
undefined
,
@
IPartService
private
readonly
_partService
:
IPartService
,
)
{
super
();
...
...
@@ -213,10 +210,6 @@ export class WebviewEditorInput extends EditorInput {
}
public
resolve
():
Promise
<
IEditorModel
>
{
if
(
this
.
reviver
&&
!
this
.
_revived
)
{
this
.
_revived
=
true
;
return
this
.
reviver
(
this
).
then
(()
=>
new
EditorModel
());
}
return
Promise
.
resolve
(
new
EditorModel
());
}
...
...
@@ -310,3 +303,30 @@ export class WebviewEditorInput extends EditorInput {
this
.
_group
=
group
;
}
}
export
class
RevivedWebviewEditorInput
extends
WebviewEditorInput
{
private
_revived
:
boolean
=
false
;
constructor
(
viewType
:
string
,
id
:
number
|
undefined
,
name
:
string
,
options
:
WebviewInputOptions
,
state
:
any
,
events
:
WebviewEvents
,
extensionLocation
:
URI
|
undefined
,
public
readonly
reviver
:
(
input
:
WebviewEditorInput
)
=>
Promise
<
void
>
,
@
IPartService
partService
:
IPartService
,
)
{
super
(
viewType
,
id
,
name
,
options
,
state
,
events
,
extensionLocation
,
partService
);
}
public
async
resolve
():
Promise
<
IEditorModel
>
{
if
(
!
this
.
_revived
)
{
this
.
_revived
=
true
;
await
this
.
reviver
(
this
);
}
return
super
.
resolve
();
}
}
\ No newline at end of file
src/vs/workbench/contrib/webview/electron-browser/webviewEditorInputFactory.ts
浏览文件 @
904e4260
...
...
@@ -5,7 +5,7 @@
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEditorInputFactory
}
from
'
vs/workbench/common/editor
'
;
import
{
WebviewEditorInput
}
from
'
./webviewEditorInput
'
;
import
{
WebviewEditorInput
,
RevivedWebviewEditorInput
}
from
'
./webviewEditorInput
'
;
import
{
IWebviewEditorService
,
WebviewInputOptions
}
from
'
./webviewEditorService
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
...
...
@@ -41,7 +41,7 @@ export class WebviewEditorInputFactory implements IEditorInputFactory {
}
// Only attempt revival if we may have a reviver
if
(
!
this
.
_webviewService
.
canRevive
(
input
)
&&
!
input
.
reviver
)
{
if
(
!
this
.
_webviewService
.
canRevive
(
input
)
&&
!
(
input
instanceof
RevivedWebviewEditorInput
)
)
{
return
null
;
}
...
...
src/vs/workbench/contrib/webview/electron-browser/webviewEditorService.ts
浏览文件 @
904e4260
...
...
@@ -9,7 +9,7 @@ import { IInstantiationService, createDecorator } from 'vs/platform/instantiatio
import
{
IEditorService
,
ACTIVE_GROUP_TYPE
,
SIDE_GROUP_TYPE
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroupsService
,
IEditorGroup
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
WebviewEditorInput
}
from
'
./webviewEditorInput
'
;
import
{
WebviewEditorInput
,
RevivedWebviewEditorInput
}
from
'
./webviewEditorInput
'
;
import
{
GroupIdentifier
}
from
'
vs/workbench/common/editor
'
;
import
{
equals
}
from
'
vs/base/common/arrays
'
;
...
...
@@ -132,18 +132,17 @@ export class WebviewEditorService implements IWebviewEditorService {
options
:
WebviewInputOptions
,
extensionLocation
:
URI
):
WebviewEditorInput
{
const
webviewInput
=
this
.
_instantiationService
.
createInstance
(
WebviewEditorInput
,
viewType
,
id
,
title
,
options
,
state
,
{},
extensionLocation
,
(
webview
:
WebviewEditorInput
):
Promise
<
void
>
=>
{
return
this
.
tryRevive
(
webview
).
then
(
didRevive
=>
{
if
(
didRevive
)
{
return
Promise
.
resolve
(
undefined
);
}
// A reviver may not be registered yet. Put into queue and resolve promise when we can revive
let
resolve
:
(
value
:
void
)
=>
void
;
const
promise
=
new
Promise
<
void
>
(
r
=>
{
resolve
=
r
;
});
this
.
_awaitingRevival
.
push
({
input
:
webview
,
resolve
:
resolve
!
});
return
promise
;
});
const
webviewInput
=
this
.
_instantiationService
.
createInstance
(
RevivedWebviewEditorInput
,
viewType
,
id
,
title
,
options
,
state
,
{},
extensionLocation
,
async
(
webview
:
WebviewEditorInput
):
Promise
<
void
>
=>
{
const
didRevive
=
await
this
.
tryRevive
(
webview
);
if
(
didRevive
)
{
return
Promise
.
resolve
(
undefined
);
}
// A reviver may not be registered yet. Put into queue and resolve promise when we can revive
let
resolve
:
()
=>
void
;
const
promise
=
new
Promise
<
void
>
(
r
=>
{
resolve
=
r
;
});
this
.
_awaitingRevival
.
push
({
input
:
webview
,
resolve
:
resolve
!
});
return
promise
;
});
webviewInput
.
iconPath
=
iconPath
;
return
webviewInput
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录