Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
e02f59a1
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e02f59a1
编写于
4月 18, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #31312: Leave a 2px gap at the end of wrapped lines for the cursor
上级
a03dbe86
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
86 addition
and
25 deletion
+86
-25
src/vs/editor/common/config/editorOptions.ts
src/vs/editor/common/config/editorOptions.ts
+10
-8
src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts
...ditor/test/common/viewLayout/editorLayoutProvider.test.ts
+76
-17
未找到文件。
src/vs/editor/common/config/editorOptions.ts
浏览文件 @
e02f59a1
...
...
@@ -2090,18 +2090,19 @@ export class EditorLayoutProvider {
}
// Given:
// viewportColumn = (contentWidth - verticalScrollbarWidth) / typicalHalfwidthCharacterWidth
// (leaving 2px for the cursor to have space after the last character)
// viewportColumn = (contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth
// minimapWidth = viewportColumn * minimapCharWidth
// contentWidth = remainingWidth - minimapWidth
// What are good values for contentWidth and minimapWidth ?
// minimapWidth = ((contentWidth - verticalScrollbarWidth) / typicalHalfwidthCharacterWidth) * minimapCharWidth
// typicalHalfwidthCharacterWidth * minimapWidth = (contentWidth - verticalScrollbarWidth) * minimapCharWidth
// typicalHalfwidthCharacterWidth * minimapWidth = (remainingWidth - minimapWidth - verticalScrollbarWidth) * minimapCharWidth
// (typicalHalfwidthCharacterWidth + minimapCharWidth) * minimapWidth = (remainingWidth - verticalScrollbarWidth) * minimapCharWidth
// minimapWidth = ((remainingWidth - verticalScrollbarWidth) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth)
// minimapWidth = ((contentWidth - verticalScrollbarWidth
- 2
) / typicalHalfwidthCharacterWidth) * minimapCharWidth
// typicalHalfwidthCharacterWidth * minimapWidth = (contentWidth - verticalScrollbarWidth
- 2
) * minimapCharWidth
// typicalHalfwidthCharacterWidth * minimapWidth = (remainingWidth - minimapWidth - verticalScrollbarWidth
- 2
) * minimapCharWidth
// (typicalHalfwidthCharacterWidth + minimapCharWidth) * minimapWidth = (remainingWidth - verticalScrollbarWidth
- 2
) * minimapCharWidth
// minimapWidth = ((remainingWidth - verticalScrollbarWidth
- 2
) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth)
minimapWidth
=
Math
.
max
(
0
,
Math
.
floor
(((
remainingWidth
-
verticalScrollbarWidth
)
*
minimapCharWidth
)
/
(
typicalHalfwidthCharacterWidth
+
minimapCharWidth
)));
minimapWidth
=
Math
.
max
(
0
,
Math
.
floor
(((
remainingWidth
-
verticalScrollbarWidth
-
2
)
*
minimapCharWidth
)
/
(
typicalHalfwidthCharacterWidth
+
minimapCharWidth
)));
let
minimapColumns
=
minimapWidth
/
minimapCharWidth
;
if
(
minimapColumns
>
minimapMaxColumn
)
{
minimapWidth
=
Math
.
floor
(
minimapMaxColumn
*
minimapCharWidth
);
...
...
@@ -2119,7 +2120,8 @@ export class EditorLayoutProvider {
}
}
const
viewportColumn
=
Math
.
max
(
1
,
Math
.
floor
((
contentWidth
-
verticalScrollbarWidth
)
/
typicalHalfwidthCharacterWidth
));
// (leaving 2px for the cursor to have space after the last character)
const
viewportColumn
=
Math
.
max
(
1
,
Math
.
floor
((
contentWidth
-
verticalScrollbarWidth
-
2
)
/
typicalHalfwidthCharacterWidth
));
const
verticalArrowSize
=
(
verticalScrollbarHasArrows
?
scrollbarArrowSize
:
0
);
...
...
src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts
浏览文件 @
e02f59a1
...
...
@@ -58,7 +58,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
renderMinimap
:
RenderMinimap
.
None
,
minimapLeft
:
0
,
minimapWidth
:
0
,
viewportColumn
:
9
9
,
viewportColumn
:
9
8
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -174,7 +174,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
renderMinimap
:
RenderMinimap
.
None
,
minimapLeft
:
0
,
minimapWidth
:
0
,
viewportColumn
:
8
9
,
viewportColumn
:
8
8
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -232,7 +232,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
renderMinimap
:
RenderMinimap
.
None
,
minimapLeft
:
0
,
minimapWidth
:
0
,
viewportColumn
:
8
9
,
viewportColumn
:
8
8
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -290,7 +290,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
renderMinimap
:
RenderMinimap
.
None
,
minimapLeft
:
0
,
minimapWidth
:
0
,
viewportColumn
:
8
9
,
viewportColumn
:
8
8
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -348,7 +348,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
renderMinimap
:
RenderMinimap
.
None
,
minimapLeft
:
0
,
minimapWidth
:
0
,
viewportColumn
:
8
4
,
viewportColumn
:
8
3
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -406,7 +406,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
renderMinimap
:
RenderMinimap
.
None
,
minimapLeft
:
0
,
minimapWidth
:
0
,
viewportColumn
:
8
4
,
viewportColumn
:
8
3
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -464,7 +464,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
renderMinimap
:
RenderMinimap
.
None
,
minimapLeft
:
0
,
minimapWidth
:
0
,
viewportColumn
:
8
3
,
viewportColumn
:
8
2
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -522,7 +522,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
renderMinimap
:
RenderMinimap
.
None
,
minimapLeft
:
0
,
minimapWidth
:
0
,
viewportColumn
:
17
2
,
viewportColumn
:
17
1
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -580,7 +580,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
renderMinimap
:
RenderMinimap
.
None
,
minimapLeft
:
0
,
minimapWidth
:
0
,
viewportColumn
:
1
70
,
viewportColumn
:
1
69
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -632,13 +632,13 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
decorationsHeight
:
800
,
contentLeft
:
10
,
contentWidth
:
90
0
,
contentWidth
:
90
1
,
contentHeight
:
800
,
renderMinimap
:
RenderMinimap
.
Small
,
minimapLeft
:
91
0
,
minimapWidth
:
90
,
viewportColumn
:
90
,
minimapLeft
:
91
1
,
minimapWidth
:
89
,
viewportColumn
:
89
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -690,13 +690,13 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
decorationsHeight
:
800
,
contentLeft
:
10
,
contentWidth
:
90
0
,
contentWidth
:
90
1
,
contentHeight
:
800
,
renderMinimap
:
RenderMinimap
.
Large
,
minimapLeft
:
91
0
,
minimapWidth
:
90
,
viewportColumn
:
90
,
minimapLeft
:
91
1
,
minimapWidth
:
89
,
viewportColumn
:
89
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
...
...
@@ -825,4 +825,63 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
}
});
});
test
(
'
issue #31312: When wrapping, leave 2px for the cursor
'
,
()
=>
{
doTest
({
outerWidth
:
1201
,
outerHeight
:
422
,
showGlyphMargin
:
true
,
lineHeight
:
30
,
showLineNumbers
:
true
,
lineNumbersMinChars
:
3
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
26
,
typicalHalfwidthCharacterWidth
:
12.04296875
,
maxDigitWidth
:
12.04296875
,
verticalScrollbarWidth
:
14
,
horizontalScrollbarHeight
:
10
,
scrollbarArrowSize
:
11
,
verticalScrollbarHasArrows
:
false
,
minimap
:
true
,
minimapSide
:
'
right
'
,
minimapRenderCharacters
:
true
,
minimapMaxColumn
:
120
,
pixelRatio
:
2
},
{
width
:
1201
,
height
:
422
,
glyphMarginLeft
:
0
,
glyphMarginWidth
:
30
,
glyphMarginHeight
:
422
,
lineNumbersLeft
:
30
,
lineNumbersWidth
:
36
,
lineNumbersHeight
:
422
,
decorationsLeft
:
66
,
decorationsWidth
:
26
,
decorationsHeight
:
422
,
contentLeft
:
92
,
contentWidth
:
1026
,
contentHeight
:
422
,
renderMinimap
:
RenderMinimap
.
Large
,
minimapLeft
:
1104
,
minimapWidth
:
83
,
viewportColumn
:
83
,
verticalScrollbarWidth
:
14
,
horizontalScrollbarHeight
:
10
,
overviewRuler
:
{
top
:
0
,
width
:
14
,
height
:
422
,
right
:
0
}
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录