Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3a5f6213
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,体验更适合开发者的 AI 搜索 >>
提交
3a5f6213
编写于
3月 06, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
return of the 3mins rule, fixes #21709
上级
0106ab2e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
8 deletion
+62
-8
src/vs/workbench/api/node/mainThreadDocuments.ts
src/vs/workbench/api/node/mainThreadDocuments.ts
+62
-8
未找到文件。
src/vs/workbench/api/node/mainThreadDocuments.ts
浏览文件 @
3a5f6213
...
...
@@ -4,23 +4,71 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
toErrorMessage
}
from
'
vs/base/common/errorMessage
'
;
import
{
EmitterEvent
}
from
'
vs/base/common/eventEmitter
'
;
import
{
setDisposableTimeout
}
from
'
vs/base/common/async
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
,
IReference
}
from
'
vs/base/common/lifecycle
'
;
import
{
TextFileModelChangeEvent
,
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
ExtHostContext
,
MainThreadDocumentsShape
,
ExtHostDocumentsShape
}
from
'
./extHost.protocol
'
;
import
{
ITextModelResolverService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
ITextSource
}
from
'
vs/editor/common/model/textSource
'
;
import
{
MainThreadDocumentsAndEditors
}
from
'
./mainThreadDocumentsAndEditors
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ITextEditorModel
}
from
"
vs/workbench/common/editor
"
;
class
TimeoutReference
{
private
static
_delay
=
1000
*
60
*
3
;
private
_timer
:
IDisposable
;
private
_disposed
=
false
;
constructor
(
readonly
codeEditorService
:
ICodeEditorService
,
readonly
editorGroupService
:
IEditorGroupService
,
readonly
reference
:
IReference
<
ITextEditorModel
>
)
{
const
check
=
()
=>
{
if
(
!
this
.
isUsed
())
{
this
.
dispose
();
}
else
{
this
.
_timer
=
setDisposableTimeout
(
check
,
TimeoutReference
.
_delay
);
}
};
this
.
_timer
=
setDisposableTimeout
(
check
,
TimeoutReference
.
_delay
);
}
dispose
():
void
{
if
(
!
this
.
_disposed
)
{
this
.
_disposed
=
true
;
dispose
(
this
.
reference
,
this
.
_timer
);
}
}
private
isUsed
():
boolean
{
for
(
const
editor
of
this
.
codeEditorService
.
listCodeEditors
())
{
if
(
editor
.
getModel
()
===
this
.
reference
.
object
.
textEditorModel
)
{
return
true
;
}
}
for
(
const
group
of
this
.
editorGroupService
.
getStacksModel
().
groups
)
{
if
(
group
.
contains
(
this
.
reference
.
object
.
textEditorModel
.
uri
))
{
return
true
;
}
}
return
false
;
}
}
export
class
MainThreadDocuments
extends
MainThreadDocumentsShape
{
...
...
@@ -31,6 +79,8 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
private
_codeEditorService
:
ICodeEditorService
;
private
_fileService
:
IFileService
;
private
_untitledEditorService
:
IUntitledEditorService
;
private
_editorGroupService
:
IEditorGroupService
;
private
_toDispose
:
IDisposable
[];
private
_modelToDisposeMap
:
{
[
modelUrl
:
string
]:
IDisposable
;
};
private
_proxy
:
ExtHostDocumentsShape
;
...
...
@@ -46,7 +96,8 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
@
ICodeEditorService
codeEditorService
:
ICodeEditorService
,
@
IFileService
fileService
:
IFileService
,
@
ITextModelResolverService
textModelResolverService
:
ITextModelResolverService
,
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
@
IUntitledEditorService
untitledEditorService
:
IUntitledEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
)
{
super
();
this
.
_modelService
=
modelService
;
...
...
@@ -56,6 +107,8 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
this
.
_codeEditorService
=
codeEditorService
;
this
.
_fileService
=
fileService
;
this
.
_untitledEditorService
=
untitledEditorService
;
this
.
_editorGroupService
=
editorGroupService
;
this
.
_proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostDocuments
);
this
.
_modelIsSynced
=
{};
...
...
@@ -181,11 +234,12 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
private
_handleAsResourceInput
(
uri
:
URI
):
TPromise
<
boolean
>
{
return
this
.
_textModelResolverService
.
createModelReference
(
uri
).
then
(
ref
=>
{
// TimeoutReference will check every 3 min if the
// reference is still in use. This is quite harsh to
// extensions but we don't want them to make us hold
// on to model indefinitely
this
.
_toDispose
.
push
(
new
TimeoutReference
(
this
.
_codeEditorService
,
this
.
_editorGroupService
,
ref
));
const
result
=
!!
ref
.
object
;
// TODO@Joao TODO@Joh when should this model reference be disposed?
// ref.dispose();
return
result
;
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录