Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
12e72de9
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,发现更多精彩内容 >>
提交
12e72de9
编写于
10月 09, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reuse LazilyResolvedWebviewEditorInput for custom editors as well
上级
b9e08fa6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
30 deletion
+17
-30
src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
...rkbench/contrib/customEditor/browser/customEditorInput.ts
+7
-17
src/vs/workbench/contrib/webview/browser/webviewEditorInput.ts
...s/workbench/contrib/webview/browser/webviewEditorInput.ts
+7
-10
src/vs/workbench/contrib/webview/browser/webviewEditorService.ts
...workbench/contrib/webview/browser/webviewEditorService.ts
+3
-3
未找到文件。
src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
浏览文件 @
12e72de9
...
...
@@ -6,25 +6,23 @@
import
{
memoize
}
from
'
vs/base/common/decorators
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
UnownedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
basename
}
from
'
vs/base/common/path
'
;
import
{
isEqual
,
DataUri
}
from
'
vs/base/common/resources
'
;
import
{
DataUri
,
isEqual
}
from
'
vs/base/common/resources
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
WebviewContentState
}
from
'
vs/editor/common/modes
'
;
import
{
IDialogService
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
IEditorModel
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
ConfirmResult
,
IEditorInput
,
Verbosity
}
from
'
vs/workbench/common/editor
'
;
import
{
WebviewEditorOverlay
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
Webview
Input
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorInput
'
;
import
{
LazilyResolvedWebviewEditor
Input
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorInput
'
;
import
{
IWebviewEditorService
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorService
'
;
import
{
promptSave
}
from
'
vs/workbench/services/textfile/browser/textFileService
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
export
class
CustomFileEditorInput
extends
Webview
Input
{
export
class
CustomFileEditorInput
extends
LazilyResolvedWebviewEditor
Input
{
public
static
typeId
=
'
workbench.editors.webviewEditor
'
;
private
_hasResolved
=
false
;
private
readonly
_editorResource
:
URI
;
private
_state
=
WebviewContentState
.
Readonly
;
...
...
@@ -33,11 +31,11 @@ export class CustomFileEditorInput extends WebviewInput {
viewType
:
string
,
id
:
string
,
webview
:
UnownedDisposable
<
WebviewEditorOverlay
>
,
@
ILabelService
private
readonly
labelService
:
ILabelService
,
@
IWebviewEditorService
private
readonly
_webviewEditorService
:
IWebviewEditorService
,
@
IWebviewEditorService
webviewEditorService
:
IWebviewEditorService
,
@
IDialogService
private
readonly
dialogService
:
IDialogService
,
@
ILabelService
private
readonly
labelService
:
ILabelService
,
)
{
super
(
id
,
viewType
,
''
,
webview
);
super
(
id
,
viewType
,
''
,
webview
,
webviewEditorService
);
this
.
_editorResource
=
resource
;
}
...
...
@@ -112,14 +110,6 @@ export class CustomFileEditorInput extends WebviewInput {
}
}
public
async
resolve
():
Promise
<
IEditorModel
>
{
if
(
!
this
.
_hasResolved
)
{
this
.
_hasResolved
=
true
;
await
this
.
_webviewEditorService
.
resolveWebview
(
this
);
}
return
super
.
resolve
();
}
public
setState
(
newState
:
WebviewContentState
):
void
{
this
.
_state
=
newState
;
this
.
_onDidChangeDirty
.
fire
();
...
...
src/vs/workbench/contrib/webview/browser/webviewEditorInput.ts
浏览文件 @
12e72de9
...
...
@@ -4,11 +4,12 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
memoize
}
from
'
vs/base/common/decorators
'
;
import
{
UnownedDisposable
as
Unowned
}
from
'
vs/base/common/lifecycle
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IEditorModel
}
from
'
vs/platform/editor/common/editor
'
;
import
{
EditorInput
,
EditorModel
,
GroupIdentifier
,
IEditorInput
,
Verbosity
}
from
'
vs/workbench/common/editor
'
;
import
{
WebviewEditorOverlay
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
UnownedDisposable
as
Unowned
}
from
'
vs/base/common/lifecycl
e
'
;
import
{
IWebviewEditorService
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorServic
e
'
;
const
WebviewPanelResourceScheme
=
'
webview-panel
'
;
...
...
@@ -141,24 +142,20 @@ export class WebviewInput extends EditorInput {
}
}
export
class
RevivedWebviewEditorInput
extends
WebviewInput
{
private
_revived
:
boolean
=
false
;
export
class
LazilyResolvedWebviewEditorInput
extends
WebviewInput
{
constructor
(
id
:
string
,
viewType
:
string
,
name
:
string
,
private
readonly
reviver
:
(
input
:
WebviewInput
)
=>
Promise
<
void
>
,
webview
:
Unowned
<
WebviewEditorOverlay
>
webview
:
Unowned
<
WebviewEditorOverlay
>
,
@
IWebviewEditorService
private
readonly
_webviewEditorService
:
IWebviewEditorService
,
)
{
super
(
id
,
viewType
,
name
,
webview
);
}
@
memoize
public
async
resolve
():
Promise
<
IEditorModel
>
{
if
(
!
this
.
_revived
)
{
this
.
_revived
=
true
;
await
this
.
reviver
(
this
);
}
await
this
.
_webviewEditorService
.
resolveWebview
(
this
);
return
super
.
resolve
();
}
}
src/vs/workbench/contrib/webview/browser/webviewEditorService.ts
浏览文件 @
12e72de9
...
...
@@ -17,7 +17,7 @@ import { GroupIdentifier } from 'vs/workbench/common/editor';
import
{
IWebviewService
,
WebviewContentOptions
,
WebviewOptions
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
IEditorGroup
,
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
ACTIVE_GROUP_TYPE
,
IEditorService
,
SIDE_GROUP_TYPE
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
Revi
vedWebviewEditorInput
,
WebviewInput
}
from
'
./webviewEditorInput
'
;
import
{
LazilyResol
vedWebviewEditorInput
,
WebviewInput
}
from
'
./webviewEditorInput
'
;
export
const
IWebviewEditorService
=
createDecorator
<
IWebviewEditorService
>
(
'
webviewEditorService
'
);
...
...
@@ -190,7 +190,7 @@ export class WebviewEditorService implements IWebviewEditorService {
const
webview
=
this
.
createWebiew
(
id
,
extension
,
options
);
webview
.
state
=
state
;
const
webviewInput
=
new
RevivedWebviewEditorInput
(
id
,
viewType
,
title
,
(
webview
:
WebviewInput
)
=>
this
.
resolveWebview
(
webview
),
new
UnownedDisposable
(
webview
)
);
const
webviewInput
=
new
LazilyResolvedWebviewEditorInput
(
id
,
viewType
,
title
,
new
UnownedDisposable
(
webview
),
this
);
webviewInput
.
iconPath
=
iconPath
;
if
(
typeof
group
===
'
number
'
)
{
...
...
@@ -219,7 +219,7 @@ export class WebviewEditorService implements IWebviewEditorService {
// Revived webviews may not have an actively registered reviver but we still want to presist them
// since a reviver should exist when it is actually needed.
return
webview
instanceof
Revi
vedWebviewEditorInput
;
return
webview
instanceof
LazilyResol
vedWebviewEditorInput
;
}
private
async
tryRevive
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录