Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
32465012
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,发现更多精彩内容 >>
提交
32465012
编写于
10月 16, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add fast path for vscode.TextEditor.setDecorations
上级
d4408e2b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
71 addition
and
6 deletion
+71
-6
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+21
-0
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+5
-0
src/vs/workbench/api/electron-browser/mainThreadEditor.ts
src/vs/workbench/api/electron-browser/mainThreadEditor.ts
+11
-0
src/vs/workbench/api/electron-browser/mainThreadEditors.ts
src/vs/workbench/api/electron-browser/mainThreadEditors.ts
+8
-0
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+1
-0
src/vs/workbench/api/node/extHostTextEditor.ts
src/vs/workbench/api/node/extHostTextEditor.ts
+23
-5
src/vs/workbench/api/node/extHostTypeConverters.ts
src/vs/workbench/api/node/extHostTypeConverters.ts
+1
-1
src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts
...bench/test/electron-browser/api/extHostTextEditor.test.ts
+1
-0
未找到文件。
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
32465012
...
...
@@ -30,6 +30,7 @@ import { ICursorPositionChangedEvent, ICursorSelectionChangedEvent } from 'vs/ed
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
VerticalRevealType
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
ModelDecorationOptions
}
from
'
vs/editor/common/model/textModelWithDecorations
'
;
let
EDITOR_ID
=
0
;
...
...
@@ -856,6 +857,26 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
this
.
_decorationTypeKeysToIds
[
decorationTypeKey
]
=
this
.
deltaDecorations
(
oldDecorationsIds
,
newModelDecorations
);
}
public
setDecorationsFast
(
decorationTypeKey
:
string
,
ranges
:
IRange
[]):
void
{
// remove decoration sub types that are no longer used, deregister decoration type if necessary
let
oldDecorationsSubTypes
=
this
.
_decorationTypeSubtypes
[
decorationTypeKey
]
||
{};
for
(
let
subType
in
oldDecorationsSubTypes
)
{
this
.
_removeDecorationType
(
decorationTypeKey
+
'
-
'
+
subType
);
}
this
.
_decorationTypeSubtypes
[
decorationTypeKey
]
=
{};
const
opts
=
ModelDecorationOptions
.
createDynamic
(
this
.
_resolveDecorationOptions
(
decorationTypeKey
,
false
));
let
newModelDecorations
:
editorCommon
.
IModelDeltaDecoration
[]
=
new
Array
<
editorCommon
.
IModelDeltaDecoration
>
(
ranges
.
length
);
for
(
let
i
=
0
,
len
=
ranges
.
length
;
i
<
len
;
i
++
)
{
newModelDecorations
[
i
]
=
{
range
:
ranges
[
i
],
options
:
opts
};
}
// update all decorations
let
oldDecorationsIds
=
this
.
_decorationTypeKeysToIds
[
decorationTypeKey
]
||
[];
this
.
_decorationTypeKeysToIds
[
decorationTypeKey
]
=
this
.
deltaDecorations
(
oldDecorationsIds
,
newModelDecorations
);
}
public
removeDecorations
(
decorationTypeKey
:
string
):
void
{
// remove decorations for type and sub type
let
oldDecorationsIds
=
this
.
_decorationTypeKeysToIds
[
decorationTypeKey
];
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
32465012
...
...
@@ -1984,6 +1984,11 @@ export interface ICommonCodeEditor extends IEditor {
*/
setDecorations
(
decorationTypeKey
:
string
,
ranges
:
IDecorationOptions
[]):
void
;
/**
* @internal
*/
setDecorationsFast
(
decorationTypeKey
:
string
,
ranges
:
IRange
[]):
void
;
/**
* @internal
*/
...
...
src/vs/workbench/api/electron-browser/mainThreadEditor.ts
浏览文件 @
32465012
...
...
@@ -244,6 +244,17 @@ export class MainThreadTextEditor {
this
.
_codeEditor
.
setDecorations
(
key
,
ranges
);
}
public
setDecorationsFast
(
key
:
string
,
_ranges
:
number
[]):
void
{
if
(
!
this
.
_codeEditor
)
{
return
;
}
let
ranges
:
Range
[]
=
[];
for
(
let
i
=
0
,
len
=
Math
.
floor
(
_ranges
.
length
/
4
);
i
<
len
;
i
++
)
{
ranges
[
i
]
=
new
Range
(
_ranges
[
4
*
i
],
_ranges
[
4
*
i
+
1
],
_ranges
[
4
*
i
+
2
],
_ranges
[
4
*
i
+
3
]);
}
this
.
_codeEditor
.
setDecorationsFast
(
key
,
ranges
);
}
public
revealRange
(
range
:
IRange
,
revealType
:
TextEditorRevealType
):
void
{
if
(
!
this
.
_codeEditor
)
{
return
;
...
...
src/vs/workbench/api/electron-browser/mainThreadEditors.ts
浏览文件 @
32465012
...
...
@@ -195,6 +195,14 @@ export class MainThreadEditors implements MainThreadEditorsShape {
return
TPromise
.
as
(
null
);
}
$trySetDecorationsFast
(
id
:
string
,
key
:
string
,
ranges
:
string
):
TPromise
<
any
>
{
if
(
!
this
.
_documentsAndEditors
.
getEditor
(
id
))
{
return
TPromise
.
wrapError
(
disposed
(
`TextEditor(
${
id
}
)`
));
}
this
.
_documentsAndEditors
.
getEditor
(
id
).
setDecorationsFast
(
key
,
/*TODO: marshaller is too slow*/
JSON
.
parse
(
ranges
));
return
TPromise
.
as
(
null
);
}
$tryRevealRange
(
id
:
string
,
range
:
IRange
,
revealType
:
TextEditorRevealType
):
TPromise
<
any
>
{
if
(
!
this
.
_documentsAndEditors
.
getEditor
(
id
))
{
return
TPromise
.
wrapError
(
disposed
(
`TextEditor(
${
id
}
)`
));
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
32465012
...
...
@@ -210,6 +210,7 @@ export interface MainThreadEditorsShape extends IDisposable {
$tryHideEditor
(
id
:
string
):
TPromise
<
void
>
;
$trySetOptions
(
id
:
string
,
options
:
ITextEditorConfigurationUpdate
):
TPromise
<
any
>
;
$trySetDecorations
(
id
:
string
,
key
:
string
,
ranges
:
editorCommon
.
IDecorationOptions
[]):
TPromise
<
any
>
;
$trySetDecorationsFast
(
id
:
string
,
key
:
string
,
ranges
:
string
):
TPromise
<
any
>
;
$tryRevealRange
(
id
:
string
,
range
:
IRange
,
revealType
:
TextEditorRevealType
):
TPromise
<
any
>
;
$trySetSelections
(
id
:
string
,
selections
:
ISelection
[]):
TPromise
<
any
>
;
$tryApplyEdits
(
id
:
string
,
modelVersionId
:
number
,
edits
:
editorCommon
.
ISingleEditOperation
[],
opts
:
IApplyEditsOptions
):
TPromise
<
boolean
>
;
...
...
src/vs/workbench/api/node/extHostTextEditor.ts
浏览文件 @
32465012
...
...
@@ -416,11 +416,29 @@ export class ExtHostTextEditor implements vscode.TextEditor {
setDecorations
(
decorationType
:
vscode
.
TextEditorDecorationType
,
ranges
:
Range
[]
|
vscode
.
DecorationOptions
[]):
void
{
this
.
_runOnProxy
(
()
=>
this
.
_proxy
.
$trySetDecorations
(
this
.
_id
,
decorationType
.
key
,
TypeConverters
.
fromRangeOrRangeWithMessage
(
ranges
)
)
()
=>
{
if
(
TypeConverters
.
isDecorationOptionsArr
(
ranges
))
{
return
this
.
_proxy
.
$trySetDecorations
(
this
.
_id
,
decorationType
.
key
,
TypeConverters
.
fromRangeOrRangeWithMessage
(
ranges
)
);
}
else
{
let
_ranges
:
number
[]
=
new
Array
<
number
>
(
4
*
ranges
.
length
);
for
(
let
i
=
0
,
len
=
ranges
.
length
;
i
<
len
;
i
++
)
{
const
range
=
ranges
[
i
];
_ranges
[
4
*
i
]
=
range
.
start
.
line
+
1
;
_ranges
[
4
*
i
+
1
]
=
range
.
start
.
character
+
1
;
_ranges
[
4
*
i
+
2
]
=
range
.
end
.
line
+
1
;
_ranges
[
4
*
i
+
3
]
=
range
.
end
.
character
+
1
;
}
return
this
.
_proxy
.
$trySetDecorationsFast
(
this
.
_id
,
decorationType
.
key
,
/*TODO: marshaller is too slow*/
JSON
.
stringify
(
_ranges
)
);
}
}
);
}
...
...
src/vs/workbench/api/node/extHostTypeConverters.ts
浏览文件 @
32465012
...
...
@@ -139,7 +139,7 @@ function isDecorationOptions(something: any): something is vscode.DecorationOpti
return
(
typeof
something
.
range
!==
'
undefined
'
);
}
function
isDecorationOptionsArr
(
something
:
vscode
.
Range
[]
|
vscode
.
DecorationOptions
[]):
something
is
vscode
.
DecorationOptions
[]
{
export
function
isDecorationOptionsArr
(
something
:
vscode
.
Range
[]
|
vscode
.
DecorationOptions
[]):
something
is
vscode
.
DecorationOptions
[]
{
if
(
something
.
length
===
0
)
{
return
true
;
}
...
...
src/vs/workbench/test/electron-browser/api/extHostTextEditor.test.ts
浏览文件 @
32465012
...
...
@@ -61,6 +61,7 @@ suite('ExtHostTextEditorOptions', () => {
$tryShowEditor
:
undefined
,
$tryHideEditor
:
undefined
,
$trySetDecorations
:
undefined
,
$trySetDecorationsFast
:
undefined
,
$tryRevealRange
:
undefined
,
$trySetSelections
:
undefined
,
$tryApplyEdits
:
undefined
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录