Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ec8016f7
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,发现更多精彩内容 >>
提交
ec8016f7
编写于
9月 09, 2020
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cache webview view title across reloads
Fixes #105867
上级
cf38af84
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
30 addition
and
9 deletion
+30
-9
src/vs/workbench/api/browser/mainThreadWebviewViews.ts
src/vs/workbench/api/browser/mainThreadWebviewViews.ts
+1
-1
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+1
-1
src/vs/workbench/api/common/extHostWebviewView.ts
src/vs/workbench/api/common/extHostWebviewView.ts
+4
-1
src/vs/workbench/contrib/webviewView/browser/webviewViewPane.ts
.../workbench/contrib/webviewView/browser/webviewViewPane.ts
+24
-6
未找到文件。
src/vs/workbench/api/browser/mainThreadWebviewViews.ts
浏览文件 @
ec8016f7
...
...
@@ -78,7 +78,7 @@ export class MainThreadWebviewsViews extends Disposable implements extHostProtoc
});
try
{
await
this
.
_proxy
.
$resolveWebviewView
(
handle
,
viewType
,
state
,
cancellation
);
await
this
.
_proxy
.
$resolveWebviewView
(
handle
,
viewType
,
webviewView
.
title
,
state
,
cancellation
);
}
catch
(
error
)
{
onUnexpectedError
(
error
);
webviewView
.
webview
.
html
=
this
.
mainThreadWebviews
.
getWebviewResolvedFailedContent
(
viewType
);
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
ec8016f7
...
...
@@ -686,7 +686,7 @@ export interface ExtHostCustomEditorsShape {
}
export
interface
ExtHostWebviewViewsShape
{
$resolveWebviewView
(
webviewHandle
:
WebviewHandle
,
viewType
:
string
,
state
:
any
,
cancellation
:
CancellationToken
):
Promise
<
void
>
;
$resolveWebviewView
(
webviewHandle
:
WebviewHandle
,
viewType
:
string
,
title
:
string
|
undefined
,
state
:
any
,
cancellation
:
CancellationToken
):
Promise
<
void
>
;
$onDidChangeWebviewViewVisibility
(
webviewHandle
:
WebviewHandle
,
visible
:
boolean
):
void
;
...
...
src/vs/workbench/api/common/extHostWebviewView.ts
浏览文件 @
ec8016f7
...
...
@@ -29,12 +29,14 @@ class ExtHostWebviewView extends Disposable implements vscode.WebviewView {
handle
:
extHostProtocol
.
WebviewHandle
,
proxy
:
extHostProtocol
.
MainThreadWebviewViewsShape
,
viewType
:
string
,
title
:
string
|
undefined
,
webview
:
ExtHostWebview
,
isVisible
:
boolean
,
)
{
super
();
this
.
#
viewType
=
viewType
;
this
.
#
title
=
title
;
this
.
#
handle
=
handle
;
this
.
#
proxy
=
proxy
;
this
.
#
webview
=
webview
;
...
...
@@ -153,6 +155,7 @@ export class ExtHostWebviewViews implements extHostProtocol.ExtHostWebviewViewsS
async
$resolveWebviewView
(
webviewHandle
:
string
,
viewType
:
string
,
title
:
string
|
undefined
,
state
:
any
,
cancellation
:
CancellationToken
,
):
Promise
<
void
>
{
...
...
@@ -164,7 +167,7 @@ export class ExtHostWebviewViews implements extHostProtocol.ExtHostWebviewViewsS
const
{
provider
,
extension
}
=
entry
;
const
webview
=
this
.
_extHostWebview
.
createNewWebview
(
webviewHandle
,
{
/* todo */
},
extension
);
const
revivedView
=
new
ExtHostWebviewView
(
webviewHandle
,
this
.
_proxy
,
viewType
,
webview
,
true
);
const
revivedView
=
new
ExtHostWebviewView
(
webviewHandle
,
this
.
_proxy
,
viewType
,
title
,
webview
,
true
);
this
.
_webviewViews
.
set
(
webviewHandle
,
revivedView
);
...
...
src/vs/workbench/contrib/webviewView/browser/webviewViewPane.ts
浏览文件 @
ec8016f7
...
...
@@ -28,7 +28,10 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
declare
const
ResizeObserver
:
any
;
const
webviewStateKey
=
'
webviewState
'
;
const
storageKeys
=
{
webviewState
:
'
webviewState
'
,
title
:
'
title
'
}
as
const
;
export
class
WebviewViewPane
extends
ViewPane
{
...
...
@@ -38,6 +41,9 @@ export class WebviewViewPane extends ViewPane {
private
_container
?:
HTMLElement
;
private
_resizeObserver
?:
any
;
private
readonly
defaultTitle
:
string
;
private
setTitle
:
string
|
undefined
;
private
readonly
memento
:
Memento
;
private
readonly
viewState
:
MementoObject
;
...
...
@@ -60,10 +66,16 @@ export class WebviewViewPane extends ViewPane {
@
IViewsService
private
readonly
viewService
:
IViewsService
,
)
{
super
({
...
options
,
titleMenuId
:
MenuId
.
ViewTitle
},
keybindingService
,
contextMenuService
,
configurationService
,
contextKeyService
,
viewDescriptorService
,
instantiationService
,
openerService
,
themeService
,
telemetryService
);
this
.
defaultTitle
=
this
.
title
;
this
.
memento
=
new
Memento
(
`webviewView.
${
this
.
id
}
`
,
storageService
);
this
.
viewState
=
this
.
memento
.
getMemento
(
StorageScope
.
WORKSPACE
);
const
storedTitle
=
this
.
viewState
[
storageKeys
.
title
];
if
(
typeof
storedTitle
===
'
string
'
)
{
this
.
updateTitle
(
storedTitle
);
}
this
.
_register
(
this
.
onDidChangeBodyVisibility
(()
=>
this
.
updateTreeVisibility
()));
this
.
updateTreeVisibility
();
}
...
...
@@ -108,8 +120,9 @@ export class WebviewViewPane extends ViewPane {
public
saveState
()
{
if
(
this
.
_webview
)
{
this
.
viewState
[
webviewStateKey
]
=
this
.
_webview
.
state
;
this
.
viewState
[
storageKeys
.
webviewState
]
=
this
.
_webview
.
state
;
}
this
.
viewState
[
storageKeys
.
title
]
=
this
.
setTitle
;
this
.
memento
.
saveMemento
();
super
.
saveState
();
...
...
@@ -142,7 +155,7 @@ export class WebviewViewPane extends ViewPane {
const
webviewId
=
`webviewView-
${
this
.
id
.
replace
(
/
[^
a-z0-9
]
/gi
,
'
-
'
)}
`
.
toLowerCase
();
const
webview
=
this
.
webviewService
.
createWebviewOverlay
(
webviewId
,
{},
{},
undefined
);
webview
.
state
=
this
.
viewState
[
'
webviewState
'
];
webview
.
state
=
this
.
viewState
[
storageKeys
.
webviewState
];
this
.
_webview
=
webview
;
this
.
_register
(
toDisposable
(()
=>
{
...
...
@@ -150,7 +163,7 @@ export class WebviewViewPane extends ViewPane {
}));
this
.
_register
(
webview
.
onDidUpdateState
(()
=>
{
this
.
viewState
[
webviewStateKey
]
=
webview
.
state
;
this
.
viewState
[
storageKeys
.
webviewState
]
=
webview
.
state
;
}));
const
source
=
this
.
_register
(
new
CancellationTokenSource
());
...
...
@@ -164,8 +177,8 @@ export class WebviewViewPane extends ViewPane {
onDidChangeVisibility
:
this
.
onDidChangeBodyVisibility
,
onDispose
:
this
.
onDispose
,
get
title
()
{
return
self
.
t
itle
;
},
set
title
(
value
:
string
)
{
self
.
updateTitle
(
value
);
},
get
title
()
:
string
|
undefined
{
return
self
.
setT
itle
;
},
set
title
(
value
:
string
|
undefined
)
{
self
.
updateTitle
(
value
);
},
get
description
():
string
|
undefined
{
return
self
.
titleDescription
;
},
set
description
(
value
:
string
|
undefined
)
{
self
.
updateTitleDescription
(
value
);
},
...
...
@@ -180,6 +193,11 @@ export class WebviewViewPane extends ViewPane {
}
}
protected
updateTitle
(
value
:
string
|
undefined
)
{
this
.
setTitle
=
value
;
super
.
updateTitle
(
typeof
value
===
'
string
'
?
value
:
this
.
defaultTitle
);
}
private
async
withProgress
(
task
:
()
=>
Promise
<
void
>
):
Promise
<
void
>
{
return
this
.
progressService
.
withProgress
({
location
:
this
.
id
,
delay
:
500
},
task
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录