Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
dac897f3
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,发现更多精彩内容 >>
提交
dac897f3
编写于
4月 27, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #10143: Add minWidthInPx to view zones
上级
4cb1ed92
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
108 addition
and
43 deletion
+108
-43
src/vs/editor/browser/editorBrowser.ts
src/vs/editor/browser/editorBrowser.ts
+5
-0
src/vs/editor/browser/viewParts/lines/viewLines.ts
src/vs/editor/browser/viewParts/lines/viewLines.ts
+1
-0
src/vs/editor/browser/viewParts/viewZones/viewZones.ts
src/vs/editor/browser/viewParts/viewZones/viewZones.ts
+13
-3
src/vs/editor/browser/widget/diffEditorWidget.ts
src/vs/editor/browser/widget/diffEditorWidget.ts
+10
-3
src/vs/editor/common/viewLayout/linesLayout.ts
src/vs/editor/common/viewLayout/linesLayout.ts
+6
-2
src/vs/editor/common/viewLayout/viewLayout.ts
src/vs/editor/common/viewLayout/viewLayout.ts
+4
-3
src/vs/editor/common/viewLayout/whitespaceComputer.ts
src/vs/editor/common/viewLayout/whitespaceComputer.ts
+36
-4
src/vs/editor/common/viewModel/viewModel.ts
src/vs/editor/common/viewModel/viewModel.ts
+1
-1
src/vs/editor/test/common/viewLayout/linesLayout.test.ts
src/vs/editor/test/common/viewLayout/linesLayout.test.ts
+11
-11
src/vs/editor/test/common/viewLayout/whitespaceComputer.test.ts
.../editor/test/common/viewLayout/whitespaceComputer.test.ts
+16
-16
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+5
-0
未找到文件。
src/vs/editor/browser/editorBrowser.ts
浏览文件 @
dac897f3
...
...
@@ -53,6 +53,11 @@ export interface IViewZone {
* If neither `heightInPx` nor `heightInLines` is specified, a default of `heightInLines` = 1 will be chosen.
*/
heightInPx
?:
number
;
/**
* The minimum width in px of the view zone.
* If this is set, the editor will ensure that the scroll width is >= than this value.
*/
minWidthInPx
?:
number
;
/**
* The dom node of the view zone
*/
...
...
src/vs/editor/browser/viewParts/lines/viewLines.ts
浏览文件 @
dac897f3
...
...
@@ -271,6 +271,7 @@ export class ViewLines extends ViewPart implements IVisibleLinesHost<ViewLine>,
return
this
.
_visibleLines
.
onTokensChanged
(
e
);
}
public
onZonesChanged
(
e
:
viewEvents
.
ViewZonesChangedEvent
):
boolean
{
this
.
_context
.
viewLayout
.
onMaxLineWidthChanged
(
this
.
_maxLineWidth
);
return
this
.
_visibleLines
.
onZonesChanged
(
e
);
}
public
onThemeChanged
(
e
:
viewEvents
.
ViewThemeChangedEvent
):
boolean
{
...
...
src/vs/editor/browser/viewParts/viewZones/viewZones.ts
浏览文件 @
dac897f3
...
...
@@ -25,6 +25,7 @@ export interface IMyViewZone {
interface
IComputedViewZoneProps
{
afterViewLineNumber
:
number
;
heightInPx
:
number
;
minWidthInPx
:
number
;
}
export
class
ViewZones
extends
ViewPart
{
...
...
@@ -138,7 +139,8 @@ export class ViewZones extends ViewPart {
if
(
zone
.
afterLineNumber
===
0
)
{
return
{
afterViewLineNumber
:
0
,
heightInPx
:
this
.
_heightInPixels
(
zone
)
heightInPx
:
this
.
_heightInPixels
(
zone
),
minWidthInPx
:
this
.
_minWidthInPixels
(
zone
)
};
}
...
...
@@ -177,13 +179,14 @@ export class ViewZones extends ViewPart {
let
isVisible
=
this
.
_context
.
model
.
coordinatesConverter
.
modelPositionIsVisible
(
zoneBeforeModelPosition
);
return
{
afterViewLineNumber
:
viewPosition
.
lineNumber
,
heightInPx
:
(
isVisible
?
this
.
_heightInPixels
(
zone
)
:
0
)
heightInPx
:
(
isVisible
?
this
.
_heightInPixels
(
zone
)
:
0
),
minWidthInPx
:
this
.
_minWidthInPixels
(
zone
)
};
}
public
addZone
(
zone
:
IViewZone
):
number
{
let
props
=
this
.
_computeWhitespaceProps
(
zone
);
let
whitespaceId
=
this
.
_context
.
viewLayout
.
addWhitespace
(
props
.
afterViewLineNumber
,
this
.
_getZoneOrdinal
(
zone
),
props
.
heightInPx
);
let
whitespaceId
=
this
.
_context
.
viewLayout
.
addWhitespace
(
props
.
afterViewLineNumber
,
this
.
_getZoneOrdinal
(
zone
),
props
.
heightInPx
,
props
.
minWidthInPx
);
let
myZone
:
IMyViewZone
=
{
whitespaceId
:
whitespaceId
,
...
...
@@ -275,6 +278,13 @@ export class ViewZones extends ViewPart {
return
this
.
_lineHeight
;
}
private
_minWidthInPixels
(
zone
:
IViewZone
):
number
{
if
(
typeof
zone
.
minWidthInPx
===
'
number
'
)
{
return
zone
.
minWidthInPx
;
}
return
0
;
}
private
_safeCallOnComputedHeight
(
zone
:
IViewZone
,
height
:
number
):
void
{
if
(
typeof
zone
.
onComputedHeight
===
'
function
'
)
{
try
{
...
...
src/vs/editor/browser/widget/diffEditorWidget.ts
浏览文件 @
dac897f3
...
...
@@ -1935,8 +1935,10 @@ class InlineViewZonesComputer extends ViewZonesComputer {
let
marginHTML
:
string
[]
=
[];
let
lineDecorationsWidth
=
this
.
modifiedEditorConfiguration
.
layoutInfo
.
decorationsWidth
;
let
lineHeight
=
this
.
modifiedEditorConfiguration
.
lineHeight
;
const
typicalHalfwidthCharacterWidth
=
this
.
modifiedEditorConfiguration
.
fontInfo
.
typicalHalfwidthCharacterWidth
;
let
maxCharsPerLine
=
0
;
for
(
let
lineNumber
=
lineChange
.
originalStartLineNumber
;
lineNumber
<=
lineChange
.
originalEndLineNumber
;
lineNumber
++
)
{
this
.
_renderOriginalLine
(
lineNumber
-
lineChange
.
originalStartLineNumber
,
this
.
originalModel
,
this
.
modifiedEditorConfiguration
,
this
.
modifiedEditorTabSize
,
lineNumber
,
decorations
,
sb
);
maxCharsPerLine
=
Math
.
max
(
maxCharsPerLine
,
this
.
_renderOriginalLine
(
lineNumber
-
lineChange
.
originalStartLineNumber
,
this
.
originalModel
,
this
.
modifiedEditorConfiguration
,
this
.
modifiedEditorTabSize
,
lineNumber
,
decorations
,
sb
)
);
if
(
this
.
renderIndicators
)
{
let
index
=
lineNumber
-
lineChange
.
originalStartLineNumber
;
...
...
@@ -1945,6 +1947,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
]);
}
}
maxCharsPerLine
+=
this
.
modifiedEditorConfiguration
.
viewInfo
.
scrollBeyondLastColumn
;
let
domNode
=
document
.
createElement
(
'
div
'
);
domNode
.
className
=
'
view-lines line-delete
'
;
...
...
@@ -1960,12 +1963,13 @@ class InlineViewZonesComputer extends ViewZonesComputer {
shouldNotShrink
:
true
,
afterLineNumber
:
(
lineChange
.
modifiedEndLineNumber
===
0
?
lineChange
.
modifiedStartLineNumber
:
lineChange
.
modifiedStartLineNumber
-
1
),
heightInLines
:
lineChangeOriginalLength
,
minWidthInPx
:
(
maxCharsPerLine
*
typicalHalfwidthCharacterWidth
),
domNode
:
domNode
,
marginDomNode
:
marginDomNode
};
}
private
_renderOriginalLine
(
count
:
number
,
originalModel
:
ITextModel
,
config
:
editorOptions
.
InternalEditorOptions
,
tabSize
:
number
,
lineNumber
:
number
,
decorations
:
InlineDecoration
[],
sb
:
IStringBuilder
):
void
{
private
_renderOriginalLine
(
count
:
number
,
originalModel
:
ITextModel
,
config
:
editorOptions
.
InternalEditorOptions
,
tabSize
:
number
,
lineNumber
:
number
,
decorations
:
InlineDecoration
[],
sb
:
IStringBuilder
):
number
{
const
lineTokens
=
originalModel
.
getLineTokens
(
lineNumber
);
const
lineContent
=
lineTokens
.
getLineContent
();
...
...
@@ -1982,7 +1986,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
const
isBasicASCII
=
ViewLineRenderingData
.
isBasicASCII
(
lineContent
,
originalModel
.
mightContainNonBasicASCII
());
const
containsRTL
=
ViewLineRenderingData
.
containsRTL
(
lineContent
,
isBasicASCII
,
originalModel
.
mightContainRTL
());
renderViewLine
(
new
RenderLineInput
(
const
output
=
renderViewLine
(
new
RenderLineInput
(
(
config
.
fontInfo
.
isMonospace
&&
!
config
.
viewInfo
.
disableMonospaceOptimizations
),
lineContent
,
isBasicASCII
,
...
...
@@ -1999,6 +2003,9 @@ class InlineViewZonesComputer extends ViewZonesComputer {
),
sb
);
sb
.
appendASCIIString
(
'
</div>
'
);
const
absoluteOffsets
=
output
.
characterMapping
.
getAbsoluteOffsets
();
return
absoluteOffsets
.
length
>
0
?
absoluteOffsets
[
absoluteOffsets
.
length
-
1
]
:
0
;
}
}
...
...
src/vs/editor/common/viewLayout/linesLayout.ts
浏览文件 @
dac897f3
...
...
@@ -64,8 +64,8 @@ export class LinesLayout {
* @param heightInPx The height of the whitespace, in pixels.
* @return An id that can be used later to mutate or delete the whitespace
*/
public
insertWhitespace
(
afterLineNumber
:
number
,
ordinal
:
number
,
heightInPx
:
number
):
number
{
return
this
.
_whitespaces
.
insertWhitespace
(
afterLineNumber
,
ordinal
,
heightInPx
);
public
insertWhitespace
(
afterLineNumber
:
number
,
ordinal
:
number
,
heightInPx
:
number
,
minWidth
:
number
):
number
{
return
this
.
_whitespaces
.
insertWhitespace
(
afterLineNumber
,
ordinal
,
heightInPx
,
minWidth
);
}
/**
...
...
@@ -155,6 +155,10 @@ export class LinesLayout {
return
this
.
_whitespaces
.
getCount
()
>
0
;
}
public
getWhitespaceMinWidth
():
number
{
return
this
.
_whitespaces
.
getMinWidth
();
}
/**
* Check if `verticalOffset` is below all lines.
*/
...
...
src/vs/editor/common/viewLayout/viewLayout.ts
浏览文件 @
dac897f3
...
...
@@ -142,7 +142,8 @@ export class ViewLayout extends Disposable implements IViewLayout {
let
isViewportWrapping
=
this
.
_configuration
.
editor
.
wrappingInfo
.
isViewportWrapping
;
if
(
!
isViewportWrapping
)
{
const
extraHorizontalSpace
=
this
.
_configuration
.
editor
.
viewInfo
.
scrollBeyondLastColumn
*
this
.
_configuration
.
editor
.
fontInfo
.
typicalHalfwidthCharacterWidth
;
return
Math
.
max
(
maxLineWidth
+
extraHorizontalSpace
,
viewportWidth
);
const
whitespaceMinWidth
=
this
.
_linesLayout
.
getWhitespaceMinWidth
();
return
Math
.
max
(
maxLineWidth
+
extraHorizontalSpace
,
viewportWidth
,
whitespaceMinWidth
);
}
return
Math
.
max
(
maxLineWidth
,
viewportWidth
);
}
...
...
@@ -173,8 +174,8 @@ export class ViewLayout extends Disposable implements IViewLayout {
// ---- IVerticalLayoutProvider
public
addWhitespace
(
afterLineNumber
:
number
,
ordinal
:
number
,
height
:
number
):
number
{
return
this
.
_linesLayout
.
insertWhitespace
(
afterLineNumber
,
ordinal
,
height
);
public
addWhitespace
(
afterLineNumber
:
number
,
ordinal
:
number
,
height
:
number
,
minWidth
:
number
):
number
{
return
this
.
_linesLayout
.
insertWhitespace
(
afterLineNumber
,
ordinal
,
height
,
minWidth
);
}
public
changeWhitespace
(
id
:
number
,
newAfterLineNumber
:
number
,
newHeight
:
number
):
boolean
{
return
this
.
_linesLayout
.
changeWhitespace
(
id
,
newAfterLineNumber
,
newHeight
);
...
...
src/vs/editor/common/viewLayout/whitespaceComputer.ts
浏览文件 @
dac897f3
...
...
@@ -21,6 +21,11 @@ export class WhitespaceComputer {
*/
private
_heights
:
number
[];
/**
* minWidths[i] is the min width in pixels for whitespace at index i
*/
private
_minWidths
:
number
[];
/**
* afterLineNumbers[i] is the line number whitespace at index i is after
*/
...
...
@@ -58,8 +63,11 @@ export class WhitespaceComputer {
*/
private
_lastWhitespaceId
:
number
;
private
_minWidth
:
number
;
constructor
()
{
this
.
_heights
=
[];
this
.
_minWidths
=
[];
this
.
_ids
=
[];
this
.
_afterLineNumbers
=
[];
this
.
_ordinals
=
[];
...
...
@@ -67,6 +75,7 @@ export class WhitespaceComputer {
this
.
_prefixSumValidIndex
=
-
1
;
this
.
_whitespaceId2Index
=
{};
this
.
_lastWhitespaceId
=
0
;
this
.
_minWidth
=
-
1
;
/* marker for not being computed */
}
/**
...
...
@@ -105,25 +114,29 @@ export class WhitespaceComputer {
* @param heightInPx The height of the whitespace, in pixels.
* @return An id that can be used later to mutate or delete the whitespace
*/
public
insertWhitespace
(
afterLineNumber
:
number
,
ordinal
:
number
,
heightInPx
:
number
):
number
{
public
insertWhitespace
(
afterLineNumber
:
number
,
ordinal
:
number
,
heightInPx
:
number
,
minWidth
:
number
):
number
{
afterLineNumber
=
afterLineNumber
|
0
;
ordinal
=
ordinal
|
0
;
heightInPx
=
heightInPx
|
0
;
minWidth
=
minWidth
|
0
;
let
id
=
(
++
this
.
_lastWhitespaceId
);
let
insertionIndex
=
WhitespaceComputer
.
findInsertionIndex
(
this
.
_afterLineNumbers
,
afterLineNumber
,
this
.
_ordinals
,
ordinal
);
this
.
_insertWhitespaceAtIndex
(
id
,
insertionIndex
,
afterLineNumber
,
ordinal
,
heightInPx
);
this
.
_insertWhitespaceAtIndex
(
id
,
insertionIndex
,
afterLineNumber
,
ordinal
,
heightInPx
,
minWidth
);
this
.
_minWidth
=
-
1
;
/* marker for not being computed */
return
id
;
}
private
_insertWhitespaceAtIndex
(
id
:
number
,
insertIndex
:
number
,
afterLineNumber
:
number
,
ordinal
:
number
,
heightInPx
:
number
):
void
{
private
_insertWhitespaceAtIndex
(
id
:
number
,
insertIndex
:
number
,
afterLineNumber
:
number
,
ordinal
:
number
,
heightInPx
:
number
,
minWidth
:
number
):
void
{
id
=
id
|
0
;
insertIndex
=
insertIndex
|
0
;
afterLineNumber
=
afterLineNumber
|
0
;
ordinal
=
ordinal
|
0
;
heightInPx
=
heightInPx
|
0
;
minWidth
=
minWidth
|
0
;
this
.
_heights
.
splice
(
insertIndex
,
0
,
heightInPx
);
this
.
_minWidths
.
splice
(
insertIndex
,
0
,
minWidth
);
this
.
_ids
.
splice
(
insertIndex
,
0
,
id
);
this
.
_afterLineNumbers
.
splice
(
insertIndex
,
0
,
afterLineNumber
);
this
.
_ordinals
.
splice
(
insertIndex
,
0
,
ordinal
);
...
...
@@ -202,12 +215,15 @@ export class WhitespaceComputer {
// Record old height
let
heightInPx
=
this
.
_heights
[
index
];
// Record old min width
let
minWidth
=
this
.
_minWidths
[
index
];
// Since changing `afterLineNumber` can trigger a reordering, we're gonna remove this whitespace
this
.
removeWhitespace
(
id
);
// And add it again
let
insertionIndex
=
WhitespaceComputer
.
findInsertionIndex
(
this
.
_afterLineNumbers
,
newAfterLineNumber
,
this
.
_ordinals
,
ordinal
);
this
.
_insertWhitespaceAtIndex
(
id
,
insertionIndex
,
newAfterLineNumber
,
ordinal
,
heightInPx
);
this
.
_insertWhitespaceAtIndex
(
id
,
insertionIndex
,
newAfterLineNumber
,
ordinal
,
heightInPx
,
minWidth
);
return
true
;
}
...
...
@@ -230,6 +246,7 @@ export class WhitespaceComputer {
let
index
=
this
.
_whitespaceId2Index
[
sid
];
delete
this
.
_whitespaceId2Index
[
sid
];
this
.
_removeWhitespaceAtIndex
(
index
);
this
.
_minWidth
=
-
1
;
/* marker for not being computed */
return
true
;
}
...
...
@@ -240,6 +257,7 @@ export class WhitespaceComputer {
removeIndex
=
removeIndex
|
0
;
this
.
_heights
.
splice
(
removeIndex
,
1
);
this
.
_minWidths
.
splice
(
removeIndex
,
1
);
this
.
_ids
.
splice
(
removeIndex
,
1
);
this
.
_afterLineNumbers
.
splice
(
removeIndex
,
1
);
this
.
_ordinals
.
splice
(
removeIndex
,
1
);
...
...
@@ -410,6 +428,20 @@ export class WhitespaceComputer {
return
this
.
_heights
.
length
;
}
/**
* The maximum min width for all whitespaces.
*/
public
getMinWidth
():
number
{
if
(
this
.
_minWidth
===
-
1
)
{
let
minWidth
=
0
;
for
(
let
i
=
0
,
len
=
this
.
_minWidths
.
length
;
i
<
len
;
i
++
)
{
minWidth
=
Math
.
max
(
minWidth
,
this
.
_minWidths
[
i
]);
}
this
.
_minWidth
=
minWidth
;
}
return
this
.
_minWidth
;
}
/**
* Get the `afterLineNumber` for whitespace at index `index`.
*
...
...
src/vs/editor/common/viewModel/viewModel.ts
浏览文件 @
dac897f3
...
...
@@ -75,7 +75,7 @@ export interface IViewLayout {
* Reserve rendering space.
* @return an identifier that can be later used to remove or change the whitespace.
*/
addWhitespace
(
afterLineNumber
:
number
,
ordinal
:
number
,
height
:
number
):
number
;
addWhitespace
(
afterLineNumber
:
number
,
ordinal
:
number
,
height
:
number
,
minWidth
:
number
):
number
;
/**
* Change the properties of a whitespace.
*/
...
...
src/vs/editor/test/common/viewLayout/linesLayout.test.ts
浏览文件 @
dac897f3
...
...
@@ -41,7 +41,7 @@ suite('Editor ViewLayout - LinesLayout', () => {
assert
.
equal
(
linesLayout
.
getLineNumberAtOrAfterVerticalOffset
(
29
),
3
);
// Add whitespace of height 5px after 2nd line
linesLayout
.
insertWhitespace
(
2
,
0
,
5
);
linesLayout
.
insertWhitespace
(
2
,
0
,
5
,
0
);
// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
// whitespace: a(2,5)
assert
.
equal
(
linesLayout
.
getLinesTotalHeight
(),
105
);
...
...
@@ -65,8 +65,8 @@ suite('Editor ViewLayout - LinesLayout', () => {
assert
.
equal
(
linesLayout
.
getLineNumberAtOrAfterVerticalOffset
(
105
),
10
);
// Add two more whitespaces of height 5px
linesLayout
.
insertWhitespace
(
3
,
0
,
5
);
linesLayout
.
insertWhitespace
(
4
,
0
,
5
);
linesLayout
.
insertWhitespace
(
3
,
0
,
5
,
0
);
linesLayout
.
insertWhitespace
(
4
,
0
,
5
,
0
);
// lines: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
// whitespace: a(2,5), b(3, 5), c(4, 5)
assert
.
equal
(
linesLayout
.
getLinesTotalHeight
(),
115
);
...
...
@@ -122,7 +122,7 @@ suite('Editor ViewLayout - LinesLayout', () => {
// Start off with 10 lines and one whitespace after line 2, of height 5
var
linesLayout
=
new
LinesLayout
(
10
,
1
);
var
a
=
linesLayout
.
insertWhitespace
(
2
,
0
,
5
);
var
a
=
linesLayout
.
insertWhitespace
(
2
,
0
,
5
,
0
);
// 10 lines
// whitespace: - a(2,5)
...
...
@@ -218,7 +218,7 @@ suite('Editor ViewLayout - LinesLayout', () => {
test
(
'
LinesLayout getLineNumberAtOrAfterVerticalOffset
'
,
()
=>
{
var
linesLayout
=
new
LinesLayout
(
10
,
1
);
linesLayout
.
insertWhitespace
(
6
,
0
,
10
);
linesLayout
.
insertWhitespace
(
6
,
0
,
10
,
0
);
// 10 lines
// whitespace: - a(6,10)
...
...
@@ -267,7 +267,7 @@ suite('Editor ViewLayout - LinesLayout', () => {
test
(
'
LinesLayout getCenteredLineInViewport
'
,
()
=>
{
var
linesLayout
=
new
LinesLayout
(
10
,
1
);
linesLayout
.
insertWhitespace
(
6
,
0
,
10
);
linesLayout
.
insertWhitespace
(
6
,
0
,
10
,
0
);
// 10 lines
// whitespace: - a(6,10)
...
...
@@ -350,7 +350,7 @@ suite('Editor ViewLayout - LinesLayout', () => {
test
(
'
LinesLayout getLinesViewportData 1
'
,
()
=>
{
var
linesLayout
=
new
LinesLayout
(
10
,
10
);
linesLayout
.
insertWhitespace
(
6
,
0
,
100
);
linesLayout
.
insertWhitespace
(
6
,
0
,
100
,
0
);
// 10 lines
// whitespace: - a(6,100)
...
...
@@ -484,8 +484,8 @@ suite('Editor ViewLayout - LinesLayout', () => {
test
(
'
LinesLayout getLinesViewportData 2 & getWhitespaceViewportData
'
,
()
=>
{
var
linesLayout
=
new
LinesLayout
(
10
,
10
);
var
a
=
linesLayout
.
insertWhitespace
(
6
,
0
,
100
);
var
b
=
linesLayout
.
insertWhitespace
(
7
,
0
,
50
);
var
a
=
linesLayout
.
insertWhitespace
(
6
,
0
,
100
,
0
);
var
b
=
linesLayout
.
insertWhitespace
(
7
,
0
,
50
,
0
);
// 10 lines
// whitespace: - a(6,100), b(7, 50)
...
...
@@ -555,8 +555,8 @@ suite('Editor ViewLayout - LinesLayout', () => {
test
(
'
LinesLayout getWhitespaceAtVerticalOffset
'
,
()
=>
{
var
linesLayout
=
new
LinesLayout
(
10
,
10
);
var
a
=
linesLayout
.
insertWhitespace
(
6
,
0
,
100
);
var
b
=
linesLayout
.
insertWhitespace
(
7
,
0
,
50
);
var
a
=
linesLayout
.
insertWhitespace
(
6
,
0
,
100
,
0
);
var
b
=
linesLayout
.
insertWhitespace
(
7
,
0
,
50
,
0
);
var
whitespace
=
linesLayout
.
getWhitespaceAtVerticalOffset
(
0
);
assert
.
equal
(
whitespace
,
null
);
...
...
src/vs/editor/test/common/viewLayout/whitespaceComputer.test.ts
浏览文件 @
dac897f3
...
...
@@ -14,7 +14,7 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
var
whitespaceComputer
=
new
WhitespaceComputer
();
// Insert a whitespace after line number 2, of height 10
var
a
=
whitespaceComputer
.
insertWhitespace
(
2
,
0
,
10
);
var
a
=
whitespaceComputer
.
insertWhitespace
(
2
,
0
,
10
,
0
);
// whitespaces: a(2, 10)
assert
.
equal
(
whitespaceComputer
.
getCount
(),
1
);
assert
.
equal
(
whitespaceComputer
.
getAfterLineNumberForWhitespaceIndex
(
0
),
2
);
...
...
@@ -27,7 +27,7 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
assert
.
equal
(
whitespaceComputer
.
getAccumulatedHeightBeforeLineNumber
(
4
),
10
);
// Insert a whitespace again after line number 2, of height 20
var
b
=
whitespaceComputer
.
insertWhitespace
(
2
,
0
,
20
);
var
b
=
whitespaceComputer
.
insertWhitespace
(
2
,
0
,
20
,
0
);
// whitespaces: a(2, 10), b(2, 20)
assert
.
equal
(
whitespaceComputer
.
getCount
(),
2
);
assert
.
equal
(
whitespaceComputer
.
getAfterLineNumberForWhitespaceIndex
(
0
),
2
);
...
...
@@ -72,7 +72,7 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
assert
.
equal
(
whitespaceComputer
.
getAccumulatedHeightBeforeLineNumber
(
4
),
10
);
// Add a whitespace before the first line of height 50
b
=
whitespaceComputer
.
insertWhitespace
(
0
,
0
,
50
);
b
=
whitespaceComputer
.
insertWhitespace
(
0
,
0
,
50
,
0
);
// whitespaces: b(0, 50), a(2, 10)
assert
.
equal
(
whitespaceComputer
.
getCount
(),
2
);
assert
.
equal
(
whitespaceComputer
.
getAfterLineNumberForWhitespaceIndex
(
0
),
0
);
...
...
@@ -88,7 +88,7 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
assert
.
equal
(
whitespaceComputer
.
getAccumulatedHeightBeforeLineNumber
(
4
),
60
);
// Add a whitespace after line 4 of height 20
whitespaceComputer
.
insertWhitespace
(
4
,
0
,
20
);
whitespaceComputer
.
insertWhitespace
(
4
,
0
,
20
,
0
);
// whitespaces: b(0, 50), a(2, 10), c(4, 20)
assert
.
equal
(
whitespaceComputer
.
getCount
(),
3
);
assert
.
equal
(
whitespaceComputer
.
getAfterLineNumberForWhitespaceIndex
(
0
),
0
);
...
...
@@ -108,7 +108,7 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
assert
.
equal
(
whitespaceComputer
.
getAccumulatedHeightBeforeLineNumber
(
5
),
80
);
// Add a whitespace after line 3 of height 30
whitespaceComputer
.
insertWhitespace
(
3
,
0
,
30
);
whitespaceComputer
.
insertWhitespace
(
3
,
0
,
30
,
0
);
// whitespaces: b(0, 50), a(2, 10), d(3, 30), c(4, 20)
assert
.
equal
(
whitespaceComputer
.
getCount
(),
4
);
assert
.
equal
(
whitespaceComputer
.
getAfterLineNumberForWhitespaceIndex
(
0
),
0
);
...
...
@@ -379,9 +379,9 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
test
(
'
WhitespaceComputer changeWhitespaceAfterLineNumber & getFirstWhitespaceIndexAfterLineNumber
'
,
()
=>
{
var
whitespaceComputer
=
new
WhitespaceComputer
();
var
a
=
whitespaceComputer
.
insertWhitespace
(
0
,
0
,
1
);
var
b
=
whitespaceComputer
.
insertWhitespace
(
7
,
0
,
1
);
var
c
=
whitespaceComputer
.
insertWhitespace
(
3
,
0
,
1
);
var
a
=
whitespaceComputer
.
insertWhitespace
(
0
,
0
,
1
,
0
);
var
b
=
whitespaceComputer
.
insertWhitespace
(
7
,
0
,
1
,
0
);
var
c
=
whitespaceComputer
.
insertWhitespace
(
3
,
0
,
1
,
0
);
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
0
),
a
);
// 0
assert
.
equal
(
whitespaceComputer
.
getAfterLineNumberForWhitespaceIndex
(
0
),
0
);
...
...
@@ -504,32 +504,32 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
test
(
'
WhitespaceComputer Bug
'
,
()
=>
{
var
whitespaceComputer
=
new
WhitespaceComputer
();
var
a
=
whitespaceComputer
.
insertWhitespace
(
0
,
0
,
1
);
var
b
=
whitespaceComputer
.
insertWhitespace
(
7
,
0
,
1
);
var
a
=
whitespaceComputer
.
insertWhitespace
(
0
,
0
,
1
,
0
);
var
b
=
whitespaceComputer
.
insertWhitespace
(
7
,
0
,
1
,
0
);
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
0
),
a
);
// 0
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
1
),
b
);
// 7
var
c
=
whitespaceComputer
.
insertWhitespace
(
3
,
0
,
1
);
var
c
=
whitespaceComputer
.
insertWhitespace
(
3
,
0
,
1
,
0
);
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
0
),
a
);
// 0
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
1
),
c
);
// 3
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
2
),
b
);
// 7
var
d
=
whitespaceComputer
.
insertWhitespace
(
2
,
0
,
1
);
var
d
=
whitespaceComputer
.
insertWhitespace
(
2
,
0
,
1
,
0
);
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
0
),
a
);
// 0
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
1
),
d
);
// 2
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
2
),
c
);
// 3
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
3
),
b
);
// 7
var
e
=
whitespaceComputer
.
insertWhitespace
(
8
,
0
,
1
);
var
e
=
whitespaceComputer
.
insertWhitespace
(
8
,
0
,
1
,
0
);
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
0
),
a
);
// 0
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
1
),
d
);
// 2
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
2
),
c
);
// 3
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
3
),
b
);
// 7
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
4
),
e
);
// 8
var
f
=
whitespaceComputer
.
insertWhitespace
(
11
,
0
,
1
);
var
f
=
whitespaceComputer
.
insertWhitespace
(
11
,
0
,
1
,
0
);
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
0
),
a
);
// 0
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
1
),
d
);
// 2
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
2
),
c
);
// 3
...
...
@@ -537,7 +537,7 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
4
),
e
);
// 8
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
5
),
f
);
// 11
var
g
=
whitespaceComputer
.
insertWhitespace
(
10
,
0
,
1
);
var
g
=
whitespaceComputer
.
insertWhitespace
(
10
,
0
,
1
,
0
);
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
0
),
a
);
// 0
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
1
),
d
);
// 2
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
2
),
c
);
// 3
...
...
@@ -546,7 +546,7 @@ suite('Editor ViewLayout - WhitespaceComputer', () => {
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
5
),
g
);
// 10
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
6
),
f
);
// 11
var
h
=
whitespaceComputer
.
insertWhitespace
(
0
,
0
,
1
);
var
h
=
whitespaceComputer
.
insertWhitespace
(
0
,
0
,
1
,
0
);
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
0
),
a
);
// 0
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
1
),
h
);
// 0
assert
.
equal
(
whitespaceComputer
.
getIdForWhitespaceIndex
(
2
),
d
);
// 2
...
...
src/vs/monaco.d.ts
浏览文件 @
dac897f3
...
...
@@ -3340,6 +3340,11 @@ declare namespace monaco.editor {
* If neither `heightInPx` nor `heightInLines` is specified, a default of `heightInLines` = 1 will be chosen.
*/
heightInPx
?:
number
;
/**
* The minimum width in px of the view zone.
* If this is set, the editor will ensure that the scroll width is >= than this value.
*/
minWidthInPx
?:
number
;
/**
* The dom node of the view zone
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录