Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7e71822a
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,发现更多精彩内容 >>
提交
7e71822a
编写于
11月 12, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Hook up CustomEditorModel to workingCopyService
上级
0fcc0aa8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
7 deletion
+31
-7
src/vs/workbench/api/browser/mainThreadWebview.ts
src/vs/workbench/api/browser/mainThreadWebview.ts
+4
-2
src/vs/workbench/contrib/customEditor/browser/customEditorModel.ts
...rkbench/contrib/customEditor/browser/customEditorModel.ts
+27
-5
未找到文件。
src/vs/workbench/api/browser/mainThreadWebview.ts
浏览文件 @
7e71822a
...
...
@@ -12,6 +12,7 @@ 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
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IProductService
}
from
'
vs/platform/product/common/productService
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
...
...
@@ -20,6 +21,7 @@ import { editorGroupToViewColumn, EditorViewColumn, viewColumnToEditorGroup } fr
import
{
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
CustomFileEditorInput
}
from
'
vs/workbench/contrib/customEditor/browser/customEditorInput
'
;
import
{
CustomEditorModel
}
from
'
vs/workbench/contrib/customEditor/browser/customEditorModel
'
;
import
{
WebviewExtensionDescription
}
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
'
;
...
...
@@ -27,7 +29,6 @@ import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
extHostNamedCustomer
}
from
'
../common/extHostCustomers
'
;
import
{
CustomEditorModel
}
from
'
vs/workbench/contrib/customEditor/browser/customEditorModel
'
;
/**
* Bi-directional map between webview handles and inputs.
...
...
@@ -102,6 +103,7 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
@
IExtensionService
extensionService
:
IExtensionService
,
@
IEditorGroupsService
private
readonly
_editorGroupService
:
IEditorGroupsService
,
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
@
IOpenerService
private
readonly
_openerService
:
IOpenerService
,
@
IProductService
private
readonly
_productService
:
IProductService
,
@
ITelemetryService
private
readonly
_telemetryService
:
ITelemetryService
,
...
...
@@ -271,7 +273,7 @@ export class MainThreadWebviews extends Disposable implements extHostProtocol.Ma
webviewInput
.
webview
.
options
=
options
;
webviewInput
.
webview
.
extension
=
extension
;
const
model
=
new
CustomEditorModel
(
);
const
model
=
this
.
_instantiationService
.
createInstance
(
CustomEditorModel
,
webviewInput
.
getResource
()
);
webviewInput
.
setModel
(
model
);
this
.
_models
.
set
(
handle
,
model
);
...
...
src/vs/workbench/contrib/customEditor/browser/customEditorModel.ts
浏览文件 @
7e71822a
...
...
@@ -5,18 +5,44 @@
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IWorkingCopy
,
IWorkingCopyService
,
WorkingCopyCapabilities
}
from
'
vs/workbench/services/workingCopy/common/workingCopyService
'
;
type
Edit
=
string
;
export
class
CustomEditorModel
extends
Disposable
{
export
class
CustomEditorModel
extends
Disposable
implements
IWorkingCopy
{
private
_currentEditIndex
:
number
=
0
;
private
_savePoint
:
number
=
-
1
;
private
_edits
:
Array
<
Edit
>
=
[];
constructor
(
private
readonly
_resource
:
URI
,
@
IWorkingCopyService
private
readonly
_workingCopyService
:
IWorkingCopyService
,
)
{
super
();
this
.
_register
(
this
.
_workingCopyService
.
registerWorkingCopy
(
this
));
}
//#region IWorkingCopy
public
get
resource
()
{
return
this
.
_resource
;
}
public
get
capabilities
():
WorkingCopyCapabilities
{
return
0
;
}
public
isDirty
():
boolean
{
return
this
.
_edits
.
length
>
0
&&
this
.
_savePoint
!==
this
.
_edits
.
length
;
}
protected
readonly
_onDidChangeDirty
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChangeDirty
:
Event
<
void
>
=
this
.
_onDidChangeDirty
.
event
;
//#endregion
protected
readonly
_onUndo
:
Emitter
<
Edit
>
=
this
.
_register
(
new
Emitter
<
Edit
>
());
readonly
onUndo
:
Event
<
Edit
>
=
this
.
_onUndo
.
event
;
...
...
@@ -26,10 +52,6 @@ export class CustomEditorModel extends Disposable {
this
.
updateDirty
();
}
public
isDirty
():
boolean
{
return
this
.
_edits
.
length
>
0
&&
this
.
_savePoint
!==
this
.
_edits
.
length
;
}
private
updateDirty
()
{
this
.
_onDidChangeDirty
.
fire
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录