Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cbf1ef20
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,发现更多精彩内容 >>
提交
cbf1ef20
编写于
10月 30, 2017
作者:
D
David Weber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add line number interval setting
上级
6d5e4b8c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
97 addition
and
1 deletion
+97
-1
src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts
src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts
+3
-1
src/vs/editor/common/config/commonEditorConfig.ts
src/vs/editor/common/config/commonEditorConfig.ts
+6
-0
src/vs/editor/common/config/editorOptions.ts
src/vs/editor/common/config/editorOptions.ts
+13
-0
src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts
...ditor/test/common/viewLayout/editorLayoutProvider.test.ts
+69
-0
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+6
-0
未找到文件。
src/vs/editor/browser/viewParts/lineNumbers/lineNumbers.ts
浏览文件 @
cbf1ef20
...
...
@@ -27,6 +27,7 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
private
_renderRelativeLineNumbers
:
boolean
;
private
_lineNumbersLeft
:
number
;
private
_lineNumbersWidth
:
number
;
private
_lineNumberInterval
:
number
;
private
_lastCursorModelPosition
:
Position
;
private
_renderResult
:
string
[];
...
...
@@ -50,6 +51,7 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
this
.
_renderRelativeLineNumbers
=
config
.
viewInfo
.
renderRelativeLineNumbers
;
this
.
_lineNumbersLeft
=
config
.
layoutInfo
.
lineNumbersLeft
;
this
.
_lineNumbersWidth
=
config
.
layoutInfo
.
lineNumbersWidth
;
this
.
_lineNumberInterval
=
config
.
viewInfo
.
lineNumberInterval
;
}
public
dispose
():
void
{
...
...
@@ -133,7 +135,7 @@ export class LineNumbersOverlay extends DynamicViewOverlay {
let
lineIndex
=
lineNumber
-
visibleStartLineNumber
;
let
renderLineNumber
=
this
.
_getLineRenderLineNumber
(
lineNumber
);
if
(
renderLineNumber
)
{
if
(
renderLineNumber
&&
lineIndex
%
this
.
_lineNumberInterval
===
0
)
{
output
[
lineIndex
]
=
(
common
+
renderLineNumber
...
...
src/vs/editor/common/config/commonEditorConfig.ts
浏览文件 @
cbf1ef20
...
...
@@ -207,6 +207,12 @@ const editorConfiguration: IConfigurationNode = {
'
default
'
:
'
on
'
,
'
description
'
:
nls
.
localize
(
'
lineNumbers
'
,
"
Controls the display of line numbers. Possible values are 'on', 'off', and 'relative'. 'relative' shows the line count from the current cursor position.
"
)
},
'
editor.lineNumberInterval
'
:
{
'
type
'
:
'
number
'
,
'
default
'
:
EDITOR_DEFAULTS
.
viewInfo
.
lineNumberInterval
,
'
minimum
'
:
1
,
'
description
'
:
nls
.
localize
(
'
lineNumberInterval
'
,
"
Controls the interval at which line numbers are shown. Should be a positive integer.
"
)
},
'
editor.rulers
'
:
{
'
type
'
:
'
array
'
,
'
items
'
:
{
...
...
src/vs/editor/common/config/editorOptions.ts
浏览文件 @
cbf1ef20
...
...
@@ -161,6 +161,11 @@ export interface IEditorOptions {
* Defaults to true.
*/
lineNumbers
?:
'
on
'
|
'
off
'
|
'
relative
'
|
((
lineNumber
:
number
)
=>
string
);
/**
* Controls the interval at which line numbers are rendered.
* Defaults to 1.
*/
lineNumberInterval
?:
number
;
/**
* Should the corresponding line be selected when clicking on the line number?
* Defaults to true.
...
...
@@ -762,6 +767,7 @@ export interface InternalEditorViewOptions {
readonly
renderCustomLineNumbers
:
(
lineNumber
:
number
)
=>
string
;
readonly
renderRelativeLineNumbers
:
boolean
;
readonly
selectOnLineNumbers
:
boolean
;
readonly
lineNumberInterval
:
number
;
readonly
glyphMargin
:
boolean
;
readonly
revealHorizontalRightPadding
:
number
;
readonly
roundedSelection
:
boolean
;
...
...
@@ -1031,6 +1037,7 @@ export class InternalEditorOptions {
&&
a
.
renderCustomLineNumbers
===
b
.
renderCustomLineNumbers
&&
a
.
renderRelativeLineNumbers
===
b
.
renderRelativeLineNumbers
&&
a
.
selectOnLineNumbers
===
b
.
selectOnLineNumbers
&&
a
.
lineNumberInterval
===
b
.
lineNumberInterval
&&
a
.
glyphMargin
===
b
.
glyphMargin
&&
a
.
revealHorizontalRightPadding
===
b
.
revealHorizontalRightPadding
&&
a
.
roundedSelection
===
b
.
roundedSelection
...
...
@@ -1629,6 +1636,7 @@ export class EditorOptionsValidator {
renderCustomLineNumbers
:
renderCustomLineNumbers
,
renderRelativeLineNumbers
:
renderRelativeLineNumbers
,
selectOnLineNumbers
:
_boolean
(
opts
.
selectOnLineNumbers
,
defaults
.
selectOnLineNumbers
),
lineNumberInterval
:
_clampedInt
(
opts
.
lineNumberInterval
,
defaults
.
lineNumberInterval
,
defaults
.
lineNumberInterval
,
Constants
.
MAX_UINT_32
),
glyphMargin
:
_boolean
(
opts
.
glyphMargin
,
defaults
.
glyphMargin
),
revealHorizontalRightPadding
:
_clampedInt
(
opts
.
revealHorizontalRightPadding
,
defaults
.
revealHorizontalRightPadding
,
0
,
1000
),
roundedSelection
:
_boolean
(
opts
.
roundedSelection
,
defaults
.
roundedSelection
),
...
...
@@ -1732,6 +1740,7 @@ export class InternalEditorOptionsFactory {
renderCustomLineNumbers
:
opts
.
viewInfo
.
renderCustomLineNumbers
,
renderRelativeLineNumbers
:
opts
.
viewInfo
.
renderRelativeLineNumbers
,
selectOnLineNumbers
:
opts
.
viewInfo
.
selectOnLineNumbers
,
lineNumberInterval
:
opts
.
viewInfo
.
lineNumberInterval
,
glyphMargin
:
opts
.
viewInfo
.
glyphMargin
,
revealHorizontalRightPadding
:
opts
.
viewInfo
.
revealHorizontalRightPadding
,
roundedSelection
:
(
accessibilityIsOn
?
false
:
opts
.
viewInfo
.
roundedSelection
),
// DISABLED WHEN SCREEN READER IS ATTACHED
...
...
@@ -1823,6 +1832,7 @@ export class InternalEditorOptionsFactory {
showGlyphMargin
:
opts
.
viewInfo
.
glyphMargin
,
lineHeight
:
env
.
fontInfo
.
lineHeight
,
showLineNumbers
:
opts
.
viewInfo
.
renderLineNumbers
,
lineNumberInterval
:
opts
.
viewInfo
.
lineNumberInterval
,
lineNumbersMinChars
:
opts
.
lineNumbersMinChars
,
lineNumbersDigitCount
:
env
.
lineNumbersDigitCount
,
lineDecorationsWidth
:
lineDecorationsWidth
,
...
...
@@ -1951,6 +1961,7 @@ export interface IEditorLayoutProviderOpts {
lineHeight
:
number
;
showLineNumbers
:
boolean
;
lineNumberInterval
:
number
;
lineNumbersMinChars
:
number
;
lineNumbersDigitCount
:
number
;
...
...
@@ -1980,6 +1991,7 @@ export class EditorLayoutProvider {
const
showGlyphMargin
=
_opts
.
showGlyphMargin
;
const
lineHeight
=
_opts
.
lineHeight
|
0
;
const
showLineNumbers
=
_opts
.
showLineNumbers
;
const
lineNumberInterval
=
_opts
.
lineNumberInterval
;
const
lineNumbersMinChars
=
_opts
.
lineNumbersMinChars
|
0
;
const
lineNumbersDigitCount
=
_opts
.
lineNumbersDigitCount
|
0
;
const
lineDecorationsWidth
=
_opts
.
lineDecorationsWidth
|
0
;
...
...
@@ -2156,6 +2168,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
renderCustomLineNumbers
:
null
,
renderRelativeLineNumbers
:
false
,
selectOnLineNumbers
:
true
,
lineNumberInterval
:
1
,
glyphMargin
:
true
,
revealHorizontalRightPadding
:
30
,
roundedSelection
:
true
,
...
...
src/vs/editor/test/common/viewLayout/editorLayoutProvider.test.ts
浏览文件 @
cbf1ef20
...
...
@@ -21,6 +21,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
false
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
0
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
...
...
@@ -77,6 +78,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
false
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
0
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
...
...
@@ -133,6 +135,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
false
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
0
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
...
...
@@ -189,6 +192,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
false
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
0
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
...
...
@@ -245,6 +249,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
false
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
5
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
...
...
@@ -301,6 +306,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
true
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
5
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
...
...
@@ -357,6 +363,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
true
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
5
,
lineNumbersDigitCount
:
5
,
lineDecorationsWidth
:
10
,
...
...
@@ -413,6 +420,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
true
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
5
,
lineNumbersDigitCount
:
6
,
lineDecorationsWidth
:
10
,
...
...
@@ -469,6 +477,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
true
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
5
,
lineNumbersDigitCount
:
6
,
lineDecorationsWidth
:
10
,
...
...
@@ -525,6 +534,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
true
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
5
,
lineNumbersDigitCount
:
6
,
lineDecorationsWidth
:
10
,
...
...
@@ -581,6 +591,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
false
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
0
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
...
...
@@ -637,6 +648,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
false
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
0
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
...
...
@@ -693,6 +705,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
false
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
0
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
...
...
@@ -733,6 +746,62 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
overviewRuler
:
{
top
:
0
,
width
:
0
,
height
:
800
,
right
:
0
}
});
});
test
(
'
EditorLayoutProvider 10 - render editor with lineNumberInterval = 1
'
,
()
=>
{
doTest
({
outerWidth
:
1000
,
outerHeight
:
800
,
showGlyphMargin
:
false
,
lineHeight
:
16
,
showLineNumbers
:
false
,
lineNumberInterval
:
1
,
lineNumbersMinChars
:
0
,
lineNumbersDigitCount
:
1
,
lineDecorationsWidth
:
10
,
typicalHalfwidthCharacterWidth
:
10
,
maxDigitWidth
:
10
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
scrollbarArrowSize
:
0
,
verticalScrollbarHasArrows
:
false
,
minimap
:
false
,
minimapRenderCharacters
:
true
,
minimapMaxColumn
:
150
,
pixelRatio
:
1
,
},
{
width
:
1000
,
height
:
800
,
glyphMarginLeft
:
0
,
glyphMarginWidth
:
0
,
glyphMarginHeight
:
800
,
lineNumbersLeft
:
0
,
lineNumbersWidth
:
0
,
lineNumbersHeight
:
800
,
decorationsLeft
:
0
,
decorationsWidth
:
10
,
decorationsHeight
:
800
,
contentLeft
:
10
,
contentWidth
:
990
,
contentHeight
:
800
,
renderMinimap
:
RenderMinimap
.
None
,
minimapWidth
:
0
,
viewportColumn
:
99
,
verticalScrollbarWidth
:
0
,
horizontalScrollbarHeight
:
0
,
overviewRuler
:
{
top
:
0
,
width
:
0
,
...
...
src/vs/monaco.d.ts
浏览文件 @
cbf1ef20
...
...
@@ -2746,6 +2746,11 @@ declare module monaco.editor {
* Defaults to true.
*/
lineNumbers
?:
'
on
'
|
'
off
'
|
'
relative
'
|
((
lineNumber
:
number
)
=>
string
);
/**
* Controls the interval at which line numbers are rendered.
* Defaults to 1.
*/
lineNumberInterval
?:
number
;
/**
* Should the corresponding line be selected when clicking on the line number?
* Defaults to true.
...
...
@@ -3280,6 +3285,7 @@ declare module monaco.editor {
readonly
renderCustomLineNumbers
:
(
lineNumber
:
number
)
=>
string
;
readonly
renderRelativeLineNumbers
:
boolean
;
readonly
selectOnLineNumbers
:
boolean
;
readonly
lineNumberInterval
:
number
;
readonly
glyphMargin
:
boolean
;
readonly
revealHorizontalRightPadding
:
number
;
readonly
roundedSelection
:
boolean
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录