Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a47159ba
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,发现更多精彩内容 >>
提交
a47159ba
编写于
10月 12, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Eliminate IModelDecorationsChangedEvent.changedDecorations
上级
6023aee9
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
22 addition
and
53 deletion
+22
-53
src/vs/editor/common/model/textModelEvents.ts
src/vs/editor/common/model/textModelEvents.ts
+0
-4
src/vs/editor/common/model/textModelWithDecorations.ts
src/vs/editor/common/model/textModelWithDecorations.ts
+15
-28
src/vs/editor/common/viewModel/viewModelDecorations.ts
src/vs/editor/common/viewModel/viewModelDecorations.ts
+1
-2
src/vs/editor/common/viewModel/viewModelImpl.ts
src/vs/editor/common/viewModel/viewModelImpl.ts
+1
-2
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
...ditor/contrib/referenceSearch/browser/referencesWidget.ts
+2
-3
src/vs/editor/test/common/model/modelDecorations.test.ts
src/vs/editor/test/common/model/modelDecorations.test.ts
+1
-7
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+0
-4
src/vs/workbench/parts/debug/browser/debugEditorModelManager.ts
.../workbench/parts/debug/browser/debugEditorModelManager.ts
+2
-3
未找到文件。
src/vs/editor/common/model/textModelEvents.ts
浏览文件 @
a47159ba
...
...
@@ -88,10 +88,6 @@ export interface IModelContentChangedEvent {
* An event describing that model decorations have changed.
*/
export
interface
IModelDecorationsChangedEvent
{
/**
* Lists of ids for changed decorations.
*/
readonly
changedDecorations
:
string
[];
}
/**
...
...
src/vs/editor/common/model/textModelWithDecorations.ts
浏览文件 @
a47159ba
...
...
@@ -28,15 +28,12 @@ class DecorationsTracker {
public
didAddDecorations
:
boolean
;
public
didRemoveDecorations
:
boolean
;
public
changedDecorations
:
string
[];
public
changedDecorationsLen
:
number
;
public
didChangeDecorations
:
boolean
;
constructor
()
{
this
.
didAddDecorations
=
false
;
this
.
didRemoveDecorations
=
false
;
this
.
changedDecorations
=
[];
this
.
changedDecorationsLen
=
0
;
this
.
didChangeDecorations
=
false
;
}
// --- Build decoration events
...
...
@@ -49,12 +46,8 @@ class DecorationsTracker {
this
.
didRemoveDecorations
=
true
;
}
public
addMovedDecoration
(
id
:
string
):
void
{
this
.
changedDecorations
[
this
.
changedDecorationsLen
++
]
=
id
;
}
public
addUpdatedDecoration
(
id
:
string
):
void
{
this
.
changedDecorations
[
this
.
changedDecorationsLen
++
]
=
id
;
public
markDidChangeDecorations
():
void
{
this
.
didChangeDecorations
=
true
;
}
}
...
...
@@ -456,7 +449,7 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
}
/**
* Handle changed markers (i.e. update decorations ranges
and return the changed decorations, unique and sorted by id
)
* Handle changed markers (i.e. update decorations ranges)
*/
private
_handleTrackedMarkers
(
markersTracker
:
MarkersTracker
):
void
{
let
changedInternalDecorationIds
=
markersTracker
.
getDecorationIds
();
...
...
@@ -466,8 +459,8 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
changedInternalDecorationIds
.
sort
();
let
uniqueChangedDecorations
:
string
[]
=
[],
uniqueChangedDecorationsLen
=
0
;
let
previousInternalDecorationId
:
number
=
0
;
let
somethingChanged
=
false
;
for
(
let
i
=
0
,
len
=
changedInternalDecorationIds
.
length
;
i
<
len
;
i
++
)
{
let
internalDecorationId
=
changedInternalDecorationIds
[
i
];
if
(
internalDecorationId
===
previousInternalDecorationId
)
{
...
...
@@ -485,15 +478,11 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
let
endMarker
=
decoration
.
endMarker
.
position
;
let
range
=
TextModelWithDecorations
.
_createRangeFromMarkers
(
startMarker
,
endMarker
);
decoration
.
setRange
(
this
.
_multiLineDecorationsMap
,
range
);
uniqueChangedDecorations
[
uniqueChangedDecorationsLen
++
]
=
decoration
.
id
;
somethingChanged
=
true
;
}
if
(
uniqueChangedDecorations
.
length
>
0
)
{
let
e
:
textModelEvents
.
IModelDecorationsChangedEvent
=
{
changedDecorations
:
uniqueChangedDecorations
};
this
.
emitModelDecorationsChangedEvent
(
e
);
if
(
somethingChanged
)
{
this
.
emitModelDecorationsChangedEvent
();
}
}
...
...
@@ -528,20 +517,18 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
private
_handleTrackedDecorations
(
decorationsTracker
:
DecorationsTracker
):
void
{
if
(
!
decorationsTracker
.
didAddDecorations
&&
decorationsTracker
.
changedDecorationsLen
===
0
&&
!
decorationsTracker
.
didChangeDecorations
&&
!
decorationsTracker
.
didRemoveDecorations
)
{
return
;
}
let
e
:
textModelEvents
.
IModelDecorationsChangedEvent
=
{
changedDecorations
:
decorationsTracker
.
changedDecorations
};
this
.
emitModelDecorationsChangedEvent
(
e
);
this
.
emitModelDecorationsChangedEvent
();
}
private
emitModelDecorationsChangedEvent
(
e
:
textModelEvents
.
IModelDecorationsChangedEvent
):
void
{
private
emitModelDecorationsChangedEvent
():
void
{
if
(
!
this
.
_isDisposing
)
{
let
e
:
textModelEvents
.
IModelDecorationsChangedEvent
=
{};
this
.
_eventEmitter
.
emit
(
textModelEvents
.
TextModelEventType
.
ModelDecorationsChanged
,
e
);
}
}
...
...
@@ -666,7 +653,7 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
decoration
.
setRange
(
this
.
_multiLineDecorationsMap
,
newRange
);
decorationsTracker
.
addMovedDecoration
(
decorationId
);
decorationsTracker
.
markDidChangeDecorations
(
);
}
private
_changeDecorationOptionsImpl
(
decorationsTracker
:
DecorationsTracker
,
decorationId
:
string
,
options
:
ModelDecorationOptions
):
void
{
...
...
@@ -682,7 +669,7 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
decoration
.
setOptions
(
options
);
decorationsTracker
.
addUpdatedDecoration
(
decorationId
);
decorationsTracker
.
markDidChangeDecorations
(
);
}
private
_removeDecorationImpl
(
decorationsTracker
:
DecorationsTracker
,
decorationId
:
string
):
void
{
...
...
src/vs/editor/common/viewModel/viewModelDecorations.ts
浏览文件 @
a47159ba
...
...
@@ -9,7 +9,6 @@ import { Range } from 'vs/editor/common/core/range';
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
InlineDecoration
,
ViewModelDecoration
,
ICoordinatesConverter
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
IModelDecorationsChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
export
interface
IDecorationsViewportData
{
/**
...
...
@@ -58,7 +57,7 @@ export class ViewModelDecorations implements IDisposable {
this
.
_clearCachedModelDecorationsResolver
();
}
public
onModelDecorationsChanged
(
e
:
IModelDecorationsChangedEvent
):
void
{
public
onModelDecorationsChanged
():
void
{
this
.
_decorationsCache
=
Object
.
create
(
null
);
this
.
_clearCachedModelDecorationsResolver
();
}
...
...
src/vs/editor/common/viewModel/viewModelImpl.ts
浏览文件 @
a47159ba
...
...
@@ -282,8 +282,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
break
;
}
case
textModelEvents
.
TextModelEventType
.
ModelDecorationsChanged
:
{
const
e
=
<
textModelEvents
.
IModelDecorationsChangedEvent
>
data
;
this
.
decorations
.
onModelDecorationsChanged
(
e
);
this
.
decorations
.
onModelDecorationsChanged
();
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
());
break
;
}
...
...
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
浏览文件 @
a47159ba
...
...
@@ -38,7 +38,6 @@ import { ITextModelService, ITextEditorModel } from 'vs/editor/common/services/r
import
{
registerColor
,
activeContrastBorder
,
contrastBorder
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
registerThemingParticipant
,
ITheme
,
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
attachListStyler
,
attachBadgeStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
IModelDecorationsChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ModelDecorationOptions
}
from
'
vs/editor/common/model/textModelWithDecorations
'
;
...
...
@@ -81,7 +80,7 @@ class DecorationsManager implements IDisposable {
}
private
_addDecorations
(
reference
:
FileReferences
):
void
{
this
.
_callOnModelChange
.
push
(
this
.
_editor
.
getModel
().
onDidChangeDecorations
((
event
)
=>
this
.
_onDecorationChanged
(
event
)));
this
.
_callOnModelChange
.
push
(
this
.
_editor
.
getModel
().
onDidChangeDecorations
((
event
)
=>
this
.
_onDecorationChanged
()));
this
.
_editor
.
changeDecorations
(
accessor
=>
{
...
...
@@ -107,7 +106,7 @@ class DecorationsManager implements IDisposable {
});
}
private
_onDecorationChanged
(
event
:
IModelDecorationsChangedEvent
):
void
{
private
_onDecorationChanged
():
void
{
const
toRemove
:
string
[]
=
[];
this
.
_decorations
.
forEach
((
reference
,
decorationId
)
=>
{
...
...
src/vs/editor/test/common/model/modelDecorations.test.ts
浏览文件 @
a47159ba
...
...
@@ -207,7 +207,6 @@ suite('Editor Model - Model Decorations', () => {
let
listenerCalled
=
0
;
thisModel
.
onDidChangeDecorations
((
e
)
=>
{
listenerCalled
++
;
assert
.
equal
(
e
.
changedDecorations
.
length
,
0
);
});
addDecoration
(
thisModel
,
1
,
2
,
3
,
2
,
'
myType
'
);
assert
.
equal
(
listenerCalled
,
1
,
'
listener called
'
);
...
...
@@ -218,8 +217,6 @@ suite('Editor Model - Model Decorations', () => {
let
decId
=
addDecoration
(
thisModel
,
1
,
2
,
3
,
2
,
'
myType
'
);
thisModel
.
onDidChangeDecorations
((
e
)
=>
{
listenerCalled
++
;
assert
.
equal
(
e
.
changedDecorations
.
length
,
1
);
assert
.
equal
(
e
.
changedDecorations
[
0
],
decId
);
});
thisModel
.
changeDecorations
((
changeAccessor
)
=>
{
changeAccessor
.
changeDecoration
(
decId
,
new
Range
(
1
,
1
,
1
,
2
));
...
...
@@ -232,7 +229,6 @@ suite('Editor Model - Model Decorations', () => {
let
decId
=
addDecoration
(
thisModel
,
1
,
2
,
3
,
2
,
'
myType
'
);
thisModel
.
onDidChangeDecorations
((
e
)
=>
{
listenerCalled
++
;
assert
.
equal
(
e
.
changedDecorations
.
length
,
0
);
});
thisModel
.
changeDecorations
((
changeAccessor
)
=>
{
changeAccessor
.
removeDecoration
(
decId
);
...
...
@@ -242,12 +238,10 @@ suite('Editor Model - Model Decorations', () => {
test
(
'
decorations emit event when inserting one line text before it
'
,
()
=>
{
let
listenerCalled
=
0
;
let
decId
=
addDecoration
(
thisModel
,
1
,
2
,
3
,
2
,
'
myType
'
);
addDecoration
(
thisModel
,
1
,
2
,
3
,
2
,
'
myType
'
);
thisModel
.
onDidChangeDecorations
((
e
)
=>
{
listenerCalled
++
;
assert
.
equal
(
e
.
changedDecorations
.
length
,
1
);
assert
.
equal
(
e
.
changedDecorations
[
0
],
decId
);
});
thisModel
.
applyEdits
([
EditOperation
.
insert
(
new
Position
(
1
,
1
),
'
Hallo
'
)]);
...
...
src/vs/monaco.d.ts
浏览文件 @
a47159ba
...
...
@@ -2482,10 +2482,6 @@ declare module monaco.editor {
* An event describing that model decorations have changed.
*/
export
interface
IModelDecorationsChangedEvent
{
/**
* Lists of ids for changed decorations.
*/
readonly
changedDecorations
:
string
[];
}
/**
...
...
src/vs/workbench/parts/debug/browser/debugEditorModelManager.ts
浏览文件 @
a47159ba
...
...
@@ -13,7 +13,6 @@ import { IModel, TrackedRangeStickiness, IModelDeltaDecoration, IModelDecoration
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IDebugService
,
IBreakpoint
,
IRawBreakpoint
,
State
}
from
'
vs/workbench/parts/debug/common/debug
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModelDecorationsChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
MarkdownString
}
from
'
vs/base/common/htmlContent
'
;
interface
IDebugEditorModelData
{
...
...
@@ -84,7 +83,7 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
const
desiredDecorations
=
this
.
createBreakpointDecorations
(
model
,
breakpoints
);
const
breakPointDecorations
=
model
.
deltaDecorations
([],
desiredDecorations
);
const
toDispose
:
lifecycle
.
IDisposable
[]
=
[
model
.
onDidChangeDecorations
((
e
)
=>
this
.
onModelDecorationsChanged
(
modelUrlStr
,
e
))];
const
toDispose
:
lifecycle
.
IDisposable
[]
=
[
model
.
onDidChangeDecorations
((
e
)
=>
this
.
onModelDecorationsChanged
(
modelUrlStr
))];
const
breakpointDecorationsAsMap
=
new
Map
<
string
,
Range
>
();
breakPointDecorations
.
forEach
((
decorationId
,
index
)
=>
breakpointDecorationsAsMap
.
set
(
decorationId
,
desiredDecorations
[
index
].
range
));
...
...
@@ -186,7 +185,7 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
}
// breakpoints management. Represent data coming from the debug service and also send data back.
private
onModelDecorationsChanged
(
modelUrlStr
:
string
,
e
:
IModelDecorationsChangedEvent
):
void
{
private
onModelDecorationsChanged
(
modelUrlStr
:
string
):
void
{
const
modelData
=
this
.
modelDataMap
.
get
(
modelUrlStr
);
if
(
modelData
.
breakpointDecorationsAsMap
.
size
===
0
)
{
// I have no decorations
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录