Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
38443b43
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,发现更多精彩内容 >>
提交
38443b43
编写于
3月 08, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use a bulk model content changed listener in the cursor (#21434)
上级
29a859d4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
42 deletion
+68
-42
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+38
-38
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+30
-4
未找到文件。
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
38443b43
...
...
@@ -769,6 +769,44 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
},
};
this
.
listenersToRemove
.
push
(
this
.
model
.
addBulkListener
((
events
)
=>
{
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
let
eventType
=
events
[
i
].
getType
();
let
e
=
events
[
i
].
getData
();
switch
(
eventType
)
{
case
editorCommon
.
EventType
.
ModelDecorationsChanged
:
this
.
emit
(
editorCommon
.
EventType
.
ModelDecorationsChanged
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelLanguageChanged
:
this
.
domElement
.
setAttribute
(
'
data-mode-id
'
,
this
.
model
.
getLanguageIdentifier
().
language
);
this
.
emit
(
editorCommon
.
EventType
.
ModelLanguageChanged
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelRawContentChanged
:
this
.
emit
(
editorCommon
.
EventType
.
ModelRawContentChanged
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelContentChanged2
:
this
.
emit
(
editorCommon
.
EventType
.
ModelContentChanged2
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelOptionsChanged
:
this
.
emit
(
editorCommon
.
EventType
.
ModelOptionsChanged
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelDispose
:
// Someone might destroy the model from under the editor, so prevent any exceptions by setting a null model
this
.
setModel
(
null
);
break
;
default
:
// console.warn("Unhandled model event: ", e);
}
}
}));
this
.
cursor
=
new
Cursor
(
this
.
_configuration
,
this
.
model
,
...
...
@@ -842,44 +880,6 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
}
}));
this
.
listenersToRemove
.
push
(
this
.
model
.
addBulkListener
((
events
)
=>
{
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
let
eventType
=
events
[
i
].
getType
();
let
e
=
events
[
i
].
getData
();
switch
(
eventType
)
{
case
editorCommon
.
EventType
.
ModelDecorationsChanged
:
this
.
emit
(
editorCommon
.
EventType
.
ModelDecorationsChanged
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelLanguageChanged
:
this
.
domElement
.
setAttribute
(
'
data-mode-id
'
,
this
.
model
.
getLanguageIdentifier
().
language
);
this
.
emit
(
editorCommon
.
EventType
.
ModelLanguageChanged
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelRawContentChanged
:
this
.
emit
(
editorCommon
.
EventType
.
ModelRawContentChanged
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelContentChanged2
:
this
.
emit
(
editorCommon
.
EventType
.
ModelContentChanged2
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelOptionsChanged
:
this
.
emit
(
editorCommon
.
EventType
.
ModelOptionsChanged
,
e
);
break
;
case
editorCommon
.
EventType
.
ModelDispose
:
// Someone might destroy the model from under the editor, so prevent any exceptions by setting a null model
this
.
setModel
(
null
);
break
;
default
:
// console.warn("Unhandled model event: ", e);
}
}
}));
this
.
listenersToRemove
.
push
(
this
.
cursor
.
addBulkListener2
((
events
)
=>
{
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
let
eventType
=
events
[
i
].
getType
();
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
38443b43
...
...
@@ -103,8 +103,34 @@ export class Cursor extends EventEmitter {
this
.
_isHandling
=
false
;
this
.
modelUnbinds
=
[];
this
.
modelUnbinds
.
push
(
this
.
model
.
onDidChangeRawContent
((
e
)
=>
{
this
.
_onModelContentChanged
(
e
);
this
.
modelUnbinds
.
push
(
this
.
model
.
addBulkListener
((
events
)
=>
{
if
(
this
.
_isHandling
)
{
return
;
}
let
hadContentChange
=
false
;
let
hadFlushEvent
=
false
;
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
const
event
=
events
[
i
];
const
eventType
=
event
.
getType
();
if
(
eventType
===
editorCommon
.
EventType
.
ModelRawContentChanged
)
{
hadContentChange
=
true
;
const
changeEvent
=
<
editorCommon
.
IModelContentChangedEvent
>
event
.
getData
();
if
(
changeEvent
.
changeType
===
editorCommon
.
EventType
.
ModelRawContentChangedFlush
)
{
hadFlushEvent
=
true
;
break
;
}
}
}
if
(
!
hadContentChange
)
{
return
;
}
this
.
_onModelContentChanged
(
hadFlushEvent
);
}));
this
.
modelUnbinds
.
push
(
this
.
model
.
onDidChangeLanguage
((
e
)
=>
{
this
.
_onModelLanguageChanged
();
...
...
@@ -200,8 +226,8 @@ export class Cursor extends EventEmitter {
this
.
cursors
.
updateMode
();
}
private
_onModelContentChanged
(
e
:
editorCommon
.
IModelContentChangedEvent
):
void
{
if
(
e
.
changeType
===
editorCommon
.
EventType
.
ModelRawContentChangedFlush
)
{
private
_onModelContentChanged
(
hadFlushEvent
:
boolean
):
void
{
if
(
hadFlushEvent
)
{
// a model.setValue() was called
this
.
cursors
.
dispose
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录