Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
86085377
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,发现更多精彩内容 >>
未验证
提交
86085377
编写于
5月 05, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor tweaks
上级
013181fe
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
75 addition
and
68 deletion
+75
-68
src/vs/editor/common/config/editorOptions.ts
src/vs/editor/common/config/editorOptions.ts
+75
-68
未找到文件。
src/vs/editor/common/config/editorOptions.ts
浏览文件 @
86085377
...
...
@@ -1947,12 +1947,26 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
}
private
static
_computeMinimapLayout
(
input
:
IMinimapLayoutInput
)
{
if
(
!
input
.
minimap
.
enabled
)
{
return
{
storeResultInMemory
:
false
,
minimapWidth
:
0
,
minimapHeightIsEditorHeight
:
false
,
minimapIsSampling
:
false
,
minimapScale
:
1
,
minimapLineHeight
:
1
,
minimapCanvasInnerWidth
:
0
,
minimapCanvasInnerHeight
:
0
,
minimapCanvasOuterWidth
:
0
,
minimapCanvasOuterHeight
:
0
,
};
}
const
outerHeight
=
input
.
outerHeight
;
const
lineHeight
=
input
.
lineHeight
;
const
typicalHalfwidthCharacterWidth
=
input
.
typicalHalfwidthCharacterWidth
;
const
pixelRatio
=
input
.
pixelRatio
;
const
scrollBeyondLastLine
=
input
.
scrollBeyondLastLine
;
const
minimapEnabled
=
input
.
minimap
.
enabled
;
const
minimapRenderCharacters
=
input
.
minimap
.
renderCharacters
;
let
minimapScale
=
(
pixelRatio
>=
2
?
Math
.
round
(
input
.
minimap
.
scale
*
2
)
:
input
.
minimap
.
scale
);
const
minimapMaxColumn
=
input
.
minimap
.
maxColumn
;
...
...
@@ -1972,80 +1986,73 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
let
minimapHeightIsEditorHeight
=
false
;
let
minimapIsSampling
=
false
;
let
minimapLineHeight
=
baseCharHeight
*
minimapScale
;
if
(
!
minimapEnabled
)
{
minimapWidth
=
0
;
minimapCanvasInnerWidth
=
0
;
minimapCanvasOuterWidth
=
0
;
minimapLineHeight
=
1
;
}
else
{
let
minimapCharWidth
=
minimapScale
/
pixelRatio
;
let
minimapWidthMultiplier
:
number
=
1
;
if
(
minimapSize
===
'
fill
'
||
minimapSize
===
'
fit
'
)
{
const
{
typicalViewportLineCount
,
extraLinesBeyondLastLine
,
desiredRatio
,
minimapLineCount
}
=
EditorLayoutInfoComputer
.
computeContainedMinimapLineCount
({
viewLineCount
:
viewLineCount
,
scrollBeyondLastLine
:
scrollBeyondLastLine
,
height
:
outerHeight
,
lineHeight
:
lineHeight
,
pixelRatio
:
pixelRatio
});
// ratio is intentionally not part of the layout to avoid the layout changing all the time
// when doing sampling
const
ratio
=
viewLineCount
/
minimapLineCount
;
if
(
ratio
>
1
)
{
let
minimapCharWidth
=
minimapScale
/
pixelRatio
;
let
minimapWidthMultiplier
:
number
=
1
;
if
(
minimapSize
===
'
fill
'
||
minimapSize
===
'
fit
'
)
{
const
{
typicalViewportLineCount
,
extraLinesBeyondLastLine
,
desiredRatio
,
minimapLineCount
}
=
EditorLayoutInfoComputer
.
computeContainedMinimapLineCount
({
viewLineCount
:
viewLineCount
,
scrollBeyondLastLine
:
scrollBeyondLastLine
,
height
:
outerHeight
,
lineHeight
:
lineHeight
,
pixelRatio
:
pixelRatio
});
// ratio is intentionally not part of the layout to avoid the layout changing all the time
// when doing sampling
const
ratio
=
viewLineCount
/
minimapLineCount
;
if
(
ratio
>
1
)
{
minimapHeightIsEditorHeight
=
true
;
minimapIsSampling
=
true
;
minimapScale
=
1
;
minimapLineHeight
=
1
;
minimapCharWidth
=
minimapScale
/
pixelRatio
;
}
else
{
const
effectiveMinimapHeight
=
Math
.
ceil
((
viewLineCount
+
extraLinesBeyondLastLine
)
*
minimapLineHeight
);
if
(
minimapSize
===
'
fill
'
||
effectiveMinimapHeight
>
minimapCanvasInnerHeight
)
{
if
(
minimapSize
===
'
fit
'
&&
isViewportWrapping
)
{
// `fit` becomes `fill`: this can cause the `minimapScale` to change, which causes `minimapWidth` to change.
// With viewport wrapping, this can cause the `viewLineCount` to change, which can lead to a new result
// where `fit` would not become `fill`... and so on...
// to break the loop, we store the result in memory and then reuse the same result on the next call.
storeResultInMemory
=
true
;
}
minimapHeightIsEditorHeight
=
true
;
minimapIsSampling
=
true
;
minimapScale
=
1
;
minimapLineHeight
=
1
;
minimapCharWidth
=
minimapScale
/
pixelRatio
;
}
else
{
const
effectiveMinimapHeight
=
Math
.
ceil
((
viewLineCount
+
extraLinesBeyondLastLine
)
*
minimapLineHeight
);
if
(
minimapSize
===
'
fill
'
||
effectiveMinimapHeight
>
minimapCanvasInnerHeight
)
{
if
(
minimapSize
===
'
fit
'
&&
isViewportWrapping
)
{
// `fit` becomes `fill`: this can cause the `minimapScale` to change, which causes `minimapWidth` to change.
// With viewport wrapping, this can cause the `viewLineCount` to change, which can lead to a new result
// where `fit` would not become `fill`... and so on...
// to break the loop, we store the result in memory and then reuse the same result on the next call.
storeResultInMemory
=
true
;
}
minimapHeightIsEditorHeight
=
true
;
const
configuredFontScale
=
minimapScale
;
minimapLineHeight
=
Math
.
min
(
lineHeight
*
pixelRatio
,
Math
.
max
(
1
,
Math
.
floor
(
1
/
desiredRatio
)));
minimapScale
=
Math
.
min
(
configuredFontScale
+
1
,
Math
.
max
(
1
,
Math
.
floor
(
minimapLineHeight
/
baseCharHeight
)));
if
(
minimapScale
>
configuredFontScale
)
{
minimapWidthMultiplier
=
Math
.
min
(
2
,
minimapScale
/
configuredFontScale
);
}
minimapCharWidth
=
minimapScale
/
pixelRatio
/
minimapWidthMultiplier
;
minimapCanvasInnerHeight
=
Math
.
ceil
((
Math
.
max
(
typicalViewportLineCount
,
viewLineCount
+
extraLinesBeyondLastLine
))
*
minimapLineHeight
);
const
configuredFontScale
=
minimapScale
;
minimapLineHeight
=
Math
.
min
(
lineHeight
*
pixelRatio
,
Math
.
max
(
1
,
Math
.
floor
(
1
/
desiredRatio
)));
minimapScale
=
Math
.
min
(
configuredFontScale
+
1
,
Math
.
max
(
1
,
Math
.
floor
(
minimapLineHeight
/
baseCharHeight
)));
if
(
minimapScale
>
configuredFontScale
)
{
minimapWidthMultiplier
=
Math
.
min
(
2
,
minimapScale
/
configuredFontScale
);
}
minimapCharWidth
=
minimapScale
/
pixelRatio
/
minimapWidthMultiplier
;
minimapCanvasInnerHeight
=
Math
.
ceil
((
Math
.
max
(
typicalViewportLineCount
,
viewLineCount
+
extraLinesBeyondLastLine
))
*
minimapLineHeight
);
}
}
}
// Given:
// (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 - 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
-
2
)
*
minimapCharWidth
)
/
(
typicalHalfwidthCharacterWidth
+
minimapCharWidth
)))
+
MINIMAP_GUTTER_WIDTH
;
let
minimapColumns
=
minimapWidth
/
minimapCharWidth
;
if
(
minimapColumns
>
minimapMaxColumn
)
{
minimapWidth
=
Math
.
floor
(
minimapMaxColumn
*
minimapCharWidth
);
}
minimapCanvasInnerWidth
=
Math
.
floor
(
pixelRatio
*
minimapWidth
);
minimapCanvasOuterWidth
=
minimapCanvasInnerWidth
/
pixelRatio
;
minimapCanvasInnerWidth
=
Math
.
floor
(
minimapCanvasInnerWidth
*
minimapWidthMultiplier
);
// Given:
// (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 - 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
-
2
)
*
minimapCharWidth
)
/
(
typicalHalfwidthCharacterWidth
+
minimapCharWidth
)))
+
MINIMAP_GUTTER_WIDTH
;
let
minimapColumns
=
minimapWidth
/
minimapCharWidth
;
if
(
minimapColumns
>
minimapMaxColumn
)
{
minimapWidth
=
Math
.
floor
(
minimapMaxColumn
*
minimapCharWidth
);
}
minimapCanvasInnerWidth
=
Math
.
floor
(
pixelRatio
*
minimapWidth
);
minimapCanvasOuterWidth
=
minimapCanvasInnerWidth
/
pixelRatio
;
minimapCanvasInnerWidth
=
Math
.
floor
(
minimapCanvasInnerWidth
*
minimapWidthMultiplier
);
return
{
storeResultInMemory
,
minimapWidth
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录