Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
29e9717d
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,发现更多精彩内容 >>
未验证
提交
29e9717d
编写于
8月 31, 2020
作者:
A
Alexandru Dima
提交者:
GitHub
8月 31, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #104310 from stnrepin/trailing-option-for-render-whitespace
Add 'trailing' option to 'editor.renderWhitespace'
上级
20c94eb3
4260f5a2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
116 addition
and
12 deletion
+116
-12
src/vs/editor/browser/viewParts/lines/viewLine.ts
src/vs/editor/browser/viewParts/lines/viewLine.ts
+1
-1
src/vs/editor/common/config/editorOptions.ts
src/vs/editor/common/config/editorOptions.ts
+4
-3
src/vs/editor/common/viewLayout/viewLineRenderer.ts
src/vs/editor/common/viewLayout/viewLineRenderer.ts
+19
-5
src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts
...vs/editor/test/common/viewLayout/viewLineRenderer.test.ts
+90
-1
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+2
-2
未找到文件。
src/vs/editor/browser/viewParts/lines/viewLine.ts
浏览文件 @
29e9717d
...
...
@@ -72,7 +72,7 @@ export class DomReadingContext {
export
class
ViewLineOptions
{
public
readonly
themeType
:
ThemeType
;
public
readonly
renderWhitespace
:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
all
'
;
public
readonly
renderWhitespace
:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
trailing
'
|
'
all
'
;
public
readonly
renderControlCharacters
:
boolean
;
public
readonly
spaceWidth
:
number
;
public
readonly
middotWidth
:
number
;
...
...
src/vs/editor/common/config/editorOptions.ts
浏览文件 @
29e9717d
...
...
@@ -529,7 +529,7 @@ export interface IEditorOptions {
* Enable rendering of whitespace.
* Defaults to none.
*/
renderWhitespace
?:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
all
'
;
renderWhitespace
?:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
trailing
'
|
'
all
'
;
/**
* Enable rendering of control characters.
* Defaults to false.
...
...
@@ -4079,13 +4079,14 @@ export const EditorOptions = {
)),
renderWhitespace
:
register
(
new
EditorStringEnumOption
(
EditorOption
.
renderWhitespace
,
'
renderWhitespace
'
,
'
selection
'
as
'
selection
'
|
'
none
'
|
'
boundary
'
|
'
all
'
,
[
'
none
'
,
'
boundary
'
,
'
selection
'
,
'
all
'
]
as
const
,
'
selection
'
as
'
selection
'
|
'
none
'
|
'
boundary
'
|
'
trailing
'
|
'
all
'
,
[
'
none
'
,
'
boundary
'
,
'
selection
'
,
'
trailing
'
,
'
all
'
]
as
const
,
{
enumDescriptions
:
[
''
,
nls
.
localize
(
'
renderWhitespace.boundary
'
,
"
Render whitespace characters except for single spaces between words.
"
),
nls
.
localize
(
'
renderWhitespace.selection
'
,
"
Render whitespace characters only on selected text.
"
),
nls
.
localize
(
'
renderWhitespace.trailing
'
,
"
Render only trailing whitespace characters
"
),
''
],
description
:
nls
.
localize
(
'
renderWhitespace
'
,
"
Controls how the editor should render whitespace characters.
"
)
...
...
src/vs/editor/common/viewLayout/viewLineRenderer.ts
浏览文件 @
29e9717d
...
...
@@ -14,7 +14,8 @@ export const enum RenderWhitespace {
None
=
0
,
Boundary
=
1
,
Selection
=
2
,
All
=
3
Trailing
=
3
,
All
=
4
}
export
const
enum
LinePartMetadata
{
...
...
@@ -113,7 +114,7 @@ export class RenderLineInput {
middotWidth
:
number
,
wsmiddotWidth
:
number
,
stopRenderingLineAfter
:
number
,
renderWhitespace
:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
all
'
,
renderWhitespace
:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
trailing
'
|
'
all
'
,
renderControlCharacters
:
boolean
,
fontLigatures
:
boolean
,
selectionsOnLine
:
LineRange
[]
|
null
...
...
@@ -138,7 +139,9 @@ export class RenderLineInput {
?
RenderWhitespace
.
Boundary
:
renderWhitespace
===
'
selection
'
?
RenderWhitespace
.
Selection
:
RenderWhitespace
.
None
:
renderWhitespace
===
'
trailing
'
?
RenderWhitespace
.
Trailing
:
RenderWhitespace
.
None
);
this
.
renderControlCharacters
=
renderControlCharacters
;
this
.
fontLigatures
=
fontLigatures
;
...
...
@@ -435,7 +438,11 @@ function resolveRenderLineInput(input: RenderLineInput): ResolvedRenderLineInput
}
let
tokens
=
transformAndRemoveOverflowing
(
input
.
lineTokens
,
input
.
fauxIndentLength
,
len
);
if
(
input
.
renderWhitespace
===
RenderWhitespace
.
All
||
input
.
renderWhitespace
===
RenderWhitespace
.
Boundary
||
(
input
.
renderWhitespace
===
RenderWhitespace
.
Selection
&&
!!
input
.
selectionsOnLine
))
{
if
(
input
.
renderWhitespace
===
RenderWhitespace
.
All
||
input
.
renderWhitespace
===
RenderWhitespace
.
Boundary
||
(
input
.
renderWhitespace
===
RenderWhitespace
.
Selection
&&
!!
input
.
selectionsOnLine
)
||
input
.
renderWhitespace
===
RenderWhitespace
.
Trailing
)
{
tokens
=
_applyRenderWhitespace
(
input
,
lineContent
,
len
,
tokens
);
}
let
containsForeignElements
=
ForeignElementType
.
None
;
...
...
@@ -592,6 +599,7 @@ function _applyRenderWhitespace(input: RenderLineInput, lineContent: string, len
const
useMonospaceOptimizations
=
input
.
useMonospaceOptimizations
;
const
selections
=
input
.
selectionsOnLine
;
const
onlyBoundary
=
(
input
.
renderWhitespace
===
RenderWhitespace
.
Boundary
);
const
onlyTrailing
=
(
input
.
renderWhitespace
===
RenderWhitespace
.
Trailing
);
const
generateLinePartForEachWhitespace
=
(
input
.
renderSpaceWidth
!==
input
.
spaceWidth
);
let
result
:
LinePart
[]
=
[],
resultLen
=
0
;
...
...
@@ -600,10 +608,11 @@ function _applyRenderWhitespace(input: RenderLineInput, lineContent: string, len
let
tokenEndIndex
=
tokens
[
tokenIndex
].
endIndex
;
const
tokensLength
=
tokens
.
length
;
let
lineIsEmptyOrWhitespace
=
false
;
let
firstNonWhitespaceIndex
=
strings
.
firstNonWhitespaceIndex
(
lineContent
);
let
lastNonWhitespaceIndex
:
number
;
if
(
firstNonWhitespaceIndex
===
-
1
)
{
// The entire line is whitespace
lineIsEmptyOrWhitespace
=
true
;
firstNonWhitespaceIndex
=
len
;
lastNonWhitespaceIndex
=
len
;
}
else
{
...
...
@@ -651,6 +660,11 @@ function _applyRenderWhitespace(input: RenderLineInput, lineContent: string, len
isInWhitespace
=
!!
currentSelection
&&
currentSelection
.
startOffset
<=
charIndex
&&
currentSelection
.
endOffset
>
charIndex
;
}
// If rendering only trailing whitespace, check that the charIndex points to trailing whitespace.
if
(
isInWhitespace
&&
onlyTrailing
)
{
isInWhitespace
=
lineIsEmptyOrWhitespace
||
charIndex
>
lastNonWhitespaceIndex
;
}
if
(
wasInWhitespace
)
{
// was in whitespace token
if
(
!
isInWhitespace
||
(
!
useMonospaceOptimizations
&&
tmpIndent
>=
tabSize
))
{
...
...
src/vs/editor/test/common/viewLayout/viewLineRenderer.test.ts
浏览文件 @
29e9717d
...
...
@@ -869,7 +869,7 @@ suite('viewLineRenderer.renderLine', () => {
suite
(
'
viewLineRenderer.renderLine 2
'
,
()
=>
{
function
testCreateLineParts
(
fontIsMonospace
:
boolean
,
lineContent
:
string
,
tokens
:
ViewLineToken
[],
fauxIndentLength
:
number
,
renderWhitespace
:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
all
'
,
selections
:
LineRange
[]
|
null
,
expected
:
string
):
void
{
function
testCreateLineParts
(
fontIsMonospace
:
boolean
,
lineContent
:
string
,
tokens
:
ViewLineToken
[],
fauxIndentLength
:
number
,
renderWhitespace
:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
trailing
'
|
'
all
'
,
selections
:
LineRange
[]
|
null
,
expected
:
string
):
void
{
let
actual
=
renderViewLine
(
new
RenderLineInput
(
fontIsMonospace
,
true
,
...
...
@@ -1355,6 +1355,95 @@ suite('viewLineRenderer.renderLine 2', () => {
);
});
test
(
'
createLineParts render whitespace for trailing with leading, inner, and without trailing whitespace
'
,
()
=>
{
testCreateLineParts
(
false
,
'
Hello world!
'
,
[
createPart
(
4
,
0
),
createPart
(
6
,
1
),
createPart
(
14
,
2
)
],
0
,
'
trailing
'
,
null
,
[
'
<span>
'
,
'
<span class="mtk0">
\
u00a0Hel</span>
'
,
'
<span class="mtk1">lo</span>
'
,
'
<span class="mtk2">
\
u00a0world!</span>
'
,
'
</span>
'
,
].
join
(
''
)
);
});
test
(
'
createLineParts render whitespace for trailing with leading, inner, and trailing whitespace
'
,
()
=>
{
testCreateLineParts
(
false
,
'
Hello world!
\t
'
,
[
createPart
(
4
,
0
),
createPart
(
6
,
1
),
createPart
(
15
,
2
)
],
0
,
'
trailing
'
,
null
,
[
'
<span>
'
,
'
<span class="mtk0">
\
u00a0Hel</span>
'
,
'
<span class="mtk1">lo</span>
'
,
'
<span class="mtk2">
\
u00a0world!</span>
'
,
'
<span class="mtkz" style="width:30px">
\
u00b7
\
u2192
\
u00a0</span>
'
,
'
</span>
'
,
].
join
(
''
)
);
});
test
(
'
createLineParts render whitespace for trailing with 8 leading and 8 trailing whitespaces
'
,
()
=>
{
testCreateLineParts
(
false
,
'
Hello world!
'
,
[
createPart
(
8
,
1
),
createPart
(
10
,
2
),
createPart
(
28
,
3
)
],
0
,
'
trailing
'
,
null
,
[
'
<span>
'
,
'
<span class="mtk1">
\
u00a0
\
u00a0
\
u00a0
\
u00a0
\
u00a0
\
u00a0
\
u00a0
\
u00a0</span>
'
,
'
<span class="mtk2">He</span>
'
,
'
<span class="mtk3">llo
\
u00a0world!</span>
'
,
'
<span class="mtkz" style="width:40px">
\
u00b7
\
u00b7
\
u00b7
\
u00b7</span>
'
,
'
<span class="mtkz" style="width:40px">
\
u00b7
\
u00b7
\
u00b7
\
u00b7</span>
'
,
'
</span>
'
,
].
join
(
''
)
);
});
test
(
'
createLineParts render whitespace for trailing with line containing only whitespaces
'
,
()
=>
{
testCreateLineParts
(
false
,
'
\t
'
,
[
createPart
(
2
,
0
),
createPart
(
3
,
1
),
],
0
,
'
trailing
'
,
null
,
[
'
<span>
'
,
'
<span class="mtkz" style="width:40px">
\
u00b7
\
u2192
\
u00a0
\
u00a0</span>
'
,
'
<span class="mtkz" style="width:10px">
\
u00b7</span>
'
,
'
</span>
'
,
].
join
(
''
)
);
});
test
(
'
createLineParts can handle unsorted inline decorations
'
,
()
=>
{
let
actual
=
renderViewLine
(
new
RenderLineInput
(
false
,
...
...
src/vs/monaco.d.ts
浏览文件 @
29e9717d
...
...
@@ -3068,7 +3068,7 @@ declare namespace monaco.editor {
* Enable rendering of whitespace.
* Defaults to none.
*/
renderWhitespace
?:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
all
'
;
renderWhitespace
?:
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
trailing
'
|
'
all
'
;
/**
* Enable rendering of control characters.
* Defaults to false.
...
...
@@ -4052,7 +4052,7 @@ declare namespace monaco.editor {
renderLineHighlight
:
IEditorOption
<
EditorOption
.
renderLineHighlight
,
'
all
'
|
'
line
'
|
'
none
'
|
'
gutter
'
>
;
renderLineHighlightOnlyWhenFocus
:
IEditorOption
<
EditorOption
.
renderLineHighlightOnlyWhenFocus
,
boolean
>
;
renderValidationDecorations
:
IEditorOption
<
EditorOption
.
renderValidationDecorations
,
'
on
'
|
'
off
'
|
'
editable
'
>
;
renderWhitespace
:
IEditorOption
<
EditorOption
.
renderWhitespace
,
'
all
'
|
'
none
'
|
'
boundary
'
|
'
selection
'
>
;
renderWhitespace
:
IEditorOption
<
EditorOption
.
renderWhitespace
,
'
all
'
|
'
none
'
|
'
boundary
'
|
'
selection
'
|
'
trailing
'
>
;
revealHorizontalRightPadding
:
IEditorOption
<
EditorOption
.
revealHorizontalRightPadding
,
number
>
;
roundedSelection
:
IEditorOption
<
EditorOption
.
roundedSelection
,
boolean
>
;
rulers
:
IEditorOption
<
EditorOption
.
rulers
,
{}
>
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录