Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
af4b129c
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,发现更多精彩内容 >>
未验证
提交
af4b129c
编写于
5月 05, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move word wrapping options logic to the EditorLayoutInfoComputer
上级
9ecc8107
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
165 addition
and
64 deletion
+165
-64
src/vs/editor/common/config/editorOptions.ts
src/vs/editor/common/config/editorOptions.ts
+80
-64
src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts
...ditor/test/common/viewLayout/editorLayoutProvider.test.ts
+82
-0
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+3
-0
未找到文件。
src/vs/editor/common/config/editorOptions.ts
浏览文件 @
af4b129c
...
...
@@ -1744,6 +1744,10 @@ export interface EditorLayoutInfo {
*/
readonly
viewportColumn
:
number
;
readonly
isWordWrapMinified
:
boolean
;
readonly
isViewportWrapping
:
boolean
;
readonly
wrappingColumn
:
number
;
/**
* The width of the vertical scrollbar.
*/
...
...
@@ -1763,15 +1767,16 @@ export interface EditorLayoutInfo {
* @internal
*/
export
interface
EditorLayoutInfoComputerEnv
{
memory
:
IComputeOptionsMemory
|
null
;
outerWidth
:
number
;
outerHeight
:
number
;
lineHeight
:
number
;
viewLineCount
:
number
;
lineNumbersDigitCount
:
number
;
typicalHalfwidthCharacterWidth
:
number
;
maxDigitWidth
:
number
;
pixelRatio
:
number
;
readonly
memory
:
IComputeOptionsMemory
|
null
;
readonly
outerWidth
:
number
;
readonly
outerHeight
:
number
;
readonly
isDominatedByLongLines
:
boolean
readonly
lineHeight
:
number
;
readonly
viewLineCount
:
number
;
readonly
lineNumbersDigitCount
:
number
;
readonly
typicalHalfwidthCharacterWidth
:
number
;
readonly
maxDigitWidth
:
number
;
readonly
pixelRatio
:
number
;
}
/**
...
...
@@ -1782,7 +1787,12 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
constructor
()
{
super
(
EditorOption
.
layoutInfo
,
[
EditorOption
.
glyphMargin
,
EditorOption
.
lineDecorationsWidth
,
EditorOption
.
folding
,
EditorOption
.
minimap
,
EditorOption
.
scrollbar
,
EditorOption
.
lineNumbers
]
[
EditorOption
.
glyphMargin
,
EditorOption
.
lineDecorationsWidth
,
EditorOption
.
folding
,
EditorOption
.
minimap
,
EditorOption
.
scrollbar
,
EditorOption
.
lineNumbers
,
EditorOption
.
wordWrap
,
EditorOption
.
wordWrapColumn
,
EditorOption
.
wordWrapMinified
,
EditorOption
.
accessibilitySupport
]
);
}
...
...
@@ -1791,6 +1801,7 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
memory
:
env
.
memory
,
outerWidth
:
env
.
outerWidth
,
outerHeight
:
env
.
outerHeight
,
isDominatedByLongLines
:
env
.
isDominatedByLongLines
,
lineHeight
:
env
.
fontInfo
.
lineHeight
,
viewLineCount
:
env
.
viewLineCount
,
lineNumbersDigitCount
:
env
.
lineNumbersDigitCount
,
...
...
@@ -1823,6 +1834,11 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
const
maxDigitWidth
=
env
.
maxDigitWidth
;
const
pixelRatio
=
env
.
pixelRatio
;
const
wordWrap
=
options
.
get
(
EditorOption
.
wordWrap
);
const
wordWrapColumn
=
options
.
get
(
EditorOption
.
wordWrapColumn
);
const
wordWrapMinified
=
options
.
get
(
EditorOption
.
wordWrapMinified
);
const
accessibilitySupport
=
options
.
get
(
EditorOption
.
accessibilitySupport
);
const
showGlyphMargin
=
options
.
get
(
EditorOption
.
glyphMargin
);
const
showLineNumbers
=
(
options
.
get
(
EditorOption
.
lineNumbers
).
renderType
!==
RenderLineNumbersType
.
Off
);
const
lineNumbersMinChars
=
options
.
get
(
EditorOption
.
lineNumbersMinChars
)
|
0
;
...
...
@@ -1974,6 +1990,52 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
const
verticalArrowSize
=
(
verticalScrollbarHasArrows
?
scrollbarArrowSize
:
0
);
let
bareWrappingInfo
:
{
isWordWrapMinified
:
boolean
;
isViewportWrapping
:
boolean
;
wrappingColumn
:
number
;
}
|
null
=
null
;
{
if
(
accessibilitySupport
===
AccessibilitySupport
.
Enabled
)
{
// See https://github.com/Microsoft/vscode/issues/27766
// Never enable wrapping when a screen reader is attached
// because arrow down etc. will not move the cursor in the way
// a screen reader expects.
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
};
}
else
if
(
wordWrapMinified
&&
env
.
isDominatedByLongLines
)
{
// Force viewport width wrapping if model is dominated by long lines
bareWrappingInfo
=
{
isWordWrapMinified
:
true
,
isViewportWrapping
:
true
,
wrappingColumn
:
Math
.
max
(
1
,
viewportColumn
)
};
}
else
if
(
wordWrap
===
'
on
'
)
{
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
true
,
wrappingColumn
:
Math
.
max
(
1
,
viewportColumn
)
};
}
else
if
(
wordWrap
===
'
bounded
'
)
{
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
true
,
wrappingColumn
:
Math
.
min
(
Math
.
max
(
1
,
viewportColumn
),
wordWrapColumn
)
};
}
else
if
(
wordWrap
===
'
wordWrapColumn
'
)
{
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
wordWrapColumn
};
}
else
{
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
};
}
}
return
{
width
:
outerWidth
,
height
:
outerHeight
,
...
...
@@ -2004,6 +2066,10 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
viewportColumn
:
viewportColumn
,
isWordWrapMinified
:
bareWrappingInfo
.
isWordWrapMinified
,
isViewportWrapping
:
bareWrappingInfo
.
isViewportWrapping
,
wrappingColumn
:
bareWrappingInfo
.
wrappingColumn
,
verticalScrollbarWidth
:
verticalScrollbarWidth
,
horizontalScrollbarHeight
:
horizontalScrollbarHeight
,
...
...
@@ -3234,67 +3300,17 @@ export interface EditorWrappingInfo {
class
EditorWrappingInfoComputer
extends
ComputedEditorOption
<
EditorOption
.
wrappingInfo
,
EditorWrappingInfo
>
{
constructor
()
{
super
(
EditorOption
.
wrappingInfo
,
[
EditorOption
.
wordWrap
,
EditorOption
.
wordWrapColumn
,
EditorOption
.
wordWrapMinified
,
EditorOption
.
layoutInfo
,
EditorOption
.
accessibilitySupport
]);
super
(
EditorOption
.
wrappingInfo
,
[
EditorOption
.
layoutInfo
]);
}
public
compute
(
env
:
IEnvironmentalOptions
,
options
:
IComputedEditorOptions
,
_
:
EditorWrappingInfo
):
EditorWrappingInfo
{
const
wordWrap
=
options
.
get
(
EditorOption
.
wordWrap
);
const
wordWrapColumn
=
options
.
get
(
EditorOption
.
wordWrapColumn
);
const
wordWrapMinified
=
options
.
get
(
EditorOption
.
wordWrapMinified
);
const
layoutInfo
=
options
.
get
(
EditorOption
.
layoutInfo
);
const
accessibilitySupport
=
options
.
get
(
EditorOption
.
accessibilitySupport
);
let
bareWrappingInfo
:
{
isWordWrapMinified
:
boolean
;
isViewportWrapping
:
boolean
;
wrappingColumn
:
number
;
}
|
null
=
null
;
{
if
(
accessibilitySupport
===
AccessibilitySupport
.
Enabled
)
{
// See https://github.com/Microsoft/vscode/issues/27766
// Never enable wrapping when a screen reader is attached
// because arrow down etc. will not move the cursor in the way
// a screen reader expects.
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
};
}
else
if
(
wordWrapMinified
&&
env
.
isDominatedByLongLines
)
{
// Force viewport width wrapping if model is dominated by long lines
bareWrappingInfo
=
{
isWordWrapMinified
:
true
,
isViewportWrapping
:
true
,
wrappingColumn
:
Math
.
max
(
1
,
layoutInfo
.
viewportColumn
)
};
}
else
if
(
wordWrap
===
'
on
'
)
{
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
true
,
wrappingColumn
:
Math
.
max
(
1
,
layoutInfo
.
viewportColumn
)
};
}
else
if
(
wordWrap
===
'
bounded
'
)
{
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
true
,
wrappingColumn
:
Math
.
min
(
Math
.
max
(
1
,
layoutInfo
.
viewportColumn
),
wordWrapColumn
)
};
}
else
if
(
wordWrap
===
'
wordWrapColumn
'
)
{
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
wordWrapColumn
};
}
else
{
bareWrappingInfo
=
{
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
};
}
}
return
{
isDominatedByLongLines
:
env
.
isDominatedByLongLines
,
isWordWrapMinified
:
bareWrapping
Info
.
isWordWrapMinified
,
isViewportWrapping
:
bareWrapping
Info
.
isViewportWrapping
,
wrappingColumn
:
bareWrapping
Info
.
wrappingColumn
,
isWordWrapMinified
:
layout
Info
.
isWordWrapMinified
,
isViewportWrapping
:
layout
Info
.
isViewportWrapping
,
wrappingColumn
:
layout
Info
.
wrappingColumn
,
};
}
}
...
...
src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts
浏览文件 @
af4b129c
...
...
@@ -76,10 +76,16 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
};
options
.
_write
(
EditorOption
.
lineNumbers
,
lineNumbersOptions
);
options
.
_write
(
EditorOption
.
wordWrap
,
'
off
'
);
options
.
_write
(
EditorOption
.
wordWrapColumn
,
80
);
options
.
_write
(
EditorOption
.
wordWrapMinified
,
true
);
options
.
_write
(
EditorOption
.
accessibilitySupport
,
'
auto
'
);
const
actual
=
EditorLayoutInfoComputer
.
computeLayout
(
options
,
{
memory
:
null
,
outerWidth
:
input
.
outerWidth
,
outerHeight
:
input
.
outerHeight
,
isDominatedByLongLines
:
false
,
lineHeight
:
input
.
lineHeight
,
viewLineCount
:
input
.
maxLineNumber
||
Math
.
pow
(
10
,
input
.
lineNumbersDigitCount
)
-
1
,
lineNumbersDigitCount
:
input
.
lineNumbersDigitCount
,
...
...
@@ -138,7 +144,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
800
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
98
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -200,7 +210,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
800
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
97
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
11
,
horizontalScrollbarHeight
:
12
,
...
...
@@ -262,7 +276,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
800
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
88
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -324,7 +342,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
900
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
900
,
viewportColumn
:
88
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -386,7 +408,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
900
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
900
,
viewportColumn
:
88
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -448,7 +474,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
900
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
900
,
viewportColumn
:
83
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -510,7 +540,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
900
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
900
,
viewportColumn
:
83
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -572,7 +606,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
900
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
900
,
viewportColumn
:
82
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -634,7 +672,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
900
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
900
,
viewportColumn
:
171
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -696,7 +738,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
900
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
900
,
viewportColumn
:
169
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -758,7 +804,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
800
,
minimapCanvasOuterWidth
:
97
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
89
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -820,7 +870,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
1600
,
minimapCanvasOuterWidth
:
97
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
89
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -882,7 +936,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
3200
,
minimapCanvasOuterWidth
:
55
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
93
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -944,7 +1002,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
3200
,
minimapCanvasOuterWidth
:
55
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
93
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -1008,7 +1070,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
1560
,
minimapCanvasOuterWidth
:
97
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
89
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -1072,7 +1138,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
1600
,
minimapCanvasOuterWidth
:
55
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
93
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -1136,7 +1206,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
1600
,
minimapCanvasOuterWidth
:
97
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
89
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -1200,7 +1274,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
1600
,
minimapCanvasOuterWidth
:
55
,
minimapCanvasOuterHeight
:
800
,
viewportColumn
:
93
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -1262,7 +1340,11 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
minimapCanvasInnerHeight
:
844
,
minimapCanvasOuterWidth
:
91
,
minimapCanvasOuterHeight
:
422
,
viewportColumn
:
83
,
isWordWrapMinified
:
false
,
isViewportWrapping
:
false
,
wrappingColumn
:
-
1
,
verticalScrollbarWidth
:
14
,
horizontalScrollbarHeight
:
10
,
...
...
src/vs/monaco.d.ts
浏览文件 @
af4b129c
...
...
@@ -3423,6 +3423,9 @@ declare namespace monaco.editor {
* The number of columns (of typical characters) fitting on a viewport line.
*/
readonly
viewportColumn
:
number
;
readonly
isWordWrapMinified
:
boolean
;
readonly
isViewportWrapping
:
boolean
;
readonly
wrappingColumn
:
number
;
/**
* The width of the vertical scrollbar.
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录