Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b8295c1a
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b8295c1a
编写于
3月 26, 2020
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Try restoring the dirty state of backedup custom editors
上级
81521ba3
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
29 addition
and
10 deletion
+29
-10
src/vs/workbench/api/browser/mainThreadWebview.ts
src/vs/workbench/api/browser/mainThreadWebview.ts
+15
-2
src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
...rkbench/contrib/customEditor/browser/customEditorInput.ts
+8
-2
src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts
.../contrib/customEditor/browser/customEditorInputFactory.ts
+5
-5
src/vs/workbench/contrib/customEditor/browser/customEditors.ts
...s/workbench/contrib/customEditor/browser/customEditors.ts
+1
-1
未找到文件。
src/vs/workbench/api/browser/mainThreadWebview.ts
浏览文件 @
b8295c1a
...
...
@@ -35,6 +35,7 @@ import { CustomTextEditorModel } from 'vs/workbench/contrib/customEditor/common/
import
{
WebviewExtensionDescription
,
WebviewIcons
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
WebviewInput
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorInput
'
;
import
{
ICreateWebViewShowOptions
,
IWebviewWorkbenchService
,
WebviewInputOptions
}
from
'
vs/workbench/contrib/webview/browser/webviewWorkbenchService
'
;
import
{
IBackupFileService
}
from
'
vs/workbench/services/backup/common/backup
'
;
import
{
IEditorGroup
,
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
'
;
...
...
@@ -581,6 +582,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
private
_currentEditIndex
:
number
=
-
1
;
private
_savePoint
:
number
=
-
1
;
private
readonly
_edits
:
Array
<
number
>
=
[];
private
_fromBackup
:
boolean
=
false
;
public
static
async
create
(
instantiationService
:
IInstantiationService
,
...
...
@@ -591,7 +593,9 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
cancellation
:
CancellationToken
,
)
{
const
{
editable
}
=
await
proxy
.
$createWebviewCustomEditorDocument
(
resource
,
viewType
,
cancellation
);
return
instantiationService
.
createInstance
(
MainThreadCustomEditorModel
,
proxy
,
viewType
,
resource
,
editable
,
getEditors
);
const
model
=
instantiationService
.
createInstance
(
MainThreadCustomEditorModel
,
proxy
,
viewType
,
resource
,
editable
,
getEditors
);
await
model
.
init
();
return
model
;
}
constructor
(
...
...
@@ -604,6 +608,7 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
@
ILabelService
private
readonly
_labelService
:
ILabelService
,
@
IFileService
private
readonly
_fileService
:
IFileService
,
@
IUndoRedoService
private
readonly
_undoService
:
IUndoRedoService
,
@
IBackupFileService
private
readonly
_backupFileService
:
IBackupFileService
,
)
{
super
();
...
...
@@ -616,6 +621,11 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
return
this
.
_editorResource
;
}
async
init
():
Promise
<
void
>
{
const
backup
=
await
this
.
_backupFileService
.
resolve
<
CustomDocumentBackupData
>
(
this
.
resource
);
this
.
_fromBackup
=
!!
backup
;
}
dispose
()
{
if
(
this
.
_editable
)
{
this
.
_undoService
.
removeElements
(
this
.
_editorResource
);
...
...
@@ -645,7 +655,10 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
}
public
isDirty
():
boolean
{
return
this
.
_edits
.
length
>
0
&&
this
.
_savePoint
!==
this
.
_currentEditIndex
;
if
(
this
.
_edits
.
length
>
0
)
{
return
this
.
_savePoint
!==
this
.
_currentEditIndex
;
}
return
this
.
_fromBackup
;
}
private
readonly
_onDidChangeDirty
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
...
...
src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
浏览文件 @
b8295c1a
...
...
@@ -27,6 +27,8 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
public
static
typeId
=
'
workbench.editors.webviewEditor
'
;
private
readonly
_editorResource
:
URI
;
private
readonly
_fromBackup
:
boolean
;
get
resource
()
{
return
this
.
_editorResource
;
}
private
_modelRef
?:
IReference
<
ICustomEditorModel
>
;
...
...
@@ -36,6 +38,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
viewType
:
string
,
id
:
string
,
webview
:
Lazy
<
WebviewOverlay
>
,
fromBackup
:
boolean
,
@
IWebviewService
webviewService
:
IWebviewService
,
@
IWebviewWorkbenchService
webviewWorkbenchService
:
IWebviewWorkbenchService
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
...
...
@@ -48,6 +51,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
)
{
super
(
id
,
viewType
,
''
,
webview
,
webviewService
,
webviewWorkbenchService
);
this
.
_editorResource
=
resource
;
this
.
_fromBackup
=
fromBackup
;
}
public
getTypeId
():
string
{
...
...
@@ -106,7 +110,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
public
isDirty
():
boolean
{
if
(
!
this
.
_modelRef
)
{
return
false
;
return
this
.
_fromBackup
;
}
return
this
.
_modelRef
.
object
.
isDirty
();
}
...
...
@@ -188,7 +192,9 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
newResource
,
this
.
viewType
,
this
.
id
,
new
Lazy
(()
=>
undefined
!
));
// this webview is replaced in the transfer call
new
Lazy
(()
=>
undefined
!
),
// this webview is replaced in the transfer call
this
.
_fromBackup
,
);
this
.
transfer
(
newEditor
);
newEditor
.
updateGroup
(
group
);
return
{
editor
:
newEditor
};
...
...
src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts
浏览文件 @
b8295c1a
...
...
@@ -78,7 +78,7 @@ export class CustomEditorInputFactory extends WebviewEditorInputFactory {
return
webview
;
});
const
customInput
=
this
.
_instantiationService
.
createInstance
(
CustomEditorInput
,
URI
.
from
((
data
as
any
).
editorResource
),
data
.
viewType
,
id
,
webview
);
const
customInput
=
this
.
_instantiationService
.
createInstance
(
CustomEditorInput
,
URI
.
from
((
data
as
any
).
editorResource
),
data
.
viewType
,
id
,
webview
,
false
);
if
(
typeof
data
.
group
===
'
number
'
)
{
customInput
.
updateGroup
(
data
.
group
);
}
...
...
@@ -90,12 +90,12 @@ export class CustomEditorInputFactory extends WebviewEditorInputFactory {
const
webviewService
=
accessor
.
get
<
IWebviewService
>
(
IWebviewService
);
const
backupFileService
=
accessor
.
get
<
IBackupFileService
>
(
IBackupFileService
);
const
backup
=
await
backupFileService
.
resolve
(
resource
);
if
(
!
backup
)
{
const
backup
=
await
backupFileService
.
resolve
<
CustomDocumentBackupData
>
(
resource
);
if
(
!
backup
?.
meta
)
{
throw
new
Error
(
`No backup found for custom editor:
${
resource
}
`
);
}
const
backupData
=
backup
.
meta
as
CustomDocumentBackupData
;
const
backupData
=
backup
.
meta
;
const
id
=
backupData
.
webview
.
id
;
const
webview
=
new
Lazy
(()
=>
{
...
...
@@ -112,7 +112,7 @@ export class CustomEditorInputFactory extends WebviewEditorInputFactory {
return
webview
;
});
const
editor
=
instantiationService
.
createInstance
(
CustomEditorInput
,
URI
.
revive
(
backupData
.
editorResource
),
backupData
.
viewType
,
id
,
webview
);
const
editor
=
instantiationService
.
createInstance
(
CustomEditorInput
,
URI
.
revive
(
backupData
.
editorResource
),
backupData
.
viewType
,
id
,
webview
,
true
);
editor
.
updateGroup
(
0
);
return
editor
;
});
...
...
src/vs/workbench/contrib/customEditor/browser/customEditors.ts
浏览文件 @
b8295c1a
...
...
@@ -269,7 +269,7 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
const
webview
=
new
Lazy
(()
=>
{
return
this
.
webviewService
.
createWebviewOverlay
(
id
,
{
customClasses
:
options
?.
customClasses
},
{});
});
const
input
=
this
.
instantiationService
.
createInstance
(
CustomEditorInput
,
resource
,
viewType
,
id
,
webview
);
const
input
=
this
.
instantiationService
.
createInstance
(
CustomEditorInput
,
resource
,
viewType
,
id
,
webview
,
false
);
if
(
typeof
group
!==
'
undefined
'
)
{
input
.
updateGroup
(
group
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录