Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
9c0ac421
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,发现更多精彩内容 >>
未验证
提交
9c0ac421
编写于
11月 15, 2019
作者:
A
Alexandru Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid allocating for getWhitespaces() call
上级
4e8f4249
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
53 addition
and
61 deletion
+53
-61
src/vs/editor/browser/editorBrowser.ts
src/vs/editor/browser/editorBrowser.ts
+2
-2
src/vs/editor/browser/viewParts/viewZones/viewZones.ts
src/vs/editor/browser/viewParts/viewZones/viewZones.ts
+3
-3
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+2
-2
src/vs/editor/browser/widget/diffEditorWidget.ts
src/vs/editor/browser/widget/diffEditorWidget.ts
+24
-20
src/vs/editor/common/viewLayout/linesLayout.ts
src/vs/editor/common/viewLayout/linesLayout.ts
+15
-27
src/vs/editor/common/viewLayout/viewLayout.ts
src/vs/editor/common/viewLayout/viewLayout.ts
+2
-2
src/vs/editor/common/viewModel/viewModel.ts
src/vs/editor/common/viewModel/viewModel.ts
+2
-2
src/vs/editor/test/common/viewLayout/linesLayout.test.ts
src/vs/editor/test/common/viewLayout/linesLayout.test.ts
+3
-3
未找到文件。
src/vs/editor/browser/editorBrowser.ts
浏览文件 @
9c0ac421
...
...
@@ -16,7 +16,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
{
IIdentifiedSingleEditOperation
,
IModelDecoration
,
IModelDeltaDecoration
,
ITextModel
,
ICursorStateComputer
}
from
'
vs/editor/common/model
'
;
import
{
IModelContentChangedEvent
,
IModelDecorationsChangedEvent
,
IModelLanguageChangedEvent
,
IModelLanguageConfigurationChangedEvent
,
IModelOptionsChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
OverviewRulerZone
}
from
'
vs/editor/common/view/overviewZoneManager
'
;
import
{
EditorWhitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
I
EditorWhitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IDiffComputationResult
}
from
'
vs/editor/common/services/editorWorkerService
'
;
...
...
@@ -672,7 +672,7 @@ export interface ICodeEditor extends editorCommon.IEditor {
* Get the view zones.
* @internal
*/
getWhitespaces
():
EditorWhitespace
[];
getWhitespaces
():
I
EditorWhitespace
[];
/**
* Get the vertical position (top offset) for the line w.r.t. to the first line.
...
...
src/vs/editor/browser/viewParts/viewZones/viewZones.ts
浏览文件 @
9c0ac421
...
...
@@ -13,7 +13,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
{
IViewWhitespaceViewportData
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IWhitespaceChangeAccessor
,
EditorWhitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
IWhitespaceChangeAccessor
,
I
EditorWhitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
export
interface
IMyViewZone
{
whitespaceId
:
string
;
...
...
@@ -75,7 +75,7 @@ export class ViewZones extends ViewPart {
private
_recomputeWhitespacesProps
():
boolean
{
const
whitespaces
=
this
.
_context
.
viewLayout
.
getWhitespaces
();
const
oldWhitespaces
=
new
Map
<
string
,
EditorWhitespace
>
();
const
oldWhitespaces
=
new
Map
<
string
,
I
EditorWhitespace
>
();
for
(
const
whitespace
of
whitespaces
)
{
oldWhitespaces
.
set
(
whitespace
.
id
,
whitespace
);
}
...
...
@@ -88,7 +88,7 @@ export class ViewZones extends ViewPart {
const
zone
=
this
.
_zones
[
id
];
const
props
=
this
.
_computeWhitespaceProps
(
zone
.
delegate
);
const
oldWhitespace
=
oldWhitespaces
.
get
(
id
);
if
(
oldWhitespace
&&
(
oldWhitespace
.
afterLineNumber
!==
props
.
afterViewLineNumber
||
oldWhitespace
.
height
InPx
!==
props
.
heightInPx
))
{
if
(
oldWhitespace
&&
(
oldWhitespace
.
afterLineNumber
!==
props
.
afterViewLineNumber
||
oldWhitespace
.
height
!==
props
.
heightInPx
))
{
whitespaceAccessor
.
changeOneWhitespace
(
id
,
props
.
afterViewLineNumber
,
props
.
heightInPx
);
this
.
_safeCallOnComputedHeight
(
zone
.
delegate
,
props
.
heightInPx
);
hadAChange
=
true
;
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
9c0ac421
...
...
@@ -40,7 +40,7 @@ import * as modes from 'vs/editor/common/modes';
import
{
editorUnnecessaryCodeBorder
,
editorUnnecessaryCodeOpacity
}
from
'
vs/editor/common/view/editorColorRegistry
'
;
import
{
editorErrorBorder
,
editorErrorForeground
,
editorHintBorder
,
editorHintForeground
,
editorInfoBorder
,
editorInfoForeground
,
editorWarningBorder
,
editorWarningForeground
,
editorForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
VerticalRevealType
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
EditorWhitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
I
EditorWhitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
ViewModel
}
from
'
vs/editor/common/viewModel/viewModelImpl
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
@@ -451,7 +451,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
return
this
.
_modelData
.
viewModel
.
getVisibleRanges
();
}
public
getWhitespaces
():
EditorWhitespace
[]
{
public
getWhitespaces
():
I
EditorWhitespace
[]
{
if
(
!
this
.
_modelData
)
{
return
[];
}
...
...
src/vs/editor/browser/widget/diffEditorWidget.ts
浏览文件 @
9c0ac421
...
...
@@ -32,7 +32,7 @@ import { IDiffComputationResult, IEditorWorkerService } from 'vs/editor/common/s
import
{
OverviewRulerZone
}
from
'
vs/editor/common/view/overviewZoneManager
'
;
import
{
LineDecoration
}
from
'
vs/editor/common/viewLayout/lineDecorations
'
;
import
{
RenderLineInput
,
renderViewLine
}
from
'
vs/editor/common/viewLayout/viewLineRenderer
'
;
import
{
EditorWhitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
I
EditorWhitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
InlineDecoration
,
InlineDecorationType
,
ViewLineRenderingData
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -68,7 +68,7 @@ interface IEditorsZones {
}
interface
IDiffEditorWidgetStyle
{
getEditorsDiffDecorations
(
lineChanges
:
editorCommon
.
ILineChange
[],
ignoreTrimWhitespace
:
boolean
,
renderIndicators
:
boolean
,
originalWhitespaces
:
EditorWhitespace
[],
modifiedWhitespaces
:
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
):
IEditorsDiffDecorationsWithZones
;
getEditorsDiffDecorations
(
lineChanges
:
editorCommon
.
ILineChange
[],
ignoreTrimWhitespace
:
boolean
,
renderIndicators
:
boolean
,
originalWhitespaces
:
IEditorWhitespace
[],
modifiedWhitespaces
:
I
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
):
IEditorsDiffDecorationsWithZones
;
setEnableSplitViewResizing
(
enableSplitViewResizing
:
boolean
):
void
;
applyColors
(
theme
:
ITheme
):
boolean
;
layout
():
number
;
...
...
@@ -91,7 +91,7 @@ class VisualEditorState {
this
.
_decorations
=
[];
}
public
getForeignViewZones
(
allViewZones
:
EditorWhitespace
[]):
EditorWhitespace
[]
{
public
getForeignViewZones
(
allViewZones
:
IEditorWhitespace
[]):
I
EditorWhitespace
[]
{
return
allViewZones
.
filter
((
z
)
=>
!
this
.
_zonesMap
[
String
(
z
.
id
)]);
}
...
...
@@ -1303,7 +1303,7 @@ abstract class DiffEditorWidgetStyle extends Disposable implements IDiffEditorWi
return
hasChanges
;
}
public
getEditorsDiffDecorations
(
lineChanges
:
editorCommon
.
ILineChange
[],
ignoreTrimWhitespace
:
boolean
,
renderIndicators
:
boolean
,
originalWhitespaces
:
EditorWhitespace
[],
modifiedWhitespaces
:
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
):
IEditorsDiffDecorationsWithZones
{
public
getEditorsDiffDecorations
(
lineChanges
:
editorCommon
.
ILineChange
[],
ignoreTrimWhitespace
:
boolean
,
renderIndicators
:
boolean
,
originalWhitespaces
:
IEditorWhitespace
[],
modifiedWhitespaces
:
I
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
):
IEditorsDiffDecorationsWithZones
{
// Get view zones
modifiedWhitespaces
=
modifiedWhitespaces
.
sort
((
a
,
b
)
=>
{
return
a
.
afterLineNumber
-
b
.
afterLineNumber
;
...
...
@@ -1331,7 +1331,7 @@ abstract class DiffEditorWidgetStyle extends Disposable implements IDiffEditorWi
};
}
protected
abstract
_getViewZones
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
EditorWhitespace
[],
modifiedForeignVZ
:
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
,
renderIndicators
:
boolean
):
IEditorsZones
;
protected
abstract
_getViewZones
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
IEditorWhitespace
[],
modifiedForeignVZ
:
I
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
,
renderIndicators
:
boolean
):
IEditorsZones
;
protected
abstract
_getOriginalEditorDecorations
(
lineChanges
:
editorCommon
.
ILineChange
[],
ignoreTrimWhitespace
:
boolean
,
renderIndicators
:
boolean
,
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
):
IEditorDiffDecorations
;
protected
abstract
_getModifiedEditorDecorations
(
lineChanges
:
editorCommon
.
ILineChange
[],
ignoreTrimWhitespace
:
boolean
,
renderIndicators
:
boolean
,
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
):
IEditorDiffDecorations
;
...
...
@@ -1352,10 +1352,10 @@ interface IMyViewZone {
class
ForeignViewZonesIterator
{
private
_index
:
number
;
private
readonly
_source
:
EditorWhitespace
[];
public
current
:
EditorWhitespace
|
null
;
private
readonly
_source
:
I
EditorWhitespace
[];
public
current
:
I
EditorWhitespace
|
null
;
constructor
(
source
:
EditorWhitespace
[])
{
constructor
(
source
:
I
EditorWhitespace
[])
{
this
.
_source
=
source
;
this
.
_index
=
-
1
;
this
.
current
=
null
;
...
...
@@ -1375,13 +1375,17 @@ class ForeignViewZonesIterator {
abstract
class
ViewZonesComputer
{
private
readonly
lineChanges
:
editorCommon
.
ILineChange
[];
private
readonly
originalForeignVZ
:
EditorWhitespace
[];
private
readonly
modifiedForeignVZ
:
EditorWhitespace
[];
private
readonly
originalForeignVZ
:
IEditorWhitespace
[];
private
readonly
originalLineHeight
:
number
;
private
readonly
modifiedForeignVZ
:
IEditorWhitespace
[];
private
readonly
modifiedLineHeight
:
number
;
constructor
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
EditorWhitespace
[],
modifiedForeignVZ
:
EditorWhitespace
[]
)
{
constructor
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
IEditorWhitespace
[],
originalLineHeight
:
number
,
modifiedForeignVZ
:
IEditorWhitespace
[],
modifiedLineHeight
:
number
)
{
this
.
lineChanges
=
lineChanges
;
this
.
originalForeignVZ
=
originalForeignVZ
;
this
.
originalLineHeight
=
originalLineHeight
;
this
.
modifiedForeignVZ
=
modifiedForeignVZ
;
this
.
modifiedLineHeight
=
modifiedLineHeight
;
}
public
getViewZones
():
IEditorsZones
{
...
...
@@ -1456,7 +1460,7 @@ abstract class ViewZonesComputer {
stepOriginal
.
push
({
afterLineNumber
:
viewZoneLineNumber
,
heightInLines
:
modifiedForeignVZ
.
current
.
height
InLines
,
heightInLines
:
modifiedForeignVZ
.
current
.
height
/
this
.
modifiedLineHeight
,
domNode
:
null
,
marginDomNode
:
marginDomNode
});
...
...
@@ -1473,7 +1477,7 @@ abstract class ViewZonesComputer {
}
stepModified
.
push
({
afterLineNumber
:
viewZoneLineNumber
,
heightInLines
:
originalForeignVZ
.
current
.
height
InLines
,
heightInLines
:
originalForeignVZ
.
current
.
height
/
this
.
originalLineHeight
,
domNode
:
null
});
originalForeignVZ
.
advance
();
...
...
@@ -1731,8 +1735,8 @@ class DiffEditorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffE
return
this
.
_dataSource
.
getHeight
();
}
protected
_getViewZones
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
EditorWhitespace
[],
modifiedForeignVZ
:
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
):
IEditorsZones
{
let
c
=
new
SideBySideViewZonesComputer
(
lineChanges
,
originalForeignVZ
,
modifiedForeignVZ
);
protected
_getViewZones
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
IEditorWhitespace
[],
modifiedForeignVZ
:
I
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
):
IEditorsZones
{
let
c
=
new
SideBySideViewZonesComputer
(
lineChanges
,
originalForeignVZ
,
originalEditor
.
getOption
(
EditorOption
.
lineHeight
),
modifiedForeignVZ
,
modifiedEditor
.
getOption
(
EditorOption
.
lineHeight
)
);
return
c
.
getViewZones
();
}
...
...
@@ -1859,8 +1863,8 @@ class DiffEditorWidgetSideBySide extends DiffEditorWidgetStyle implements IDiffE
class
SideBySideViewZonesComputer
extends
ViewZonesComputer
{
constructor
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
EditorWhitespace
[],
modifiedForeignVZ
:
EditorWhitespace
[]
)
{
super
(
lineChanges
,
originalForeignVZ
,
modifiedForeignVZ
);
constructor
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
IEditorWhitespace
[],
originalLineHeight
:
number
,
modifiedForeignVZ
:
IEditorWhitespace
[],
modifiedLineHeight
:
number
)
{
super
(
lineChanges
,
originalForeignVZ
,
originalLineHeight
,
modifiedForeignVZ
,
modifiedLineHeight
);
}
protected
_createOriginalMarginDomNodeForModifiedForeignViewZoneInAddedRegion
():
HTMLDivElement
|
null
{
...
...
@@ -1911,7 +1915,7 @@ class DiffEditorWidgetInline extends DiffEditorWidgetStyle implements IDiffEdito
// Nothing to do..
}
protected
_getViewZones
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
EditorWhitespace
[],
modifiedForeignVZ
:
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
,
renderIndicators
:
boolean
):
IEditorsZones
{
protected
_getViewZones
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
IEditorWhitespace
[],
modifiedForeignVZ
:
I
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
,
renderIndicators
:
boolean
):
IEditorsZones
{
let
computer
=
new
InlineViewZonesComputer
(
lineChanges
,
originalForeignVZ
,
modifiedForeignVZ
,
originalEditor
,
modifiedEditor
,
renderIndicators
);
return
computer
.
getViewZones
();
}
...
...
@@ -2019,8 +2023,8 @@ class InlineViewZonesComputer extends ViewZonesComputer {
private
readonly
modifiedEditorTabSize
:
number
;
private
readonly
renderIndicators
:
boolean
;
constructor
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
EditorWhitespace
[],
modifiedForeignVZ
:
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
,
renderIndicators
:
boolean
)
{
super
(
lineChanges
,
originalForeignVZ
,
modifiedForeignVZ
);
constructor
(
lineChanges
:
editorCommon
.
ILineChange
[],
originalForeignVZ
:
IEditorWhitespace
[],
modifiedForeignVZ
:
I
EditorWhitespace
[],
originalEditor
:
editorBrowser
.
ICodeEditor
,
modifiedEditor
:
editorBrowser
.
ICodeEditor
,
renderIndicators
:
boolean
)
{
super
(
lineChanges
,
originalForeignVZ
,
originalEditor
.
getOption
(
EditorOption
.
lineHeight
),
modifiedForeignVZ
,
modifiedEditor
.
getOption
(
EditorOption
.
lineHeight
)
);
this
.
originalModel
=
originalEditor
.
getModel
()
!
;
this
.
modifiedEditorOptions
=
modifiedEditor
.
getOptions
();
this
.
modifiedEditorTabSize
=
modifiedEditor
.
getModel
()
!
.
getOptions
().
tabSize
;
...
...
src/vs/editor/common/viewLayout/linesLayout.ts
浏览文件 @
9c0ac421
...
...
@@ -7,13 +7,10 @@ import { IPartialViewLinesViewportData } from 'vs/editor/common/viewLayout/viewL
import
{
IViewWhitespaceViewportData
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
export
class
EditorWhitespace
{
constructor
(
public
readonly
id
:
string
,
public
readonly
afterLineNumber
:
number
,
public
readonly
heightInPx
:
number
,
public
readonly
heightInLines
:
number
,
)
{
}
export
interface
IEditorWhitespace
{
readonly
id
:
string
;
readonly
afterLineNumber
:
number
;
readonly
height
:
number
;
}
/**
...
...
@@ -30,7 +27,7 @@ interface IPendingRemove { id: string; }
class
PendingChanges
{
private
_hasPending
:
boolean
;
private
_inserts
:
Internal
Whitespace
[];
private
_inserts
:
Editor
Whitespace
[];
private
_changes
:
IPendingChange
[];
private
_removes
:
IPendingRemove
[];
...
...
@@ -41,7 +38,7 @@ class PendingChanges {
this
.
_removes
=
[];
}
public
insert
(
x
:
Internal
Whitespace
):
void
{
public
insert
(
x
:
Editor
Whitespace
):
void
{
this
.
_hasPending
=
true
;
this
.
_inserts
.
push
(
x
);
}
...
...
@@ -78,7 +75,7 @@ class PendingChanges {
}
}
export
class
Internal
Whitespace
{
export
class
EditorWhitespace
implements
IEditor
Whitespace
{
public
id
:
string
;
public
afterLineNumber
:
number
;
public
ordinal
:
number
;
...
...
@@ -110,7 +107,7 @@ export class LinesLayout {
private
_pendingChanges
:
PendingChanges
;
private
readonly
_arr
:
Internal
Whitespace
[];
private
readonly
_arr
:
Editor
Whitespace
[];
/**
* _arr[i].prefixSum, 1 <= i <= prefixSumValidIndex can be trusted
...
...
@@ -158,7 +155,7 @@ export class LinesLayout {
* Find the insertion index for a new value inside a sorted array of values.
* If the value is already present in the sorted array, the insertion index will be after the already existing value.
*/
public
static
findInsertionIndex
(
arr
:
Internal
Whitespace
[],
afterLineNumber
:
number
,
ordinal
:
number
):
number
{
public
static
findInsertionIndex
(
arr
:
Editor
Whitespace
[],
afterLineNumber
:
number
,
ordinal
:
number
):
number
{
let
low
=
0
;
let
high
=
arr
.
length
;
...
...
@@ -209,7 +206,7 @@ export class LinesLayout {
minWidth
=
minWidth
|
0
;
const
id
=
this
.
_instanceId
+
(
++
this
.
_lastWhitespaceId
);
this
.
_pendingChanges
.
insert
(
new
Internal
Whitespace
(
id
,
afterLineNumber
,
ordinal
,
heightInPx
,
minWidth
));
this
.
_pendingChanges
.
insert
(
new
Editor
Whitespace
(
id
,
afterLineNumber
,
ordinal
,
heightInPx
,
minWidth
));
return
id
;
// return this._insertWhitespace(afterLineNumber, ordinal, heightInPx, minWidth);
},
...
...
@@ -231,7 +228,7 @@ export class LinesLayout {
}
}
public
_commitPendingChanges
(
inserts
:
Internal
Whitespace
[],
changes
:
IPendingChange
[],
removes
:
IPendingRemove
[]):
void
{
public
_commitPendingChanges
(
inserts
:
Editor
Whitespace
[],
changes
:
IPendingChange
[],
removes
:
IPendingRemove
[]):
void
{
// const magnitude = inserts.length + changes.length + removes.length;
// if (magnitude === 1) {
// // when only one thing
...
...
@@ -257,13 +254,13 @@ export class LinesLayout {
}
}
private
_insertWhitespace
(
whitespace
:
Internal
Whitespace
):
void
{
private
_insertWhitespace
(
whitespace
:
Editor
Whitespace
):
void
{
const
insertionIndex
=
LinesLayout
.
findInsertionIndex
(
this
.
_arr
,
whitespace
.
afterLineNumber
,
whitespace
.
ordinal
);
this
.
_insertWhitespaceAtIndex
(
insertionIndex
,
whitespace
);
this
.
_minWidth
=
-
1
;
/* marker for not being computed */
}
private
_insertWhitespaceAtIndex
(
insertIndex
:
number
,
whitespace
:
Internal
Whitespace
):
void
{
private
_insertWhitespaceAtIndex
(
insertIndex
:
number
,
whitespace
:
Editor
Whitespace
):
void
{
this
.
_arr
.
splice
(
insertIndex
,
0
,
whitespace
);
const
keys
=
Object
.
keys
(
this
.
_whitespaceId2Index
);
...
...
@@ -853,18 +850,9 @@ export class LinesLayout {
/**
* Get all whitespaces.
*/
public
getWhitespaces
():
EditorWhitespace
[]
{
public
getWhitespaces
():
I
EditorWhitespace
[]
{
this
.
_checkPendingChanges
();
let
result
:
EditorWhitespace
[]
=
[];
for
(
let
i
=
0
;
i
<
this
.
_arr
.
length
;
i
++
)
{
result
.
push
(
new
EditorWhitespace
(
this
.
_arr
[
i
].
id
,
this
.
_arr
[
i
].
afterLineNumber
,
this
.
_arr
[
i
].
height
,
this
.
_arr
[
i
].
height
/
this
.
_lineHeight
));
}
return
result
;
return
this
.
_arr
.
slice
(
0
);
}
/**
...
...
src/vs/editor/common/viewLayout/viewLayout.ts
浏览文件 @
9c0ac421
...
...
@@ -8,7 +8,7 @@ import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import
{
IScrollPosition
,
ScrollEvent
,
Scrollable
,
ScrollbarVisibility
}
from
'
vs/base/common/scrollable
'
;
import
{
ConfigurationChangedEvent
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
LinesLayout
,
EditorWhitespace
,
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
LinesLayout
,
I
EditorWhitespace
,
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
IPartialViewLinesViewportData
}
from
'
vs/editor/common/viewLayout/viewLinesViewportData
'
;
import
{
IViewLayout
,
IViewWhitespaceViewportData
,
Viewport
}
from
'
vs/editor/common/viewModel/viewModel
'
;
...
...
@@ -228,7 +228,7 @@ export class ViewLayout extends Disposable implements IViewLayout {
const
visibleBox
=
this
.
getCurrentViewport
();
return
this
.
_linesLayout
.
getWhitespaceViewportData
(
visibleBox
.
top
,
visibleBox
.
top
+
visibleBox
.
height
);
}
public
getWhitespaces
():
EditorWhitespace
[]
{
public
getWhitespaces
():
I
EditorWhitespace
[]
{
return
this
.
_linesLayout
.
getWhitespaces
();
}
...
...
src/vs/editor/common/viewModel/viewModel.ts
浏览文件 @
9c0ac421
...
...
@@ -13,7 +13,7 @@ import { INewScrollPosition } from 'vs/editor/common/editorCommon';
import
{
EndOfLinePreference
,
IActiveIndentGuideInfo
,
IModelDecorationOptions
,
TextModelResolvedOptions
}
from
'
vs/editor/common/model
'
;
import
{
IViewEventListener
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
IPartialViewLinesViewportData
}
from
'
vs/editor/common/viewLayout/viewLinesViewportData
'
;
import
{
EditorWhitespace
,
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
I
EditorWhitespace
,
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
ITheme
}
from
'
vs/platform/theme/common/themeService
'
;
export
interface
IViewWhitespaceViewportData
{
...
...
@@ -61,7 +61,7 @@ export interface IViewLayout {
getLinesViewportData
():
IPartialViewLinesViewportData
;
getLinesViewportDataAtScrollTop
(
scrollTop
:
number
):
IPartialViewLinesViewportData
;
getWhitespaces
():
EditorWhitespace
[];
getWhitespaces
():
I
EditorWhitespace
[];
isAfterLines
(
verticalOffset
:
number
):
boolean
;
getLineNumberAtVerticalOffset
(
verticalOffset
:
number
):
number
;
...
...
src/vs/editor/test/common/viewLayout/linesLayout.test.ts
浏览文件 @
9c0ac421
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
LinesLayout
,
Internal
Whitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
LinesLayout
,
Editor
Whitespace
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
suite
(
'
Editor ViewLayout - LinesLayout
'
,
()
=>
{
...
...
@@ -846,10 +846,10 @@ suite('Editor ViewLayout - LinesLayout', () => {
test
(
'
LinesLayout findInsertionIndex
'
,
()
=>
{
const
makeInternalWhitespace
=
(
afterLineNumbers
:
number
[],
ordinal
:
number
=
0
)
=>
{
return
afterLineNumbers
.
map
((
afterLineNumber
)
=>
new
Internal
Whitespace
(
''
,
afterLineNumber
,
ordinal
,
0
,
0
));
return
afterLineNumbers
.
map
((
afterLineNumber
)
=>
new
Editor
Whitespace
(
''
,
afterLineNumber
,
ordinal
,
0
,
0
));
};
let
arr
:
Internal
Whitespace
[];
let
arr
:
Editor
Whitespace
[];
arr
=
makeInternalWhitespace
([]);
assert
.
equal
(
LinesLayout
.
findInsertionIndex
(
arr
,
0
,
0
),
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录