Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0792b079
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,发现更多精彩内容 >>
未验证
提交
0792b079
编写于
2月 23, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add LinePart.metadata (for #91178)
上级
4c0a06c7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
45 deletion
+89
-45
src/vs/editor/common/viewLayout/lineDecorations.ts
src/vs/editor/common/viewLayout/lineDecorations.ts
+28
-5
src/vs/editor/common/viewLayout/viewLineRenderer.ts
src/vs/editor/common/viewLayout/viewLineRenderer.ts
+41
-20
src/vs/editor/test/common/viewLayout/lineDecorations.test.ts
src/vs/editor/test/common/viewLayout/lineDecorations.test.ts
+20
-20
未找到文件。
src/vs/editor/common/viewLayout/lineDecorations.ts
浏览文件 @
0792b079
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
Constants
}
from
'
vs/base/common/uint
'
;
import
{
Constants
}
from
'
vs/base/common/uint
'
;
import
{
InlineDecoration
,
InlineDecorationType
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
InlineDecoration
,
InlineDecorationType
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
LinePartMetadata
}
from
'
vs/editor/common/viewLayout/viewLineRenderer
'
;
export
class
LineDecoration
{
export
class
LineDecoration
{
_lineDecorationBrand
:
void
;
_lineDecorationBrand
:
void
;
...
@@ -92,11 +93,13 @@ export class DecorationSegment {
...
@@ -92,11 +93,13 @@ export class DecorationSegment {
startOffset
:
number
;
startOffset
:
number
;
endOffset
:
number
;
endOffset
:
number
;
className
:
string
;
className
:
string
;
metadata
:
number
;
constructor
(
startOffset
:
number
,
endOffset
:
number
,
className
:
string
)
{
constructor
(
startOffset
:
number
,
endOffset
:
number
,
className
:
string
,
metadata
:
number
)
{
this
.
startOffset
=
startOffset
;
this
.
startOffset
=
startOffset
;
this
.
endOffset
=
endOffset
;
this
.
endOffset
=
endOffset
;
this
.
className
=
className
;
this
.
className
=
className
;
this
.
metadata
=
metadata
;
}
}
}
}
...
@@ -104,13 +107,23 @@ class Stack {
...
@@ -104,13 +107,23 @@ class Stack {
public
count
:
number
;
public
count
:
number
;
private
readonly
stopOffsets
:
number
[];
private
readonly
stopOffsets
:
number
[];
private
readonly
classNames
:
string
[];
private
readonly
classNames
:
string
[];
private
readonly
metadata
:
number
[];
constructor
()
{
constructor
()
{
this
.
stopOffsets
=
[];
this
.
stopOffsets
=
[];
this
.
classNames
=
[];
this
.
classNames
=
[];
this
.
metadata
=
[];
this
.
count
=
0
;
this
.
count
=
0
;
}
}
private
static
_metadata
(
metadata
:
number
[]):
number
{
let
result
=
0
;
for
(
let
i
=
0
,
len
=
metadata
.
length
;
i
<
len
;
i
++
)
{
result
|=
metadata
[
i
];
}
return
result
;
}
public
consumeLowerThan
(
maxStopOffset
:
number
,
nextStartOffset
:
number
,
result
:
DecorationSegment
[]):
number
{
public
consumeLowerThan
(
maxStopOffset
:
number
,
nextStartOffset
:
number
,
result
:
DecorationSegment
[]):
number
{
while
(
this
.
count
>
0
&&
this
.
stopOffsets
[
0
]
<
maxStopOffset
)
{
while
(
this
.
count
>
0
&&
this
.
stopOffsets
[
0
]
<
maxStopOffset
)
{
...
@@ -122,34 +135,37 @@ class Stack {
...
@@ -122,34 +135,37 @@ class Stack {
}
}
// Basically we are consuming the first i + 1 elements of the stack
// Basically we are consuming the first i + 1 elements of the stack
result
.
push
(
new
DecorationSegment
(
nextStartOffset
,
this
.
stopOffsets
[
i
],
this
.
classNames
.
join
(
'
'
)));
result
.
push
(
new
DecorationSegment
(
nextStartOffset
,
this
.
stopOffsets
[
i
],
this
.
classNames
.
join
(
'
'
)
,
Stack
.
_metadata
(
this
.
metadata
)
));
nextStartOffset
=
this
.
stopOffsets
[
i
]
+
1
;
nextStartOffset
=
this
.
stopOffsets
[
i
]
+
1
;
// Consume them
// Consume them
this
.
stopOffsets
.
splice
(
0
,
i
+
1
);
this
.
stopOffsets
.
splice
(
0
,
i
+
1
);
this
.
classNames
.
splice
(
0
,
i
+
1
);
this
.
classNames
.
splice
(
0
,
i
+
1
);
this
.
metadata
.
splice
(
0
,
i
+
1
);
this
.
count
-=
(
i
+
1
);
this
.
count
-=
(
i
+
1
);
}
}
if
(
this
.
count
>
0
&&
nextStartOffset
<
maxStopOffset
)
{
if
(
this
.
count
>
0
&&
nextStartOffset
<
maxStopOffset
)
{
result
.
push
(
new
DecorationSegment
(
nextStartOffset
,
maxStopOffset
-
1
,
this
.
classNames
.
join
(
'
'
)));
result
.
push
(
new
DecorationSegment
(
nextStartOffset
,
maxStopOffset
-
1
,
this
.
classNames
.
join
(
'
'
)
,
Stack
.
_metadata
(
this
.
metadata
)
));
nextStartOffset
=
maxStopOffset
;
nextStartOffset
=
maxStopOffset
;
}
}
return
nextStartOffset
;
return
nextStartOffset
;
}
}
public
insert
(
stopOffset
:
number
,
className
:
string
):
void
{
public
insert
(
stopOffset
:
number
,
className
:
string
,
metadata
:
number
):
void
{
if
(
this
.
count
===
0
||
this
.
stopOffsets
[
this
.
count
-
1
]
<=
stopOffset
)
{
if
(
this
.
count
===
0
||
this
.
stopOffsets
[
this
.
count
-
1
]
<=
stopOffset
)
{
// Insert at the end
// Insert at the end
this
.
stopOffsets
.
push
(
stopOffset
);
this
.
stopOffsets
.
push
(
stopOffset
);
this
.
classNames
.
push
(
className
);
this
.
classNames
.
push
(
className
);
this
.
metadata
.
push
(
metadata
);
}
else
{
}
else
{
// Find the insertion position for `stopOffset`
// Find the insertion position for `stopOffset`
for
(
let
i
=
0
;
i
<
this
.
count
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
count
;
i
++
)
{
if
(
this
.
stopOffsets
[
i
]
>=
stopOffset
)
{
if
(
this
.
stopOffsets
[
i
]
>=
stopOffset
)
{
this
.
stopOffsets
.
splice
(
i
,
0
,
stopOffset
);
this
.
stopOffsets
.
splice
(
i
,
0
,
stopOffset
);
this
.
classNames
.
splice
(
i
,
0
,
className
);
this
.
classNames
.
splice
(
i
,
0
,
className
);
this
.
metadata
.
splice
(
i
,
0
,
metadata
);
break
;
break
;
}
}
}
}
...
@@ -178,6 +194,13 @@ export class LineDecorationsNormalizer {
...
@@ -178,6 +194,13 @@ export class LineDecorationsNormalizer {
let
startColumn
=
d
.
startColumn
;
let
startColumn
=
d
.
startColumn
;
let
endColumn
=
d
.
endColumn
;
let
endColumn
=
d
.
endColumn
;
const
className
=
d
.
className
;
const
className
=
d
.
className
;
const
metadata
=
(
d
.
type
===
InlineDecorationType
.
Before
?
LinePartMetadata
.
PSEUDO_BEFORE
:
d
.
type
===
InlineDecorationType
.
After
?
LinePartMetadata
.
PSEUDO_AFTER
:
0
);
// If the position would end up in the middle of a high-low surrogate pair, we move it to before the pair
// If the position would end up in the middle of a high-low surrogate pair, we move it to before the pair
if
(
startColumn
>
1
)
{
if
(
startColumn
>
1
)
{
...
@@ -202,7 +225,7 @@ export class LineDecorationsNormalizer {
...
@@ -202,7 +225,7 @@ export class LineDecorationsNormalizer {
if
(
stack
.
count
===
0
)
{
if
(
stack
.
count
===
0
)
{
nextStartOffset
=
currentStartOffset
;
nextStartOffset
=
currentStartOffset
;
}
}
stack
.
insert
(
currentEndOffset
,
className
);
stack
.
insert
(
currentEndOffset
,
className
,
metadata
);
}
}
stack
.
consumeLowerThan
(
Constants
.
MAX_SAFE_SMALL_INTEGER
,
nextStartOffset
,
result
);
stack
.
consumeLowerThan
(
Constants
.
MAX_SAFE_SMALL_INTEGER
,
nextStartOffset
,
result
);
...
...
src/vs/editor/common/viewLayout/viewLineRenderer.ts
浏览文件 @
0792b079
...
@@ -17,6 +17,16 @@ export const enum RenderWhitespace {
...
@@ -17,6 +17,16 @@ export const enum RenderWhitespace {
All
=
3
All
=
3
}
}
export
const
enum
LinePartMetadata
{
IS_WHITESPACE
=
1
,
PSEUDO_BEFORE
=
2
,
PSEUDO_AFTER
=
4
,
IS_WHITESPACE_MASK
=
0b001
,
PSEUDO_BEFORE_MASK
=
0b010
,
PSEUDO_AFTER_MASK
=
0b100
,
}
class
LinePart
{
class
LinePart
{
_linePartBrand
:
void
;
_linePartBrand
:
void
;
...
@@ -25,10 +35,16 @@ class LinePart {
...
@@ -25,10 +35,16 @@ class LinePart {
*/
*/
public
readonly
endIndex
:
number
;
public
readonly
endIndex
:
number
;
public
readonly
type
:
string
;
public
readonly
type
:
string
;
public
readonly
metadata
:
number
;
constructor
(
endIndex
:
number
,
type
:
string
)
{
constructor
(
endIndex
:
number
,
type
:
string
,
metadata
:
number
)
{
this
.
endIndex
=
endIndex
;
this
.
endIndex
=
endIndex
;
this
.
type
=
type
;
this
.
type
=
type
;
this
.
metadata
=
metadata
;
}
public
isWhitespace
():
boolean
{
return
(
this
.
metadata
&
LinePartMetadata
.
IS_WHITESPACE_MASK
?
true
:
false
);
}
}
}
}
...
@@ -470,7 +486,7 @@ function transformAndRemoveOverflowing(tokens: IViewLineTokens, fauxIndentLength
...
@@ -470,7 +486,7 @@ function transformAndRemoveOverflowing(tokens: IViewLineTokens, fauxIndentLength
// The faux indent part of the line should have no token type
// The faux indent part of the line should have no token type
if
(
fauxIndentLength
>
0
)
{
if
(
fauxIndentLength
>
0
)
{
result
[
resultLen
++
]
=
new
LinePart
(
fauxIndentLength
,
''
);
result
[
resultLen
++
]
=
new
LinePart
(
fauxIndentLength
,
''
,
0
);
}
}
for
(
let
tokenIndex
=
0
,
tokensLen
=
tokens
.
getCount
();
tokenIndex
<
tokensLen
;
tokenIndex
++
)
{
for
(
let
tokenIndex
=
0
,
tokensLen
=
tokens
.
getCount
();
tokenIndex
<
tokensLen
;
tokenIndex
++
)
{
...
@@ -481,10 +497,10 @@ function transformAndRemoveOverflowing(tokens: IViewLineTokens, fauxIndentLength
...
@@ -481,10 +497,10 @@ function transformAndRemoveOverflowing(tokens: IViewLineTokens, fauxIndentLength
}
}
const
type
=
tokens
.
getClassName
(
tokenIndex
);
const
type
=
tokens
.
getClassName
(
tokenIndex
);
if
(
endIndex
>=
len
)
{
if
(
endIndex
>=
len
)
{
result
[
resultLen
++
]
=
new
LinePart
(
len
,
type
);
result
[
resultLen
++
]
=
new
LinePart
(
len
,
type
,
0
);
break
;
break
;
}
}
result
[
resultLen
++
]
=
new
LinePart
(
endIndex
,
type
);
result
[
resultLen
++
]
=
new
LinePart
(
endIndex
,
type
,
0
);
}
}
return
result
;
return
result
;
...
@@ -513,6 +529,7 @@ function splitLargeTokens(lineContent: string, tokens: LinePart[], onlyAtSpaces:
...
@@ -513,6 +529,7 @@ function splitLargeTokens(lineContent: string, tokens: LinePart[], onlyAtSpaces:
const
tokenEndIndex
=
token
.
endIndex
;
const
tokenEndIndex
=
token
.
endIndex
;
if
(
lastTokenEndIndex
+
Constants
.
LongToken
<
tokenEndIndex
)
{
if
(
lastTokenEndIndex
+
Constants
.
LongToken
<
tokenEndIndex
)
{
const
tokenType
=
token
.
type
;
const
tokenType
=
token
.
type
;
const
tokenMetadata
=
token
.
metadata
;
let
lastSpaceOffset
=
-
1
;
let
lastSpaceOffset
=
-
1
;
let
currTokenStart
=
lastTokenEndIndex
;
let
currTokenStart
=
lastTokenEndIndex
;
...
@@ -522,13 +539,13 @@ function splitLargeTokens(lineContent: string, tokens: LinePart[], onlyAtSpaces:
...
@@ -522,13 +539,13 @@ function splitLargeTokens(lineContent: string, tokens: LinePart[], onlyAtSpaces:
}
}
if
(
lastSpaceOffset
!==
-
1
&&
j
-
currTokenStart
>=
Constants
.
LongToken
)
{
if
(
lastSpaceOffset
!==
-
1
&&
j
-
currTokenStart
>=
Constants
.
LongToken
)
{
// Split at `lastSpaceOffset` + 1
// Split at `lastSpaceOffset` + 1
result
[
resultLen
++
]
=
new
LinePart
(
lastSpaceOffset
+
1
,
tokenType
);
result
[
resultLen
++
]
=
new
LinePart
(
lastSpaceOffset
+
1
,
tokenType
,
tokenMetadata
);
currTokenStart
=
lastSpaceOffset
+
1
;
currTokenStart
=
lastSpaceOffset
+
1
;
lastSpaceOffset
=
-
1
;
lastSpaceOffset
=
-
1
;
}
}
}
}
if
(
currTokenStart
!==
tokenEndIndex
)
{
if
(
currTokenStart
!==
tokenEndIndex
)
{
result
[
resultLen
++
]
=
new
LinePart
(
tokenEndIndex
,
tokenType
);
result
[
resultLen
++
]
=
new
LinePart
(
tokenEndIndex
,
tokenType
,
tokenMetadata
);
}
}
}
else
{
}
else
{
result
[
resultLen
++
]
=
token
;
result
[
resultLen
++
]
=
token
;
...
@@ -544,12 +561,13 @@ function splitLargeTokens(lineContent: string, tokens: LinePart[], onlyAtSpaces:
...
@@ -544,12 +561,13 @@ function splitLargeTokens(lineContent: string, tokens: LinePart[], onlyAtSpaces:
let
diff
=
(
tokenEndIndex
-
lastTokenEndIndex
);
let
diff
=
(
tokenEndIndex
-
lastTokenEndIndex
);
if
(
diff
>
Constants
.
LongToken
)
{
if
(
diff
>
Constants
.
LongToken
)
{
const
tokenType
=
token
.
type
;
const
tokenType
=
token
.
type
;
const
tokenMetadata
=
token
.
metadata
;
const
piecesCount
=
Math
.
ceil
(
diff
/
Constants
.
LongToken
);
const
piecesCount
=
Math
.
ceil
(
diff
/
Constants
.
LongToken
);
for
(
let
j
=
1
;
j
<
piecesCount
;
j
++
)
{
for
(
let
j
=
1
;
j
<
piecesCount
;
j
++
)
{
let
pieceEndIndex
=
lastTokenEndIndex
+
(
j
*
Constants
.
LongToken
);
let
pieceEndIndex
=
lastTokenEndIndex
+
(
j
*
Constants
.
LongToken
);
result
[
resultLen
++
]
=
new
LinePart
(
pieceEndIndex
,
tokenType
);
result
[
resultLen
++
]
=
new
LinePart
(
pieceEndIndex
,
tokenType
,
tokenMetadata
);
}
}
result
[
resultLen
++
]
=
new
LinePart
(
tokenEndIndex
,
tokenType
);
result
[
resultLen
++
]
=
new
LinePart
(
tokenEndIndex
,
tokenType
,
tokenMetadata
);
}
else
{
}
else
{
result
[
resultLen
++
]
=
token
;
result
[
resultLen
++
]
=
token
;
}
}
...
@@ -640,17 +658,17 @@ function _applyRenderWhitespace(input: RenderLineInput, lineContent: string, len
...
@@ -640,17 +658,17 @@ function _applyRenderWhitespace(input: RenderLineInput, lineContent: string, len
if
(
generateLinePartForEachWhitespace
)
{
if
(
generateLinePartForEachWhitespace
)
{
const
lastEndIndex
=
(
resultLen
>
0
?
result
[
resultLen
-
1
].
endIndex
:
fauxIndentLength
);
const
lastEndIndex
=
(
resultLen
>
0
?
result
[
resultLen
-
1
].
endIndex
:
fauxIndentLength
);
for
(
let
i
=
lastEndIndex
+
1
;
i
<=
charIndex
;
i
++
)
{
for
(
let
i
=
lastEndIndex
+
1
;
i
<=
charIndex
;
i
++
)
{
result
[
resultLen
++
]
=
new
LinePart
(
i
,
'
mtkw
'
);
result
[
resultLen
++
]
=
new
LinePart
(
i
,
'
mtkw
'
,
LinePartMetadata
.
IS_WHITESPACE
);
}
}
}
else
{
}
else
{
result
[
resultLen
++
]
=
new
LinePart
(
charIndex
,
'
mtkw
'
);
result
[
resultLen
++
]
=
new
LinePart
(
charIndex
,
'
mtkw
'
,
LinePartMetadata
.
IS_WHITESPACE
);
}
}
tmpIndent
=
tmpIndent
%
tabSize
;
tmpIndent
=
tmpIndent
%
tabSize
;
}
}
}
else
{
}
else
{
// was in regular token
// was in regular token
if
(
charIndex
===
tokenEndIndex
||
(
isInWhitespace
&&
charIndex
>
fauxIndentLength
))
{
if
(
charIndex
===
tokenEndIndex
||
(
isInWhitespace
&&
charIndex
>
fauxIndentLength
))
{
result
[
resultLen
++
]
=
new
LinePart
(
charIndex
,
tokenType
);
result
[
resultLen
++
]
=
new
LinePart
(
charIndex
,
tokenType
,
0
);
tmpIndent
=
tmpIndent
%
tabSize
;
tmpIndent
=
tmpIndent
%
tabSize
;
}
}
}
}
...
@@ -693,13 +711,13 @@ function _applyRenderWhitespace(input: RenderLineInput, lineContent: string, len
...
@@ -693,13 +711,13 @@ function _applyRenderWhitespace(input: RenderLineInput, lineContent: string, len
if
(
generateLinePartForEachWhitespace
)
{
if
(
generateLinePartForEachWhitespace
)
{
const
lastEndIndex
=
(
resultLen
>
0
?
result
[
resultLen
-
1
].
endIndex
:
fauxIndentLength
);
const
lastEndIndex
=
(
resultLen
>
0
?
result
[
resultLen
-
1
].
endIndex
:
fauxIndentLength
);
for
(
let
i
=
lastEndIndex
+
1
;
i
<=
len
;
i
++
)
{
for
(
let
i
=
lastEndIndex
+
1
;
i
<=
len
;
i
++
)
{
result
[
resultLen
++
]
=
new
LinePart
(
i
,
'
mtkw
'
);
result
[
resultLen
++
]
=
new
LinePart
(
i
,
'
mtkw
'
,
LinePartMetadata
.
IS_WHITESPACE
);
}
}
}
else
{
}
else
{
result
[
resultLen
++
]
=
new
LinePart
(
len
,
'
mtkw
'
);
result
[
resultLen
++
]
=
new
LinePart
(
len
,
'
mtkw
'
,
LinePartMetadata
.
IS_WHITESPACE
);
}
}
}
else
{
}
else
{
result
[
resultLen
++
]
=
new
LinePart
(
len
,
tokenType
);
result
[
resultLen
++
]
=
new
LinePart
(
len
,
tokenType
,
0
);
}
}
return
result
;
return
result
;
...
@@ -720,42 +738,45 @@ function _applyInlineDecorations(lineContent: string, len: number, tokens: LineP
...
@@ -720,42 +738,45 @@ function _applyInlineDecorations(lineContent: string, len: number, tokens: LineP
const
token
=
tokens
[
tokenIndex
];
const
token
=
tokens
[
tokenIndex
];
const
tokenEndIndex
=
token
.
endIndex
;
const
tokenEndIndex
=
token
.
endIndex
;
const
tokenType
=
token
.
type
;
const
tokenType
=
token
.
type
;
const
tokenMetadata
=
token
.
metadata
;
while
(
lineDecorationIndex
<
lineDecorationsLen
&&
lineDecorations
[
lineDecorationIndex
].
startOffset
<
tokenEndIndex
)
{
while
(
lineDecorationIndex
<
lineDecorationsLen
&&
lineDecorations
[
lineDecorationIndex
].
startOffset
<
tokenEndIndex
)
{
const
lineDecoration
=
lineDecorations
[
lineDecorationIndex
];
const
lineDecoration
=
lineDecorations
[
lineDecorationIndex
];
if
(
lineDecoration
.
startOffset
>
lastResultEndIndex
)
{
if
(
lineDecoration
.
startOffset
>
lastResultEndIndex
)
{
lastResultEndIndex
=
lineDecoration
.
startOffset
;
lastResultEndIndex
=
lineDecoration
.
startOffset
;
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
tokenType
);
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
tokenType
,
tokenMetadata
);
}
}
if
(
lineDecoration
.
endOffset
+
1
<=
tokenEndIndex
)
{
if
(
lineDecoration
.
endOffset
+
1
<=
tokenEndIndex
)
{
// This line decoration ends before this token ends
// This line decoration ends before this token ends
lastResultEndIndex
=
lineDecoration
.
endOffset
+
1
;
lastResultEndIndex
=
lineDecoration
.
endOffset
+
1
;
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
tokenType
+
'
'
+
lineDecoration
.
className
);
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
tokenType
+
'
'
+
lineDecoration
.
className
,
tokenMetadata
|
lineDecoration
.
metadata
);
lineDecorationIndex
++
;
lineDecorationIndex
++
;
}
else
{
}
else
{
// This line decoration continues on to the next token
// This line decoration continues on to the next token
lastResultEndIndex
=
tokenEndIndex
;
lastResultEndIndex
=
tokenEndIndex
;
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
tokenType
+
'
'
+
lineDecoration
.
className
);
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
tokenType
+
'
'
+
lineDecoration
.
className
,
tokenMetadata
|
lineDecoration
.
metadata
);
break
;
break
;
}
}
}
}
if
(
tokenEndIndex
>
lastResultEndIndex
)
{
if
(
tokenEndIndex
>
lastResultEndIndex
)
{
lastResultEndIndex
=
tokenEndIndex
;
lastResultEndIndex
=
tokenEndIndex
;
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
tokenType
);
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
tokenType
,
tokenMetadata
);
}
}
}
}
const
lastTokenEndIndex
=
tokens
[
tokens
.
length
-
1
].
endIndex
;
const
lastTokenEndIndex
=
tokens
[
tokens
.
length
-
1
].
endIndex
;
if
(
lineDecorationIndex
<
lineDecorationsLen
&&
lineDecorations
[
lineDecorationIndex
].
startOffset
===
lastTokenEndIndex
)
{
if
(
lineDecorationIndex
<
lineDecorationsLen
&&
lineDecorations
[
lineDecorationIndex
].
startOffset
===
lastTokenEndIndex
)
{
let
classNames
:
string
[]
=
[];
let
classNames
:
string
[]
=
[];
let
metadata
=
0
;
while
(
lineDecorationIndex
<
lineDecorationsLen
&&
lineDecorations
[
lineDecorationIndex
].
startOffset
===
lastTokenEndIndex
)
{
while
(
lineDecorationIndex
<
lineDecorationsLen
&&
lineDecorations
[
lineDecorationIndex
].
startOffset
===
lastTokenEndIndex
)
{
classNames
.
push
(
lineDecorations
[
lineDecorationIndex
].
className
);
classNames
.
push
(
lineDecorations
[
lineDecorationIndex
].
className
);
metadata
|=
lineDecorations
[
lineDecorationIndex
].
metadata
;
lineDecorationIndex
++
;
lineDecorationIndex
++
;
}
}
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
classNames
.
join
(
'
'
));
result
[
resultLen
++
]
=
new
LinePart
(
lastResultEndIndex
,
classNames
.
join
(
'
'
)
,
metadata
);
}
}
return
result
;
return
result
;
...
@@ -799,7 +820,7 @@ function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): Render
...
@@ -799,7 +820,7 @@ function _renderLine(input: ResolvedRenderLineInput, sb: IStringBuilder): Render
const
part
=
parts
[
partIndex
];
const
part
=
parts
[
partIndex
];
const
partEndIndex
=
part
.
endIndex
;
const
partEndIndex
=
part
.
endIndex
;
const
partType
=
part
.
type
;
const
partType
=
part
.
type
;
const
partRendersWhitespace
=
(
renderWhitespace
!==
RenderWhitespace
.
None
&&
(
partType
.
indexOf
(
'
mtkw
'
)
>=
0
));
const
partRendersWhitespace
=
(
renderWhitespace
!==
RenderWhitespace
.
None
&&
part
.
isWhitespace
(
));
const
partRendersWhitespaceWithWidth
=
partRendersWhitespace
&&
!
fontIsMonospace
&&
(
partType
===
'
mtkw
'
/*only whitespace*/
||
!
containsForeignElements
);
const
partRendersWhitespaceWithWidth
=
partRendersWhitespace
&&
!
fontIsMonospace
&&
(
partType
===
'
mtkw
'
/*only whitespace*/
||
!
containsForeignElements
);
charOffsetInPart
=
0
;
charOffsetInPart
=
0
;
...
...
src/vs/editor/test/common/viewLayout/lineDecorations.test.ts
浏览文件 @
0792b079
...
@@ -18,9 +18,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
...
@@ -18,9 +18,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
]);
]);
assert
.
deepEqual
(
result
,
[
assert
.
deepEqual
(
result
,
[
new
DecorationSegment
(
0
,
1
,
'
c1
'
),
new
DecorationSegment
(
0
,
1
,
'
c1
'
,
0
),
new
DecorationSegment
(
2
,
2
,
'
c2 c1
'
),
new
DecorationSegment
(
2
,
2
,
'
c2 c1
'
,
0
),
new
DecorationSegment
(
3
,
9
,
'
c1
'
),
new
DecorationSegment
(
3
,
9
,
'
c1
'
,
0
),
]);
]);
});
});
...
@@ -32,8 +32,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
...
@@ -32,8 +32,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
]);
]);
assert
.
deepEqual
(
result
,
[
assert
.
deepEqual
(
result
,
[
new
DecorationSegment
(
14
,
18
,
'
mtkw
'
),
new
DecorationSegment
(
14
,
18
,
'
mtkw
'
,
0
),
new
DecorationSegment
(
19
,
19
,
'
mtkw inline-folded
'
)
new
DecorationSegment
(
19
,
19
,
'
mtkw inline-folded
'
,
0
)
]);
]);
});
});
...
@@ -66,24 +66,24 @@ suite('Editor ViewLayout - ViewLineParts', () => {
...
@@ -66,24 +66,24 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new
LineDecoration
(
1
,
2
,
'
c1
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
1
,
2
,
'
c1
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
]),
[
]),
[
new
DecorationSegment
(
0
,
0
,
'
c1
'
),
new
DecorationSegment
(
0
,
0
,
'
c1
'
,
0
),
new
DecorationSegment
(
2
,
2
,
'
c2
'
)
new
DecorationSegment
(
2
,
2
,
'
c2
'
,
0
)
]);
]);
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
new
LineDecoration
(
1
,
3
,
'
c1
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
1
,
3
,
'
c1
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
]),
[
]),
[
new
DecorationSegment
(
0
,
1
,
'
c1
'
),
new
DecorationSegment
(
0
,
1
,
'
c1
'
,
0
),
new
DecorationSegment
(
2
,
2
,
'
c2
'
)
new
DecorationSegment
(
2
,
2
,
'
c2
'
,
0
)
]);
]);
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
new
LineDecoration
(
1
,
4
,
'
c1
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
1
,
4
,
'
c1
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
]),
[
]),
[
new
DecorationSegment
(
0
,
1
,
'
c1
'
),
new
DecorationSegment
(
0
,
1
,
'
c1
'
,
0
),
new
DecorationSegment
(
2
,
2
,
'
c1 c2
'
)
new
DecorationSegment
(
2
,
2
,
'
c1 c2
'
,
0
)
]);
]);
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
...
@@ -91,8 +91,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
...
@@ -91,8 +91,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new
LineDecoration
(
1
,
4
,
'
c1*
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
1
,
4
,
'
c1*
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
]),
[
]),
[
new
DecorationSegment
(
0
,
1
,
'
c1 c1*
'
),
new
DecorationSegment
(
0
,
1
,
'
c1 c1*
'
,
0
),
new
DecorationSegment
(
2
,
2
,
'
c1 c1* c2
'
)
new
DecorationSegment
(
2
,
2
,
'
c1 c1* c2
'
,
0
)
]);
]);
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
...
@@ -101,8 +101,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
...
@@ -101,8 +101,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new
LineDecoration
(
1
,
4
,
'
c1**
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
1
,
4
,
'
c1**
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
)
]),
[
]),
[
new
DecorationSegment
(
0
,
1
,
'
c1 c1* c1**
'
),
new
DecorationSegment
(
0
,
1
,
'
c1 c1* c1**
'
,
0
),
new
DecorationSegment
(
2
,
2
,
'
c1 c1* c1** c2
'
)
new
DecorationSegment
(
2
,
2
,
'
c1 c1* c1** c2
'
,
0
)
]);
]);
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
...
@@ -112,8 +112,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
...
@@ -112,8 +112,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
3
,
4
,
'
c2*
'
,
InlineDecorationType
.
Regular
)
new
LineDecoration
(
3
,
4
,
'
c2*
'
,
InlineDecorationType
.
Regular
)
]),
[
]),
[
new
DecorationSegment
(
0
,
1
,
'
c1 c1* c1**
'
),
new
DecorationSegment
(
0
,
1
,
'
c1 c1* c1**
'
,
0
),
new
DecorationSegment
(
2
,
2
,
'
c1 c1* c1** c2 c2*
'
)
new
DecorationSegment
(
2
,
2
,
'
c1 c1* c1** c2 c2*
'
,
0
)
]);
]);
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
assert
.
deepEqual
(
LineDecorationsNormalizer
.
normalize
(
'
abcabcabcabcabcabcabcabcabcabc
'
,
[
...
@@ -123,9 +123,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
...
@@ -123,9 +123,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
3
,
4
,
'
c2
'
,
InlineDecorationType
.
Regular
),
new
LineDecoration
(
3
,
5
,
'
c2*
'
,
InlineDecorationType
.
Regular
)
new
LineDecoration
(
3
,
5
,
'
c2*
'
,
InlineDecorationType
.
Regular
)
]),
[
]),
[
new
DecorationSegment
(
0
,
1
,
'
c1 c1* c1**
'
),
new
DecorationSegment
(
0
,
1
,
'
c1 c1* c1**
'
,
0
),
new
DecorationSegment
(
2
,
2
,
'
c1 c1* c1** c2 c2*
'
),
new
DecorationSegment
(
2
,
2
,
'
c1 c1* c1** c2 c2*
'
,
0
),
new
DecorationSegment
(
3
,
3
,
'
c2*
'
)
new
DecorationSegment
(
3
,
3
,
'
c2*
'
,
0
)
]);
]);
});
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录