Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
97b23735
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,发现更多精彩内容 >>
提交
97b23735
编写于
12月 05, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small perf tweaks
上级
dab5c352
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
40 deletion
+52
-40
src/vs/editor/common/model/textModelWithDecorations.ts
src/vs/editor/common/model/textModelWithDecorations.ts
+37
-35
src/vs/platform/extensions/common/abstractExtensionService.ts
...vs/platform/extensions/common/abstractExtensionService.ts
+15
-5
未找到文件。
src/vs/editor/common/model/textModelWithDecorations.ts
浏览文件 @
97b23735
...
...
@@ -79,8 +79,24 @@ export class InternalDecoration implements editorCommon.IModelDecoration {
);
}
public
setRange
(
range
:
Range
):
void
{
public
setRange
(
multiLineDecorationsMap
:
{
[
key
:
string
]:
InternalDecoration
;
},
range
:
Range
):
void
{
if
(
this
.
range
.
equalsRange
(
range
))
{
return
;
}
let
rangeWasMultiLine
=
(
this
.
range
.
startLineNumber
!==
this
.
range
.
endLineNumber
);
this
.
range
=
range
;
let
rangeIsMultiline
=
(
this
.
range
.
startLineNumber
!==
this
.
range
.
endLineNumber
);
if
(
rangeWasMultiLine
===
rangeIsMultiline
)
{
return
;
}
if
(
rangeIsMultiline
)
{
multiLineDecorationsMap
[
this
.
id
]
=
this
;
}
else
{
delete
multiLineDecorationsMap
[
this
.
id
];
}
}
}
...
...
@@ -124,15 +140,6 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
this
.
_multiLineDecorationsMap
=
Object
.
create
(
null
);
}
private
_setDecorationIsMultiLine
(
decoration
:
InternalDecoration
,
isMultiLine
:
boolean
):
void
{
let
rangeWasMultiLine
=
this
.
_multiLineDecorationsMap
[
decoration
.
id
];
if
(
!
rangeWasMultiLine
&&
isMultiLine
)
{
this
.
_multiLineDecorationsMap
[
decoration
.
id
]
=
decoration
;
}
else
if
(
rangeWasMultiLine
&&
!
isMultiLine
)
{
delete
this
.
_multiLineDecorationsMap
[
decoration
.
id
];
}
}
private
static
_shouldStartMarkerSticksToPreviousCharacter
(
stickiness
:
editorCommon
.
TrackedRangeStickiness
):
boolean
{
if
(
stickiness
===
editorCommon
.
TrackedRangeStickiness
.
AlwaysGrowsWhenTypingAtEdges
||
stickiness
===
editorCommon
.
TrackedRangeStickiness
.
GrowsOnlyWhenTypingBefore
)
{
return
true
;
...
...
@@ -443,14 +450,8 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
let
startMarker
=
decoration
.
startMarker
.
position
;
let
endMarker
=
decoration
.
endMarker
.
position
;
this
.
_setDecorationIsMultiLine
(
decoration
,
(
startMarker
.
lineNumber
!==
endMarker
.
lineNumber
)
);
let
range
=
TextModelWithDecorations
.
_createRangeFromMarkers
(
startMarker
,
endMarker
);
decoration
.
setRange
(
range
);
decoration
.
setRange
(
this
.
_multiLineDecorationsMap
,
range
);
uniqueChangedDecorations
[
uniqueChangedDecorationsLen
++
]
=
decorationId
;
}
...
...
@@ -545,8 +546,9 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
let
decoration
=
new
InternalDecoration
(
decorationId
,
ownerId
,
range
,
markers
[
0
],
markers
[
1
],
options
);
this
.
_decorations
[
decorationId
]
=
decoration
;
this
.
_setDecorationIsMultiLine
(
decoration
,
(
range
.
startLineNumber
!==
range
.
endLineNumber
));
if
(
range
.
startLineNumber
!==
range
.
endLineNumber
)
{
this
.
_multiLineDecorationsMap
[
decorationId
]
=
decoration
;
}
decorationsTracker
.
addNewDecoration
(
decorationId
);
...
...
@@ -590,8 +592,9 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
let
decoration
=
new
InternalDecoration
(
decorationId
,
ownerId
,
range
,
startMarkerId
,
endMarkerId
,
newDecoration
.
options
);
this
.
_decorations
[
decorationId
]
=
decoration
;
this
.
_setDecorationIsMultiLine
(
decoration
,
(
range
.
startLineNumber
!==
range
.
endLineNumber
));
if
(
range
.
startLineNumber
!==
range
.
endLineNumber
)
{
this
.
_multiLineDecorationsMap
[
decorationId
]
=
decoration
;
}
decorationsTracker
.
addNewDecoration
(
decorationId
);
}
...
...
@@ -621,8 +624,7 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
}
endMarker
.
setPosition
(
new
Position
(
newRange
.
endLineNumber
,
newRange
.
endColumn
));
this
.
_setDecorationIsMultiLine
(
decoration
,
(
newRange
.
startLineNumber
!==
newRange
.
endLineNumber
));
decoration
.
setRange
(
newRange
);
decoration
.
setRange
(
this
.
_multiLineDecorationsMap
,
newRange
);
decorationsTracker
.
addMovedDecoration
(
decorationId
);
}
...
...
@@ -643,40 +645,40 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
decorationsTracker
.
addUpdatedDecoration
(
decorationId
);
}
private
_removeDecorationImpl
(
decorationsTracker
:
DecorationsTracker
,
i
d
:
string
):
void
{
let
decoration
=
this
.
_decorations
[
i
d
];
private
_removeDecorationImpl
(
decorationsTracker
:
DecorationsTracker
,
decorationI
d
:
string
):
void
{
let
decoration
=
this
.
_decorations
[
decorationI
d
];
if
(
!
decoration
)
{
return
;
}
this
.
_removeMarkers
([
decoration
.
startMarker
,
decoration
.
endMarker
]);
this
.
_setDecorationIsMultiLine
(
decoration
,
false
)
;
delete
this
.
_decorations
[
i
d
];
delete
this
.
_multiLineDecorationsMap
[
decorationId
]
;
delete
this
.
_decorations
[
decorationI
d
];
if
(
decorationsTracker
)
{
decorationsTracker
.
addRemovedDecoration
(
i
d
);
decorationsTracker
.
addRemovedDecoration
(
decorationI
d
);
}
}
private
_removeDecorationsImpl
(
decorationsTracker
:
DecorationsTracker
,
i
ds
:
string
[]):
void
{
private
_removeDecorationsImpl
(
decorationsTracker
:
DecorationsTracker
,
decorationI
ds
:
string
[]):
void
{
let
removeMarkers
:
LineMarker
[]
=
[],
removeMarkersLen
=
0
;
for
(
let
i
=
0
,
len
=
i
ds
.
length
;
i
<
len
;
i
++
)
{
let
id
=
i
ds
[
i
];
let
decoration
=
this
.
_decorations
[
i
d
];
for
(
let
i
=
0
,
len
=
decorationI
ds
.
length
;
i
<
len
;
i
++
)
{
let
decorationId
=
decorationI
ds
[
i
];
let
decoration
=
this
.
_decorations
[
decorationI
d
];
if
(
!
decoration
)
{
continue
;
}
if
(
decorationsTracker
)
{
decorationsTracker
.
addRemovedDecoration
(
i
d
);
decorationsTracker
.
addRemovedDecoration
(
decorationI
d
);
}
removeMarkers
[
removeMarkersLen
++
]
=
decoration
.
startMarker
;
removeMarkers
[
removeMarkersLen
++
]
=
decoration
.
endMarker
;
this
.
_setDecorationIsMultiLine
(
decoration
,
false
)
;
delete
this
.
_decorations
[
i
d
];
delete
this
.
_multiLineDecorationsMap
[
decorationId
]
;
delete
this
.
_decorations
[
decorationI
d
];
}
if
(
removeMarkers
.
length
>
0
)
{
...
...
src/vs/platform/extensions/common/abstractExtensionService.ts
浏览文件 @
97b23735
...
...
@@ -35,13 +35,16 @@ export abstract class AbstractExtensionService<T extends ActivatedExtension> imp
protected
_activatedExtensions
:
IActivatedExtensionMap
<
T
>
;
private
_onReady
:
TPromise
<
boolean
>
;
private
_onReadyC
:
(
v
:
boolean
)
=>
void
;
private
_isReady
:
boolean
;
protected
_registry
:
ExtensionDescriptionRegistry
;
constructor
(
isReadyByDefault
:
boolean
)
{
if
(
isReadyByDefault
)
{
this
.
_isReady
=
true
;
this
.
_onReady
=
TPromise
.
as
(
true
);
this
.
_onReadyC
=
(
v
:
boolean
)
=>
{
/*no-op*/
};
}
else
{
this
.
_isReady
=
false
;
this
.
_onReady
=
new
TPromise
<
boolean
>
((
c
,
e
,
p
)
=>
{
this
.
_onReadyC
=
c
;
},
()
=>
{
...
...
@@ -54,6 +57,7 @@ export abstract class AbstractExtensionService<T extends ActivatedExtension> imp
}
protected
_triggerOnReady
():
void
{
this
.
_isReady
=
true
;
this
.
_onReadyC
(
true
);
}
...
...
@@ -93,11 +97,17 @@ export abstract class AbstractExtensionService<T extends ActivatedExtension> imp
}
public
activateByEvent
(
activationEvent
:
string
):
TPromise
<
void
>
{
return
this
.
_onReady
.
then
(()
=>
{
onWillActivate
.
fire
(
activationEvent
);
let
activateExtensions
=
this
.
_registry
.
getExtensionDescriptionsForActivationEvent
(
activationEvent
);
return
this
.
_activateExtensions
(
activateExtensions
,
0
);
});
if
(
this
.
_isReady
)
{
return
this
.
_activateByEvent
(
activationEvent
);
}
else
{
return
this
.
_onReady
.
then
(()
=>
this
.
_activateByEvent
(
activationEvent
));
}
}
private
_activateByEvent
(
activationEvent
:
string
):
TPromise
<
void
>
{
onWillActivate
.
fire
(
activationEvent
);
let
activateExtensions
=
this
.
_registry
.
getExtensionDescriptionsForActivationEvent
(
activationEvent
);
return
this
.
_activateExtensions
(
activateExtensions
,
0
);
}
public
activateById
(
extensionId
:
string
):
TPromise
<
void
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录