Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
c09fd454
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,发现更多精彩内容 >>
提交
c09fd454
编写于
1月 09, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract font info validation code to fontInfo
上级
17181f3b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
34 deletion
+74
-34
src/vs/editor/common/config/commonEditorConfig.ts
src/vs/editor/common/config/commonEditorConfig.ts
+4
-23
src/vs/editor/common/config/fontInfo.ts
src/vs/editor/common/config/fontInfo.ts
+70
-11
未找到文件。
src/vs/editor/common/config/commonEditorConfig.ts
浏览文件 @
c09fd454
...
...
@@ -11,7 +11,7 @@ import * as objects from 'vs/base/common/objects';
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
Extensions
,
IConfigurationRegistry
,
IConfigurationNode
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
DefaultConfig
,
DEFAULT_INDENTATION
,
DEFAULT_TRIM_AUTO_WHITESPACE
,
GOLDEN_LINE_HEIGHT_RATIO
}
from
'
vs/editor/common/config/defaultConfig
'
;
import
{
DefaultConfig
,
DEFAULT_INDENTATION
,
DEFAULT_TRIM_AUTO_WHITESPACE
}
from
'
vs/editor/common/config/defaultConfig
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
EditorLayoutProvider
}
from
'
vs/editor/common/viewLayout/editorLayoutProvider
'
;
import
{
ScrollbarVisibility
}
from
'
vs/base/common/scrollable
'
;
...
...
@@ -496,22 +496,6 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
let
opts
=
this
.
_configWithDefaults
.
getEditorOptions
();
let
editorClassName
=
this
.
_getEditorClassName
(
opts
.
theme
,
toBoolean
(
opts
.
fontLigatures
));
let
fontFamily
=
String
(
opts
.
fontFamily
)
||
DefaultConfig
.
editor
.
fontFamily
;
let
fontWeight
=
String
(
opts
.
fontWeight
)
||
DefaultConfig
.
editor
.
fontWeight
;
let
fontSize
=
toFloat
(
opts
.
fontSize
,
DefaultConfig
.
editor
.
fontSize
);
fontSize
=
Math
.
max
(
0
,
fontSize
);
fontSize
=
Math
.
min
(
100
,
fontSize
);
if
(
fontSize
===
0
)
{
fontSize
=
DefaultConfig
.
editor
.
fontSize
;
}
let
lineHeight
=
toInteger
(
opts
.
lineHeight
,
0
,
150
);
if
(
lineHeight
===
0
)
{
lineHeight
=
Math
.
round
(
GOLDEN_LINE_HEIGHT_RATIO
*
fontSize
);
}
let
editorZoomLevelMultiplier
=
1
+
(
EditorZoom
.
getZoomLevel
()
*
0.1
);
fontSize
*=
editorZoomLevelMultiplier
;
lineHeight
*=
editorZoomLevelMultiplier
;
let
disableTranslate3d
=
toBoolean
(
opts
.
disableTranslate3d
);
let
canUseTranslate3d
=
this
.
_getCanUseTranslate3d
();
...
...
@@ -519,16 +503,13 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
canUseTranslate3d
=
false
;
}
let
bareFontInfo
=
BareFontInfo
.
createFromRawSettings
(
opts
);
return
InternalEditorOptionsHelper
.
createInternalEditorOptions
(
this
.
getOuterWidth
(),
this
.
getOuterHeight
(),
opts
,
this
.
readConfiguration
(
new
BareFontInfo
({
fontFamily
:
fontFamily
,
fontWeight
:
fontWeight
,
fontSize
:
fontSize
,
lineHeight
:
lineHeight
})),
this
.
readConfiguration
(
bareFontInfo
),
editorClassName
,
this
.
_isDominatedByLongLines
,
this
.
_maxLineNumber
,
...
...
src/vs/editor/common/config/fontInfo.ts
浏览文件 @
c09fd454
...
...
@@ -4,21 +4,80 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
DefaultConfig
,
GOLDEN_LINE_HEIGHT_RATIO
}
from
'
vs/editor/common/config/defaultConfig
'
;
import
{
EditorZoom
}
from
'
vs/editor/common/config/editorZoom
'
;
function
safeParseFloat
(
n
:
number
|
string
,
defaultValue
:
number
):
number
{
if
(
typeof
n
===
'
number
'
)
{
return
n
;
}
let
r
=
parseFloat
(
n
);
if
(
isNaN
(
r
))
{
return
defaultValue
;
}
return
r
;
}
function
safeParseInt
(
n
:
number
|
string
,
defaultValue
:
number
):
number
{
if
(
typeof
n
===
'
number
'
)
{
return
Math
.
round
(
n
);
}
let
r
=
parseInt
(
n
);
if
(
isNaN
(
r
))
{
return
defaultValue
;
}
return
r
;
}
function
clamp
(
n
:
number
,
min
:
number
,
max
:
number
):
number
{
if
(
n
<
min
)
{
return
min
;
}
if
(
n
>
max
)
{
return
max
;
}
return
n
;
}
export
class
BareFontInfo
{
readonly
_bareFontInfoBrand
:
void
;
// /**
// * @internal
// */
// public static createFromRawSettings(editor: {
// fontFamily: string;
// fontWeight: string;
// fontSize: number;
// lineHeight: number;
// }): BareFontInfo {
/**
* @internal
*/
public
static
createFromRawSettings
(
opts
:
{
fontFamily
?:
string
;
fontWeight
?:
string
;
fontSize
?:
number
|
string
;
lineHeight
?:
number
|
string
;
}):
BareFontInfo
{
let
fontFamily
=
String
(
opts
.
fontFamily
)
||
DefaultConfig
.
editor
.
fontFamily
;
let
fontWeight
=
String
(
opts
.
fontWeight
)
||
DefaultConfig
.
editor
.
fontWeight
;
// }
let
fontSize
=
safeParseFloat
(
opts
.
fontSize
,
DefaultConfig
.
editor
.
fontSize
);
fontSize
=
clamp
(
fontSize
,
0
,
100
);
if
(
fontSize
===
0
)
{
fontSize
=
DefaultConfig
.
editor
.
fontSize
;
}
let
lineHeight
=
safeParseInt
(
opts
.
lineHeight
,
0
);
lineHeight
=
clamp
(
lineHeight
,
0
,
150
);
if
(
lineHeight
===
0
)
{
lineHeight
=
Math
.
round
(
GOLDEN_LINE_HEIGHT_RATIO
*
fontSize
);
}
let
editorZoomLevelMultiplier
=
1
+
(
EditorZoom
.
getZoomLevel
()
*
0.1
);
fontSize
*=
editorZoomLevelMultiplier
;
lineHeight
*=
editorZoomLevelMultiplier
;
return
new
BareFontInfo
({
fontFamily
:
fontFamily
,
fontWeight
:
fontWeight
,
fontSize
:
fontSize
,
lineHeight
:
lineHeight
});
}
readonly
fontFamily
:
string
;
readonly
fontWeight
:
string
;
...
...
@@ -28,7 +87,7 @@ export class BareFontInfo {
/**
* @internal
*/
constructor
(
opts
:
{
protected
constructor
(
opts
:
{
fontFamily
:
string
;
fontWeight
:
string
;
fontSize
:
number
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录