Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eadda7cd
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,发现更多精彩内容 >>
提交
eadda7cd
编写于
9月 20, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #41492: Add collapseOnReplaceEdit decoration option
上级
141f0554
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
56 addition
and
0 deletion
+56
-0
src/vs/editor/common/model.ts
src/vs/editor/common/model.ts
+5
-0
src/vs/editor/common/model/intervalTree.ts
src/vs/editor/common/model/intervalTree.ts
+23
-0
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+2
-0
src/vs/editor/contrib/links/links.ts
src/vs/editor/contrib/links/links.ts
+8
-0
src/vs/editor/test/common/model/modelDecorations.test.ts
src/vs/editor/test/common/model/modelDecorations.test.ts
+18
-0
未找到文件。
src/vs/editor/common/model.ts
浏览文件 @
eadda7cd
...
...
@@ -77,6 +77,11 @@ export interface IModelDecorationOptions {
* @internal
*/
showIfCollapsed
?:
boolean
;
/**
* Collapse the decoration if its entire range is being replaced via an edit.
* @internal
*/
collapseOnReplaceEdit
?:
boolean
;
/**
* Specifies the stack order of a decoration.
* A decoration with greater stack order is always in front of a decoration with a lower stack order.
...
...
src/vs/editor/common/model/intervalTree.ts
浏览文件 @
eadda7cd
...
...
@@ -58,6 +58,10 @@ const enum Constants {
StickinessMaskInverse
=
0b11001111
,
StickinessOffset
=
4
,
CollapseOnReplaceEditMask
=
0b01000000
,
CollapseOnReplaceEditMaskInverse
=
0b10111111
,
CollapseOnReplaceEditOffset
=
6
,
/**
* Due to how deletion works (in order to avoid always walking the right subtree of the deleted node),
* the deltas for nodes can grow and shrink dramatically. It has been observed, in practice, that unless
...
...
@@ -121,6 +125,14 @@ function _setNodeStickiness(node: IntervalNode, stickiness: TrackedRangeStickine
(
node
.
metadata
&
Constants
.
StickinessMaskInverse
)
|
(
stickiness
<<
Constants
.
StickinessOffset
)
);
}
function
getCollapseOnReplaceEdit
(
node
:
IntervalNode
):
boolean
{
return
((
node
.
metadata
&
Constants
.
CollapseOnReplaceEditMask
)
>>>
Constants
.
CollapseOnReplaceEditOffset
)
===
1
;
}
function
setCollapseOnReplaceEdit
(
node
:
IntervalNode
,
value
:
boolean
):
void
{
node
.
metadata
=
(
(
node
.
metadata
&
Constants
.
CollapseOnReplaceEditMaskInverse
)
|
((
value
?
1
:
0
)
<<
Constants
.
CollapseOnReplaceEditOffset
)
);
}
export
function
setNodeStickiness
(
node
:
IntervalNode
,
stickiness
:
ActualTrackedRangeStickiness
):
void
{
_setNodeStickiness
(
node
,
<
number
>
stickiness
);
}
...
...
@@ -170,6 +182,7 @@ export class IntervalNode implements IModelDecoration {
setNodeIsForValidation
(
this
,
false
);
_setNodeStickiness
(
this
,
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
);
setNodeIsInOverviewRuler
(
this
,
false
);
setCollapseOnReplaceEdit
(
this
,
false
);
this
.
cachedVersionId
=
0
;
this
.
cachedAbsoluteStart
=
start
;
...
...
@@ -199,6 +212,7 @@ export class IntervalNode implements IModelDecoration {
));
_setNodeStickiness
(
this
,
<
number
>
this
.
options
.
stickiness
);
setNodeIsInOverviewRuler
(
this
,
(
this
.
options
.
overviewRuler
&&
this
.
options
.
overviewRuler
.
color
)
?
true
:
false
);
setCollapseOnReplaceEdit
(
this
,
this
.
options
.
collapseOnReplaceEdit
);
}
public
setCachedOffsets
(
absoluteStart
:
number
,
absoluteEnd
:
number
,
cachedVersionId
:
number
):
void
{
...
...
@@ -417,6 +431,15 @@ export function nodeAcceptEdit(node: IntervalNode, start: number, end: number, t
const
nodeEnd
=
node
.
end
;
let
endDone
=
false
;
if
(
start
<=
nodeStart
&&
nodeEnd
<=
end
&&
getCollapseOnReplaceEdit
(
node
))
{
// This edit encompasses the entire decoration range
// and the decoration has asked to become collapsed
node
.
start
=
start
;
startDone
=
true
;
node
.
end
=
start
;
endDone
=
true
;
}
{
const
moveSemantics
=
forceMoveMarkers
?
MarkerMoveSemantics
.
ForceMove
:
(
deletingCnt
>
0
?
MarkerMoveSemantics
.
ForceStay
:
MarkerMoveSemantics
.
MarkerDefined
);
if
(
!
startDone
&&
adjustMarkerBeforeColumn
(
nodeStart
,
startStickToPreviousCharacter
,
start
,
moveSemantics
))
{
...
...
src/vs/editor/common/model/textModel.ts
浏览文件 @
eadda7cd
...
...
@@ -2839,6 +2839,7 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
readonly
glyphMarginHoverMessage
:
IMarkdownString
|
IMarkdownString
[];
readonly
isWholeLine
:
boolean
;
readonly
showIfCollapsed
:
boolean
;
readonly
collapseOnReplaceEdit
:
boolean
;
readonly
overviewRuler
:
ModelDecorationOverviewRulerOptions
;
readonly
glyphMarginClassName
:
string
;
readonly
linesDecorationsClassName
:
string
;
...
...
@@ -2856,6 +2857,7 @@ export class ModelDecorationOptions implements model.IModelDecorationOptions {
this
.
glyphMarginHoverMessage
=
options
.
glyphMarginHoverMessage
||
null
;
this
.
isWholeLine
=
options
.
isWholeLine
||
false
;
this
.
showIfCollapsed
=
options
.
showIfCollapsed
||
false
;
this
.
collapseOnReplaceEdit
=
options
.
collapseOnReplaceEdit
||
false
;
this
.
overviewRuler
=
options
.
overviewRuler
?
new
ModelDecorationOverviewRulerOptions
(
options
.
overviewRuler
)
:
null
;
this
.
glyphMarginClassName
=
options
.
glyphMarginClassName
?
cleanClassName
(
options
.
glyphMarginClassName
)
:
null
;
this
.
linesDecorationsClassName
=
options
.
linesDecorationsClassName
?
cleanClassName
(
options
.
linesDecorationsClassName
)
:
null
;
...
...
src/vs/editor/contrib/links/links.ts
浏览文件 @
eadda7cd
...
...
@@ -54,41 +54,49 @@ const HOVER_MESSAGE_COMMAND_ALT = new MarkdownString().appendText(
const
decoration
=
{
meta
:
ModelDecorationOptions
.
register
({
stickiness
:
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
collapseOnReplaceEdit
:
true
,
inlineClassName
:
'
detected-link
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL_META
}),
metaActive
:
ModelDecorationOptions
.
register
({
stickiness
:
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
collapseOnReplaceEdit
:
true
,
inlineClassName
:
'
detected-link-active
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL_META
}),
alt
:
ModelDecorationOptions
.
register
({
stickiness
:
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
collapseOnReplaceEdit
:
true
,
inlineClassName
:
'
detected-link
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL_ALT
}),
altActive
:
ModelDecorationOptions
.
register
({
stickiness
:
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
collapseOnReplaceEdit
:
true
,
inlineClassName
:
'
detected-link-active
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL_ALT
}),
altCommand
:
ModelDecorationOptions
.
register
({
stickiness
:
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
collapseOnReplaceEdit
:
true
,
inlineClassName
:
'
detected-link
'
,
hoverMessage
:
HOVER_MESSAGE_COMMAND_ALT
}),
altCommandActive
:
ModelDecorationOptions
.
register
({
stickiness
:
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
collapseOnReplaceEdit
:
true
,
inlineClassName
:
'
detected-link-active
'
,
hoverMessage
:
HOVER_MESSAGE_COMMAND_ALT
}),
metaCommand
:
ModelDecorationOptions
.
register
({
stickiness
:
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
collapseOnReplaceEdit
:
true
,
inlineClassName
:
'
detected-link
'
,
hoverMessage
:
HOVER_MESSAGE_COMMAND_META
}),
metaCommandActive
:
ModelDecorationOptions
.
register
({
stickiness
:
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
collapseOnReplaceEdit
:
true
,
inlineClassName
:
'
detected-link-active
'
,
hoverMessage
:
HOVER_MESSAGE_COMMAND_META
}),
...
...
src/vs/editor/test/common/model/modelDecorations.test.ts
浏览文件 @
eadda7cd
...
...
@@ -1370,4 +1370,22 @@ suite('deltaDecorations', () => {
model
.
dispose
();
});
test
(
'
issue #41492: URL highlighting persists after pasting over url
'
,
()
=>
{
let
model
=
TextModel
.
createFromString
([
'
My First Line
'
].
join
(
'
\n
'
));
const
id
=
model
.
deltaDecorations
([],
[{
range
:
new
Range
(
1
,
2
,
1
,
14
),
options
:
{
stickiness
:
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
collapseOnReplaceEdit
:
true
}
}])[
0
];
model
.
applyEdits
([{
range
:
new
Range
(
1
,
1
,
1
,
14
),
text
:
'
Some new text that is longer than the previous one
'
,
forceMoveMarkers
:
false
}]);
const
actual
=
model
.
getDecorationRange
(
id
);
assert
.
deepEqual
(
actual
,
new
Range
(
1
,
1
,
1
,
1
));
model
.
dispose
();
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录