Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d2419872
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 搜索 >>
提交
d2419872
编写于
8月 20, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use bi-direcitonal map for mapping webviews to handles
上级
b1dd95c8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
13 deletion
+41
-13
src/vs/workbench/api/browser/mainThreadWebview.ts
src/vs/workbench/api/browser/mainThreadWebview.ts
+41
-13
未找到文件。
src/vs/workbench/api/browser/mainThreadWebview.ts
浏览文件 @
d2419872
...
...
@@ -5,31 +5,62 @@
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
map
from
'
vs/base/common/map
'
;
import
{
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
ExtensionIdentifier
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/product
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ExtHostContext
,
ExtHostWebviewsShape
,
IExtHostContext
,
MainContext
,
MainThreadWebviewsShape
,
WebviewPanelHandle
,
WebviewPanelShowOptions
,
WebviewPanelViewStateData
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
editorGroupToViewColumn
,
EditorViewColumn
,
viewColumnToEditorGroup
}
from
'
vs/workbench/api/common/shared/editor
'
;
import
{
Webview
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
WebviewEditorInput
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorInput
'
;
import
{
ICreateWebViewShowOptions
,
IWebviewEditorService
,
WebviewInputOptions
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
extHostNamedCustomer
}
from
'
../common/extHostCustomers
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/product
'
;
import
{
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
Webview
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
find
}
from
'
vs/base/common/arrays
'
;
interface
OldMainThreadWebviewState
{
readonly
viewType
:
string
;
state
:
any
;
}
/**
* Bi-directional map between webview handles and inputs.
*/
class
WebviewHandleStore
{
private
readonly
_handlesToInputs
=
new
Map
<
string
,
WebviewEditorInput
>
();
private
readonly
_inputsToHandles
=
new
Map
<
WebviewEditorInput
,
string
>
();
public
add
(
handle
:
string
,
input
:
WebviewEditorInput
):
void
{
this
.
_handlesToInputs
.
set
(
handle
,
input
);
this
.
_inputsToHandles
.
set
(
input
,
handle
);
}
public
getHandleForInput
(
input
:
WebviewEditorInput
):
string
|
undefined
{
return
this
.
_inputsToHandles
.
get
(
input
);
}
public
getInputForHandle
(
handle
:
string
):
WebviewEditorInput
|
undefined
{
return
this
.
_handlesToInputs
.
get
(
handle
);
}
public
delete
(
handle
:
string
):
void
{
const
input
=
this
.
getInputForHandle
(
handle
);
this
.
_handlesToInputs
.
delete
(
handle
);
if
(
input
)
{
this
.
_inputsToHandles
.
delete
(
input
);
}
}
public
get
size
():
number
{
return
this
.
_handlesToInputs
.
size
;
}
}
@
extHostNamedCustomer
(
MainContext
.
MainThreadWebviews
)
export
class
MainThreadWebviews
extends
Disposable
implements
MainThreadWebviewsShape
{
...
...
@@ -44,7 +75,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
private
static
revivalPool
=
0
;
private
readonly
_proxy
:
ExtHostWebviewsShape
;
private
readonly
_webviewEditorInputs
=
new
Map
<
string
,
WebviewEditorInput
>
();
private
readonly
_webviewEditorInputs
=
new
WebviewHandleStore
();
private
readonly
_revivers
=
new
Map
<
string
,
IDisposable
>
();
constructor
(
...
...
@@ -102,7 +133,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
});
this
.
hookupWebviewEventDelegate
(
handle
,
webview
);
this
.
_webviewEditorInputs
.
set
(
handle
,
webview
);
this
.
_webviewEditorInputs
.
add
(
handle
,
webview
);
/* __GDPR__
"webviews:createWebviewPanel" : {
...
...
@@ -172,7 +203,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
const
handle
=
`revival-
${
MainThreadWebviews
.
revivalPool
++
}
`
;
this
.
_webviewEditorInputs
.
set
(
handle
,
webviewEditorInput
);
this
.
_webviewEditorInputs
.
add
(
handle
,
webviewEditorInput
);
this
.
hookupWebviewEventDelegate
(
handle
,
webviewEditorInput
);
let
state
=
undefined
;
...
...
@@ -254,10 +285,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
continue
;
}
const
handle
=
find
(
map
.
keys
(
this
.
_webviewEditorInputs
),
handle
=>
input
===
this
.
_webviewEditorInputs
.
get
(
handle
));
const
handle
=
this
.
_webviewEditorInputs
.
getHandleForInput
(
input
);
if
(
handle
)
{
viewStates
[
handle
]
=
{
visible
:
input
===
group
.
activeEditor
,
...
...
@@ -303,7 +331,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
}
private
tryGetWebviewEditorInput
(
handle
:
WebviewPanelHandle
):
WebviewEditorInput
|
undefined
{
return
this
.
_webviewEditorInputs
.
get
(
handle
);
return
this
.
_webviewEditorInputs
.
get
InputForHandle
(
handle
);
}
private
getWebview
(
handle
:
WebviewPanelHandle
):
Webview
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录