Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
78707964
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,发现更多精彩内容 >>
提交
78707964
编写于
4月 06, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce duplicate state for active webviews
上级
7307023e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
47 deletion
+27
-47
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
+18
-10
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+1
-2
src/vs/workbench/api/node/extHostWebview.ts
src/vs/workbench/api/node/extHostWebview.ts
+8
-31
src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts
...ench/parts/webview/electron-browser/webviewEditorInput.ts
+0
-4
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
浏览文件 @
78707964
...
...
@@ -37,7 +37,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
private
readonly
_webviews
=
new
Map
<
WebviewHandle
,
WebviewEditorInput
>
();
private
readonly
_revivers
=
new
Set
<
string
>
();
private
_activeWebview
:
Webview
EditorInput
|
undefined
=
undefined
;
private
_activeWebview
:
Webview
Handle
|
undefined
=
undefined
;
constructor
(
context
:
IExtHostContext
,
...
...
@@ -175,7 +175,6 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
return
{
onDidClickLink
:
uri
=>
this
.
onDidClickLink
(
handle
,
uri
),
onMessage
:
message
=>
this
.
_proxy
.
$onMessage
(
handle
,
message
),
onDidChangePosition
:
position
=>
this
.
_proxy
.
$onDidChangePosition
(
handle
,
position
),
onDispose
:
()
=>
{
this
.
_proxy
.
$onDidDisposeWeview
(
handle
).
then
(()
=>
{
this
.
_webviews
.
delete
(
handle
);
...
...
@@ -205,16 +204,25 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
}
}
if
(
newActiveWebview
)
{
if
(
!
this
.
_activeWebview
||
newActiveWebview
.
input
!==
this
.
_activeWebview
)
{
this
.
_proxy
.
$onDidChangeActiveWeview
(
newActiveWebview
.
handle
);
this
.
_activeWebview
=
newActiveWebview
.
input
;
if
(
newActiveWebview
&&
newActiveWebview
.
handle
===
this
.
_activeWebview
)
{
// No change
return
;
}
// Broadcast view state update for currently active
if
(
typeof
this
.
_activeWebview
!==
'
undefined
'
)
{
const
oldActiveWebview
=
this
.
_webviews
.
get
(
this
.
_activeWebview
);
if
(
oldActiveWebview
)
{
this
.
_proxy
.
$onDidChangeWeviewViewState
(
this
.
_activeWebview
,
false
,
oldActiveWebview
.
position
);
}
}
// Then for newly active
if
(
newActiveWebview
)
{
this
.
_proxy
.
$onDidChangeWeviewViewState
(
newActiveWebview
.
handle
,
true
,
activeEditor
.
position
);
this
.
_activeWebview
=
newActiveWebview
.
handle
;
}
else
{
if
(
this
.
_activeWebview
)
{
this
.
_proxy
.
$onDidChangeActiveWeview
(
undefined
);
this
.
_activeWebview
=
undefined
;
}
this
.
_activeWebview
=
undefined
;
}
}
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
78707964
...
...
@@ -363,9 +363,8 @@ export interface MainThreadWebviewsShape extends IDisposable {
export
interface
ExtHostWebviewsShape
{
$onMessage
(
handle
:
WebviewHandle
,
message
:
any
):
void
;
$onDidChange
ActiveWeview
(
handle
:
WebviewHandle
|
undefined
):
void
;
$onDidChange
WeviewViewState
(
handle
:
WebviewHandle
,
active
:
boolean
,
position
:
EditorPosition
):
void
;
$onDidDisposeWeview
(
handle
:
WebviewHandle
):
Thenable
<
void
>
;
$onDidChangePosition
(
handle
:
WebviewHandle
,
newPosition
:
EditorPosition
):
void
;
$deserializeWebview
(
newWebviewHandle
:
WebviewHandle
,
viewType
:
string
,
state
:
any
,
position
:
EditorPosition
,
options
:
vscode
.
WebviewOptions
):
Thenable
<
void
>
;
$serializeWebview
(
webviewHandle
:
WebviewHandle
):
Thenable
<
any
>
;
}
...
...
src/vs/workbench/api/node/extHostWebview.ts
浏览文件 @
78707964
...
...
@@ -140,8 +140,6 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
private
readonly
_webviews
=
new
Map
<
WebviewHandle
,
ExtHostWebview
>
();
private
readonly
_serializers
=
new
Map
<
string
,
vscode
.
WebviewSerializer
>
();
private
_activeWebview
:
ExtHostWebview
|
undefined
;
constructor
(
mainContext
:
IMainContext
)
{
...
...
@@ -187,21 +185,14 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
}
}
$onDidChangeActiveWeview
(
handle
:
WebviewHandle
|
undefined
):
void
{
if
(
handle
)
{
const
webview
=
this
.
getWebview
(
handle
);
if
(
webview
)
{
if
(
webview
!==
this
.
_activeWebview
)
{
this
.
_activeWebview
=
webview
;
webview
.
active
=
true
;
webview
.
onDidChangeViewStateEmitter
.
fire
({
viewColumn
:
webview
.
viewColumn
,
active
:
true
});
}
}
}
else
{
if
(
this
.
_activeWebview
)
{
this
.
_activeWebview
.
active
=
false
;
this
.
_activeWebview
.
onDidChangeViewStateEmitter
.
fire
({
viewColumn
:
this
.
_activeWebview
.
viewColumn
,
active
:
false
});
this
.
_activeWebview
=
undefined
;
$onDidChangeWeviewViewState
(
handle
:
WebviewHandle
,
active
:
boolean
,
position
:
Position
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
if
(
webview
)
{
const
viewColumn
=
typeConverters
.
toViewColumn
(
position
);
if
(
webview
.
active
!==
active
||
webview
.
viewColumn
!==
viewColumn
)
{
webview
.
active
=
active
;
webview
.
viewColumn
=
viewColumn
;
webview
.
onDidChangeViewStateEmitter
.
fire
({
active
,
viewColumn
});
}
}
}
...
...
@@ -211,24 +202,10 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
if
(
webview
)
{
webview
.
onDisposeEmitter
.
fire
();
this
.
_webviews
.
delete
(
handle
);
if
(
this
.
_activeWebview
===
webview
)
{
this
.
_activeWebview
=
undefined
;
}
}
return
TPromise
.
as
(
void
0
);
}
$onDidChangePosition
(
handle
:
WebviewHandle
,
newPosition
:
Position
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
if
(
webview
)
{
const
newViewColumn
=
typeConverters
.
toViewColumn
(
newPosition
);
if
(
webview
.
viewColumn
!==
newViewColumn
)
{
webview
.
viewColumn
=
newViewColumn
;
webview
.
onDidChangeViewStateEmitter
.
fire
({
viewColumn
:
newViewColumn
,
active
:
webview
.
active
});
}
}
}
$deserializeWebview
(
webviewHandle
:
WebviewHandle
,
viewType
:
string
,
...
...
src/vs/workbench/parts/webview/electron-browser/webviewEditorInput.ts
浏览文件 @
78707964
...
...
@@ -228,9 +228,5 @@ export class WebviewEditorInput extends EditorInput {
public
onBecameActive
(
position
:
Position
):
void
{
this
.
_position
=
position
;
if
(
this
.
_events
&&
this
.
_events
.
onDidChangePosition
)
{
this
.
_events
.
onDidChangePosition
(
position
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录