Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
faea8dc0
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,发现更多精彩内容 >>
未验证
提交
faea8dc0
编写于
1月 07, 2020
作者:
A
Alexandru Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce memory usage for SplitLines
上级
3fbc4687
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
108 deletion
+80
-108
src/vs/editor/common/viewModel/characterHardWrappingLineMapper.ts
...ditor/common/viewModel/characterHardWrappingLineMapper.ts
+4
-59
src/vs/editor/common/viewModel/splitLinesCollection.ts
src/vs/editor/common/viewModel/splitLinesCollection.ts
+67
-40
src/vs/editor/test/common/viewModel/characterHardWrappingLineMapper.test.ts
.../common/viewModel/characterHardWrappingLineMapper.test.ts
+5
-5
src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts
...editor/test/common/viewModel/splitLinesCollection.test.ts
+4
-4
未找到文件。
src/vs/editor/common/viewModel/characterHardWrappingLineMapper.ts
浏览文件 @
faea8dc0
...
@@ -7,7 +7,7 @@ import { CharCode } from 'vs/base/common/charCode';
...
@@ -7,7 +7,7 @@ import { CharCode } from 'vs/base/common/charCode';
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
WrappingIndent
,
IComputedEditorOptions
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
WrappingIndent
,
IComputedEditorOptions
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CharacterClassifier
}
from
'
vs/editor/common/core/characterClassifier
'
;
import
{
CharacterClassifier
}
from
'
vs/editor/common/core/characterClassifier
'
;
import
{
ILineMapperFactory
,
ILineMapping
,
OutputPosition
,
ILineMappingComputer
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
ILineMapperFactory
,
LineBreakingData
,
ILineMappingComputer
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
const
enum
CharacterClass
{
const
enum
CharacterClass
{
NONE
=
0
,
NONE
=
0
,
...
@@ -85,7 +85,7 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
...
@@ -85,7 +85,7 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
requests
.
push
(
lineText
);
requests
.
push
(
lineText
);
},
},
finalize
:
()
=>
{
finalize
:
()
=>
{
let
result
:
(
ILineMapping
|
null
)[]
=
[];
let
result
:
(
LineBreakingData
|
null
)[]
=
[];
for
(
let
i
=
0
,
len
=
requests
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
requests
.
length
;
i
<
len
;
i
++
)
{
result
[
i
]
=
this
.
_createLineMapping
(
requests
[
i
],
tabSize
,
wrappingColumn
,
columnsForFullWidthChar
,
wrappingIndent
);
result
[
i
]
=
this
.
_createLineMapping
(
requests
[
i
],
tabSize
,
wrappingColumn
,
columnsForFullWidthChar
,
wrappingIndent
);
}
}
...
@@ -94,7 +94,7 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
...
@@ -94,7 +94,7 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
};
};
}
}
private
_createLineMapping
(
lineText
:
string
,
tabSize
:
number
,
breakingColumn
:
number
,
columnsForFullWidthChar
:
number
,
hardWrappingIndent
:
WrappingIndent
):
ILineMapping
|
null
{
private
_createLineMapping
(
lineText
:
string
,
tabSize
:
number
,
breakingColumn
:
number
,
columnsForFullWidthChar
:
number
,
hardWrappingIndent
:
WrappingIndent
):
LineBreakingData
|
null
{
if
(
breakingColumn
===
-
1
)
{
if
(
breakingColumn
===
-
1
)
{
return
null
;
return
null
;
}
}
...
@@ -233,61 +233,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
...
@@ -233,61 +233,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
// Add last segment
// Add last segment
breakingOffsets
[
breakingOffsetsIndex
++
]
=
len
;
breakingOffsets
[
breakingOffsetsIndex
++
]
=
len
;
return
new
CharacterHardWrappingLineMapping
(
breakingOffsets
,
wrappedTextIndent
);
return
new
LineBreakingData
(
breakingOffsets
,
wrappedTextIndent
);
}
}
export
class
CharacterHardWrappingLineMapping
implements
ILineMapping
{
private
readonly
_breakingOffsets
:
number
[];
private
readonly
_wrappedLinesIndent
:
string
;
constructor
(
breakingOffsets
:
number
[],
wrappedLinesIndent
:
string
)
{
this
.
_breakingOffsets
=
breakingOffsets
;
this
.
_wrappedLinesIndent
=
wrappedLinesIndent
;
}
public
getOutputLineCount
():
number
{
return
this
.
_breakingOffsets
.
length
;
}
public
getWrappedLinesIndent
():
string
{
return
this
.
_wrappedLinesIndent
;
}
public
getInputOffsetOfOutputPosition
(
outputLineIndex
:
number
,
outputOffset
:
number
):
number
{
if
(
outputLineIndex
===
0
)
{
return
outputOffset
;
}
else
{
return
this
.
_breakingOffsets
[
outputLineIndex
-
1
]
+
outputOffset
;
}
}
public
getOutputPositionOfInputOffset
(
inputOffset
:
number
):
OutputPosition
{
inputOffset
=
inputOffset
|
0
;
//@perf
const
breakingOffsets
=
this
.
_breakingOffsets
;
let
low
=
0
;
let
high
=
breakingOffsets
.
length
-
1
;
let
mid
=
0
;
let
midStop
=
0
;
let
midStart
=
0
;
while
(
low
<=
high
)
{
mid
=
low
+
((
high
-
low
)
/
2
)
|
0
;
midStop
=
breakingOffsets
[
mid
];
midStart
=
mid
>
0
?
breakingOffsets
[
mid
-
1
]
:
0
;
if
(
inputOffset
<
midStart
)
{
high
=
mid
-
1
;
}
else
if
(
inputOffset
>=
midStop
)
{
low
=
mid
+
1
;
}
else
{
break
;
}
}
return
new
OutputPosition
(
mid
,
inputOffset
-
midStart
);
}
}
}
}
src/vs/editor/common/viewModel/splitLinesCollection.ts
浏览文件 @
faea8dc0
...
@@ -16,7 +16,6 @@ import { ITheme } from 'vs/platform/theme/common/themeService';
...
@@ -16,7 +16,6 @@ import { ITheme } from 'vs/platform/theme/common/themeService';
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
class
OutputPosition
{
export
class
OutputPosition
{
_outputPositionBrand
:
void
;
outputLineIndex
:
number
;
outputLineIndex
:
number
;
outputOffset
:
number
;
outputOffset
:
number
;
...
@@ -26,16 +25,49 @@ export class OutputPosition {
...
@@ -26,16 +25,49 @@ export class OutputPosition {
}
}
}
}
export
interface
ILineMapping
{
export
class
LineBreakingData
{
getOutputLineCount
():
number
;
constructor
(
getWrappedLinesIndent
():
string
;
public
readonly
breakOffsets
:
number
[],
getInputOffsetOfOutputPosition
(
outputLineIndex
:
number
,
outputOffset
:
number
):
number
;
public
readonly
wrappedLinesIndent
:
string
getOutputPositionOfInputOffset
(
inputOffset
:
number
):
OutputPosition
;
)
{
}
public
static
getInputOffsetOfOutputPosition
(
breakOffsets
:
number
[],
outputLineIndex
:
number
,
outputOffset
:
number
):
number
{
if
(
outputLineIndex
===
0
)
{
return
outputOffset
;
}
else
{
return
breakOffsets
[
outputLineIndex
-
1
]
+
outputOffset
;
}
}
public
static
getOutputPositionOfInputOffset
(
breakOffsets
:
number
[],
inputOffset
:
number
):
OutputPosition
{
let
low
=
0
;
let
high
=
breakOffsets
.
length
-
1
;
let
mid
=
0
;
let
midStop
=
0
;
let
midStart
=
0
;
while
(
low
<=
high
)
{
mid
=
low
+
((
high
-
low
)
/
2
)
|
0
;
midStop
=
breakOffsets
[
mid
];
midStart
=
mid
>
0
?
breakOffsets
[
mid
-
1
]
:
0
;
if
(
inputOffset
<
midStart
)
{
high
=
mid
-
1
;
}
else
if
(
inputOffset
>=
midStop
)
{
low
=
mid
+
1
;
}
else
{
break
;
}
}
return
new
OutputPosition
(
mid
,
inputOffset
-
midStart
);
}
}
}
export
interface
ILineMappingComputer
{
export
interface
ILineMappingComputer
{
addRequest
(
lineText
:
string
):
void
;
addRequest
(
lineText
:
string
):
void
;
finalize
():
(
ILineMapping
|
null
)[];
finalize
():
(
LineBreakingData
|
null
)[];
}
}
export
interface
ILineMapperFactory
{
export
interface
ILineMapperFactory
{
...
@@ -79,8 +111,8 @@ export interface IViewModelLinesCollection extends IDisposable {
...
@@ -79,8 +111,8 @@ export interface IViewModelLinesCollection extends IDisposable {
createLineMappingComputer
():
ILineMappingComputer
;
createLineMappingComputer
():
ILineMappingComputer
;
onModelFlushed
():
void
;
onModelFlushed
():
void
;
onModelLinesDeleted
(
versionId
:
number
,
fromLineNumber
:
number
,
toLineNumber
:
number
):
viewEvents
.
ViewLinesDeletedEvent
|
null
;
onModelLinesDeleted
(
versionId
:
number
,
fromLineNumber
:
number
,
toLineNumber
:
number
):
viewEvents
.
ViewLinesDeletedEvent
|
null
;
onModelLinesInserted
(
versionId
:
number
,
fromLineNumber
:
number
,
toLineNumber
:
number
,
linesMappings
:
(
ILineMapping
|
null
)[]):
viewEvents
.
ViewLinesInsertedEvent
|
null
;
onModelLinesInserted
(
versionId
:
number
,
fromLineNumber
:
number
,
toLineNumber
:
number
,
linesMappings
:
(
LineBreakingData
|
null
)[]):
viewEvents
.
ViewLinesInsertedEvent
|
null
;
onModelLineChanged
(
versionId
:
number
,
lineNumber
:
number
,
lineMapping
:
ILineMapping
|
null
):
[
boolean
,
viewEvents
.
ViewLinesChangedEvent
|
null
,
viewEvents
.
ViewLinesInsertedEvent
|
null
,
viewEvents
.
ViewLinesDeletedEvent
|
null
];
onModelLineChanged
(
versionId
:
number
,
lineNumber
:
number
,
lineMapping
:
LineBreakingData
|
null
):
[
boolean
,
viewEvents
.
ViewLinesChangedEvent
|
null
,
viewEvents
.
ViewLinesInsertedEvent
|
null
,
viewEvents
.
ViewLinesDeletedEvent
|
null
];
acceptVersionId
(
versionId
:
number
):
void
;
acceptVersionId
(
versionId
:
number
):
void
;
getViewLineCount
():
number
;
getViewLineCount
():
number
;
...
@@ -406,7 +438,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
...
@@ -406,7 +438,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
return
new
viewEvents
.
ViewLinesDeletedEvent
(
outputFromLineNumber
,
outputToLineNumber
);
return
new
viewEvents
.
ViewLinesDeletedEvent
(
outputFromLineNumber
,
outputToLineNumber
);
}
}
public
onModelLinesInserted
(
versionId
:
number
,
fromLineNumber
:
number
,
_toLineNumber
:
number
,
linesMappings
:
(
ILineMapping
|
null
)[]):
viewEvents
.
ViewLinesInsertedEvent
|
null
{
public
onModelLinesInserted
(
versionId
:
number
,
fromLineNumber
:
number
,
_toLineNumber
:
number
,
linesMappings
:
(
LineBreakingData
|
null
)[]):
viewEvents
.
ViewLinesInsertedEvent
|
null
{
if
(
versionId
<=
this
.
_validModelVersionId
)
{
if
(
versionId
<=
this
.
_validModelVersionId
)
{
// Here we check for versionId in case the lines were reconstructed in the meantime.
// Here we check for versionId in case the lines were reconstructed in the meantime.
// We don't want to apply stale change events on top of a newer read model state.
// We don't want to apply stale change events on top of a newer read model state.
...
@@ -446,7 +478,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
...
@@ -446,7 +478,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
return
new
viewEvents
.
ViewLinesInsertedEvent
(
outputFromLineNumber
,
outputFromLineNumber
+
totalOutputLineCount
-
1
);
return
new
viewEvents
.
ViewLinesInsertedEvent
(
outputFromLineNumber
,
outputFromLineNumber
+
totalOutputLineCount
-
1
);
}
}
public
onModelLineChanged
(
versionId
:
number
,
lineNumber
:
number
,
lineMapping
:
ILineMapping
|
null
):
[
boolean
,
viewEvents
.
ViewLinesChangedEvent
|
null
,
viewEvents
.
ViewLinesInsertedEvent
|
null
,
viewEvents
.
ViewLinesDeletedEvent
|
null
]
{
public
onModelLineChanged
(
versionId
:
number
,
lineNumber
:
number
,
lineMapping
:
LineBreakingData
|
null
):
[
boolean
,
viewEvents
.
ViewLinesChangedEvent
|
null
,
viewEvents
.
ViewLinesInsertedEvent
|
null
,
viewEvents
.
ViewLinesDeletedEvent
|
null
]
{
if
(
versionId
<=
this
.
_validModelVersionId
)
{
if
(
versionId
<=
this
.
_validModelVersionId
)
{
// Here we check for versionId in case the lines were reconstructed in the meantime.
// Here we check for versionId in case the lines were reconstructed in the meantime.
// We don't want to apply stale change events on top of a newer read model state.
// We don't want to apply stale change events on top of a newer read model state.
...
@@ -1027,18 +1059,13 @@ class InvisibleIdentitySplitLine implements ISplitLine {
...
@@ -1027,18 +1059,13 @@ class InvisibleIdentitySplitLine implements ISplitLine {
export
class
SplitLine
implements
ISplitLine
{
export
class
SplitLine
implements
ISplitLine
{
private
readonly
positionMapper
:
ILineMapping
;
private
readonly
_breakOffsets
:
number
[];
private
readonly
outputLineCount
:
number
;
private
readonly
_wrappedIndent
:
string
;
private
readonly
wrappedIndent
:
string
;
private
readonly
wrappedIndentLength
:
number
;
private
_isVisible
:
boolean
;
private
_isVisible
:
boolean
;
constructor
(
positionMapper
:
ILineMapping
,
isVisible
:
boolean
)
{
constructor
(
lineBreaking
:
LineBreakingData
,
isVisible
:
boolean
)
{
this
.
positionMapper
=
positionMapper
;
this
.
_breakOffsets
=
lineBreaking
.
breakOffsets
;
this
.
wrappedIndent
=
this
.
positionMapper
.
getWrappedLinesIndent
();
this
.
_wrappedIndent
=
lineBreaking
.
wrappedLinesIndent
;
this
.
wrappedIndentLength
=
this
.
wrappedIndent
.
length
;
this
.
outputLineCount
=
this
.
positionMapper
.
getOutputLineCount
();
this
.
_isVisible
=
isVisible
;
this
.
_isVisible
=
isVisible
;
}
}
...
@@ -1055,18 +1082,18 @@ export class SplitLine implements ISplitLine {
...
@@ -1055,18 +1082,18 @@ export class SplitLine implements ISplitLine {
if
(
!
this
.
_isVisible
)
{
if
(
!
this
.
_isVisible
)
{
return
0
;
return
0
;
}
}
return
this
.
outputLineCount
;
return
this
.
_breakOffsets
.
length
;
}
}
private
getInputStartOffsetOfOutputLineIndex
(
outputLineIndex
:
number
):
number
{
private
getInputStartOffsetOfOutputLineIndex
(
outputLineIndex
:
number
):
number
{
return
this
.
positionMapper
.
getInputOffsetOfOutputPosition
(
outputLineIndex
,
0
);
return
LineBreakingData
.
getInputOffsetOfOutputPosition
(
this
.
_breakOffsets
,
outputLineIndex
,
0
);
}
}
private
getInputEndOffsetOfOutputLineIndex
(
model
:
ISimpleModel
,
modelLineNumber
:
number
,
outputLineIndex
:
number
):
number
{
private
getInputEndOffsetOfOutputLineIndex
(
model
:
ISimpleModel
,
modelLineNumber
:
number
,
outputLineIndex
:
number
):
number
{
if
(
outputLineIndex
+
1
===
this
.
outputLineCount
)
{
if
(
outputLineIndex
+
1
===
this
.
_breakOffsets
.
length
)
{
return
model
.
getLineMaxColumn
(
modelLineNumber
)
-
1
;
return
model
.
getLineMaxColumn
(
modelLineNumber
)
-
1
;
}
}
return
this
.
positionMapper
.
getInputOffsetOfOutputPosition
(
outputLineIndex
+
1
,
0
);
return
LineBreakingData
.
getInputOffsetOfOutputPosition
(
this
.
_breakOffsets
,
outputLineIndex
+
1
,
0
);
}
}
public
getViewLineContent
(
model
:
ISimpleModel
,
modelLineNumber
:
number
,
outputLineIndex
:
number
):
string
{
public
getViewLineContent
(
model
:
ISimpleModel
,
modelLineNumber
:
number
,
outputLineIndex
:
number
):
string
{
...
@@ -1083,7 +1110,7 @@ export class SplitLine implements ISplitLine {
...
@@ -1083,7 +1110,7 @@ export class SplitLine implements ISplitLine {
});
});
if
(
outputLineIndex
>
0
)
{
if
(
outputLineIndex
>
0
)
{
r
=
this
.
wrappedIndent
+
r
;
r
=
this
.
_
wrappedIndent
+
r
;
}
}
return
r
;
return
r
;
...
@@ -1098,7 +1125,7 @@ export class SplitLine implements ISplitLine {
...
@@ -1098,7 +1125,7 @@ export class SplitLine implements ISplitLine {
let
r
=
endOffset
-
startOffset
;
let
r
=
endOffset
-
startOffset
;
if
(
outputLineIndex
>
0
)
{
if
(
outputLineIndex
>
0
)
{
r
=
this
.
wrappedIndent
.
length
+
r
;
r
=
this
.
_
wrappedIndent
.
length
+
r
;
}
}
return
r
;
return
r
;
...
@@ -1109,7 +1136,7 @@ export class SplitLine implements ISplitLine {
...
@@ -1109,7 +1136,7 @@ export class SplitLine implements ISplitLine {
throw
new
Error
(
'
Not supported
'
);
throw
new
Error
(
'
Not supported
'
);
}
}
if
(
outputLineIndex
>
0
)
{
if
(
outputLineIndex
>
0
)
{
return
this
.
wrappedIndentL
ength
+
1
;
return
this
.
_wrappedIndent
.
l
ength
+
1
;
}
}
return
1
;
return
1
;
}
}
...
@@ -1137,17 +1164,17 @@ export class SplitLine implements ISplitLine {
...
@@ -1137,17 +1164,17 @@ export class SplitLine implements ISplitLine {
});
});
if
(
outputLineIndex
>
0
)
{
if
(
outputLineIndex
>
0
)
{
lineContent
=
this
.
wrappedIndent
+
lineContent
;
lineContent
=
this
.
_
wrappedIndent
+
lineContent
;
}
}
let
minColumn
=
(
outputLineIndex
>
0
?
this
.
wrappedIndentL
ength
+
1
:
1
);
let
minColumn
=
(
outputLineIndex
>
0
?
this
.
_wrappedIndent
.
l
ength
+
1
:
1
);
let
maxColumn
=
lineContent
.
length
+
1
;
let
maxColumn
=
lineContent
.
length
+
1
;
let
continuesWithWrappedLine
=
(
outputLineIndex
+
1
<
this
.
getViewLineCount
());
let
continuesWithWrappedLine
=
(
outputLineIndex
+
1
<
this
.
getViewLineCount
());
let
deltaStartIndex
=
0
;
let
deltaStartIndex
=
0
;
if
(
outputLineIndex
>
0
)
{
if
(
outputLineIndex
>
0
)
{
deltaStartIndex
=
this
.
wrappedIndentL
ength
;
deltaStartIndex
=
this
.
_wrappedIndent
.
l
ength
;
}
}
let
lineTokens
=
model
.
getLineTokens
(
modelLineNumber
);
let
lineTokens
=
model
.
getLineTokens
(
modelLineNumber
);
...
@@ -1181,25 +1208,25 @@ export class SplitLine implements ISplitLine {
...
@@ -1181,25 +1208,25 @@ export class SplitLine implements ISplitLine {
}
}
let
adjustedColumn
=
outputColumn
-
1
;
let
adjustedColumn
=
outputColumn
-
1
;
if
(
outputLineIndex
>
0
)
{
if
(
outputLineIndex
>
0
)
{
if
(
adjustedColumn
<
this
.
wrappedIndentL
ength
)
{
if
(
adjustedColumn
<
this
.
_wrappedIndent
.
l
ength
)
{
adjustedColumn
=
0
;
adjustedColumn
=
0
;
}
else
{
}
else
{
adjustedColumn
-=
this
.
wrappedIndentL
ength
;
adjustedColumn
-=
this
.
_wrappedIndent
.
l
ength
;
}
}
}
}
return
this
.
positionMapper
.
getInputOffsetOfOutputPosition
(
outputLineIndex
,
adjustedColumn
)
+
1
;
return
LineBreakingData
.
getInputOffsetOfOutputPosition
(
this
.
_breakOffsets
,
outputLineIndex
,
adjustedColumn
)
+
1
;
}
}
public
getViewPositionOfModelPosition
(
deltaLineNumber
:
number
,
inputColumn
:
number
):
Position
{
public
getViewPositionOfModelPosition
(
deltaLineNumber
:
number
,
inputColumn
:
number
):
Position
{
if
(
!
this
.
_isVisible
)
{
if
(
!
this
.
_isVisible
)
{
throw
new
Error
(
'
Not supported
'
);
throw
new
Error
(
'
Not supported
'
);
}
}
let
r
=
this
.
positionMapper
.
getOutputPositionOfInputOffset
(
inputColumn
-
1
);
let
r
=
LineBreakingData
.
getOutputPositionOfInputOffset
(
this
.
_breakOffsets
,
inputColumn
-
1
);
let
outputLineIndex
=
r
.
outputLineIndex
;
let
outputLineIndex
=
r
.
outputLineIndex
;
let
outputColumn
=
r
.
outputOffset
+
1
;
let
outputColumn
=
r
.
outputOffset
+
1
;
if
(
outputLineIndex
>
0
)
{
if
(
outputLineIndex
>
0
)
{
outputColumn
+=
this
.
wrappedIndentL
ength
;
outputColumn
+=
this
.
_wrappedIndent
.
l
ength
;
}
}
// console.log('in -> out ' + deltaLineNumber + ',' + inputColumn + ' ===> ' + (deltaLineNumber+outputLineIndex) + ',' + outputColumn);
// console.log('in -> out ' + deltaLineNumber + ',' + inputColumn + ' ===> ' + (deltaLineNumber+outputLineIndex) + ',' + outputColumn);
...
@@ -1210,12 +1237,12 @@ export class SplitLine implements ISplitLine {
...
@@ -1210,12 +1237,12 @@ export class SplitLine implements ISplitLine {
if
(
!
this
.
_isVisible
)
{
if
(
!
this
.
_isVisible
)
{
throw
new
Error
(
'
Not supported
'
);
throw
new
Error
(
'
Not supported
'
);
}
}
const
r
=
this
.
positionMapper
.
getOutputPositionOfInputOffset
(
inputColumn
-
1
);
const
r
=
LineBreakingData
.
getOutputPositionOfInputOffset
(
this
.
_breakOffsets
,
inputColumn
-
1
);
return
(
deltaLineNumber
+
r
.
outputLineIndex
);
return
(
deltaLineNumber
+
r
.
outputLineIndex
);
}
}
}
}
function
createSplitLine
(
lineMapping
:
ILineMapping
|
null
,
isVisible
:
boolean
):
ISplitLine
{
function
createSplitLine
(
lineMapping
:
LineBreakingData
|
null
,
isVisible
:
boolean
):
ISplitLine
{
if
(
lineMapping
===
null
)
{
if
(
lineMapping
===
null
)
{
// No mapping needed
// No mapping needed
if
(
isVisible
)
{
if
(
isVisible
)
{
...
@@ -1332,11 +1359,11 @@ export class IdentityLinesCollection implements IViewModelLinesCollection {
...
@@ -1332,11 +1359,11 @@ export class IdentityLinesCollection implements IViewModelLinesCollection {
return
new
viewEvents
.
ViewLinesDeletedEvent
(
fromLineNumber
,
toLineNumber
);
return
new
viewEvents
.
ViewLinesDeletedEvent
(
fromLineNumber
,
toLineNumber
);
}
}
public
onModelLinesInserted
(
_versionId
:
number
,
fromLineNumber
:
number
,
toLineNumber
:
number
,
linesMappings
:
(
ILineMapping
|
null
)[]):
viewEvents
.
ViewLinesInsertedEvent
|
null
{
public
onModelLinesInserted
(
_versionId
:
number
,
fromLineNumber
:
number
,
toLineNumber
:
number
,
linesMappings
:
(
LineBreakingData
|
null
)[]):
viewEvents
.
ViewLinesInsertedEvent
|
null
{
return
new
viewEvents
.
ViewLinesInsertedEvent
(
fromLineNumber
,
toLineNumber
);
return
new
viewEvents
.
ViewLinesInsertedEvent
(
fromLineNumber
,
toLineNumber
);
}
}
public
onModelLineChanged
(
_versionId
:
number
,
lineNumber
:
number
,
lineMapping
:
ILineMapping
|
null
):
[
boolean
,
viewEvents
.
ViewLinesChangedEvent
|
null
,
viewEvents
.
ViewLinesInsertedEvent
|
null
,
viewEvents
.
ViewLinesDeletedEvent
|
null
]
{
public
onModelLineChanged
(
_versionId
:
number
,
lineNumber
:
number
,
lineMapping
:
LineBreakingData
|
null
):
[
boolean
,
viewEvents
.
ViewLinesChangedEvent
|
null
,
viewEvents
.
ViewLinesInsertedEvent
|
null
,
viewEvents
.
ViewLinesDeletedEvent
|
null
]
{
return
[
false
,
new
viewEvents
.
ViewLinesChangedEvent
(
lineNumber
,
lineNumber
),
null
,
null
];
return
[
false
,
new
viewEvents
.
ViewLinesChangedEvent
(
lineNumber
,
lineNumber
),
null
,
null
];
}
}
...
...
src/vs/editor/test/common/viewModel/characterHardWrappingLineMapper.test.ts
浏览文件 @
faea8dc0
...
@@ -5,9 +5,9 @@
...
@@ -5,9 +5,9 @@
import
*
as
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
WrappingIndent
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
WrappingIndent
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CharacterHardWrappingLineMapperFactory
}
from
'
vs/editor/common/viewModel/characterHardWrappingLineMapper
'
;
import
{
CharacterHardWrappingLineMapperFactory
}
from
'
vs/editor/common/viewModel/characterHardWrappingLineMapper
'
;
import
{
ILineMapperFactory
,
ILineMapping
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
ILineMapperFactory
,
LineBreakingData
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
function
assertLineMapping
(
factory
:
ILineMapperFactory
,
tabSize
:
number
,
breakAfter
:
number
,
annotatedText
:
string
,
wrappingIndent
=
WrappingIndent
.
None
):
ILineMapping
|
null
{
function
assertLineMapping
(
factory
:
ILineMapperFactory
,
tabSize
:
number
,
breakAfter
:
number
,
annotatedText
:
string
,
wrappingIndent
=
WrappingIndent
.
None
):
LineBreakingData
|
null
{
// Create version of `annotatedText` with line break markers removed
// Create version of `annotatedText` with line break markers removed
let
rawText
=
''
;
let
rawText
=
''
;
let
currentLineIndex
=
0
;
let
currentLineIndex
=
0
;
...
@@ -31,7 +31,7 @@ function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAf
...
@@ -31,7 +31,7 @@ function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAf
if
(
mapper
)
{
if
(
mapper
)
{
let
previousLineIndex
=
0
;
let
previousLineIndex
=
0
;
for
(
let
i
=
0
,
len
=
rawText
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
rawText
.
length
;
i
<
len
;
i
++
)
{
let
r
=
mapper
.
getOutputPositionOfInputOffset
(
i
);
let
r
=
LineBreakingData
.
getOutputPositionOfInputOffset
(
mapper
.
breakOffsets
,
i
);
if
(
previousLineIndex
!==
r
.
outputLineIndex
)
{
if
(
previousLineIndex
!==
r
.
outputLineIndex
)
{
previousLineIndex
=
r
.
outputLineIndex
;
previousLineIndex
=
r
.
outputLineIndex
;
actualAnnotatedText
+=
'
|
'
;
actualAnnotatedText
+=
'
|
'
;
...
@@ -114,7 +114,7 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
...
@@ -114,7 +114,7 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
test
(
'
issue #35162: wrappingIndent not consistently working
'
,
()
=>
{
test
(
'
issue #35162: wrappingIndent not consistently working
'
,
()
=>
{
let
factory
=
new
CharacterHardWrappingLineMapperFactory
(
''
,
'
\t
'
);
let
factory
=
new
CharacterHardWrappingLineMapperFactory
(
''
,
'
\t
'
);
let
mapper
=
assertLineMapping
(
factory
,
4
,
24
,
'
t h i s |i s |a l |o n |g l |i n |e
'
,
WrappingIndent
.
Indent
);
let
mapper
=
assertLineMapping
(
factory
,
4
,
24
,
'
t h i s |i s |a l |o n |g l |i n |e
'
,
WrappingIndent
.
Indent
);
assert
.
equal
(
mapper
!
.
getWrappedLinesIndent
()
,
'
\t
'
);
assert
.
equal
(
mapper
!
.
wrappedLinesIndent
,
'
\t
'
);
});
});
test
(
'
issue #75494: surrogate pairs
'
,
()
=>
{
test
(
'
issue #75494: surrogate pairs
'
,
()
=>
{
...
@@ -125,6 +125,6 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
...
@@ -125,6 +125,6 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
test
(
'
CharacterHardWrappingLineMapper - WrappingIndent.DeepIndent
'
,
()
=>
{
test
(
'
CharacterHardWrappingLineMapper - WrappingIndent.DeepIndent
'
,
()
=>
{
let
factory
=
new
CharacterHardWrappingLineMapperFactory
(
''
,
'
\t
'
);
let
factory
=
new
CharacterHardWrappingLineMapperFactory
(
''
,
'
\t
'
);
let
mapper
=
assertLineMapping
(
factory
,
4
,
26
,
'
W e A r e T e s t |i n g D e |e p I n d |e n t a t |i o n
'
,
WrappingIndent
.
DeepIndent
);
let
mapper
=
assertLineMapping
(
factory
,
4
,
26
,
'
W e A r e T e s t |i n g D e |e p I n d |e n t a t |i o n
'
,
WrappingIndent
.
DeepIndent
);
assert
.
equal
(
mapper
!
.
getWrappedLinesIndent
()
,
'
\t\t
'
);
assert
.
equal
(
mapper
!
.
wrappedLinesIndent
,
'
\t\t
'
);
});
});
});
});
src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts
浏览文件 @
faea8dc0
...
@@ -13,8 +13,8 @@ import { EndOfLinePreference } from 'vs/editor/common/model';
...
@@ -13,8 +13,8 @@ import { EndOfLinePreference } from 'vs/editor/common/model';
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
NULL_STATE
}
from
'
vs/editor/common/modes/nullMode
'
;
import
{
NULL_STATE
}
from
'
vs/editor/common/modes/nullMode
'
;
import
{
CharacterHardWrappingLineMapperFactory
,
CharacterHardWrappingLineMapping
}
from
'
vs/editor/common/viewModel/characterHardWrappingLineMapper
'
;
import
{
CharacterHardWrappingLineMapperFactory
}
from
'
vs/editor/common/viewModel/characterHardWrappingLineMapper
'
;
import
{
ILineMapping
,
ISimpleModel
,
SplitLine
,
SplitLinesCollection
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
LineBreakingData
,
ISimpleModel
,
SplitLine
,
SplitLinesCollection
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
ViewLineData
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
ViewLineData
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
TestConfiguration
}
from
'
vs/editor/test/common/mocks/testConfiguration
'
;
import
{
TestConfiguration
}
from
'
vs/editor/test/common/mocks/testConfiguration
'
;
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
...
@@ -776,12 +776,12 @@ function createSplitLine(splitLengths: number[], wrappedLinesPrefix: string, isV
...
@@ -776,12 +776,12 @@ function createSplitLine(splitLengths: number[], wrappedLinesPrefix: string, isV
return
new
SplitLine
(
createLineMapping
(
splitLengths
,
wrappedLinesPrefix
),
isVisible
);
return
new
SplitLine
(
createLineMapping
(
splitLengths
,
wrappedLinesPrefix
),
isVisible
);
}
}
function
createLineMapping
(
breakingLengths
:
number
[],
wrappedLinesPrefix
:
string
):
ILineMapping
{
function
createLineMapping
(
breakingLengths
:
number
[],
wrappedLinesPrefix
:
string
):
LineBreakingData
{
let
sums
:
number
[]
=
[];
let
sums
:
number
[]
=
[];
for
(
let
i
=
0
;
i
<
breakingLengths
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
breakingLengths
.
length
;
i
++
)
{
sums
[
i
]
=
(
i
>
0
?
sums
[
i
-
1
]
:
0
)
+
breakingLengths
[
i
];
sums
[
i
]
=
(
i
>
0
?
sums
[
i
-
1
]
:
0
)
+
breakingLengths
[
i
];
}
}
return
new
CharacterHardWrappingLineMapping
(
sums
,
wrappedLinesPrefix
);
return
new
LineBreakingData
(
sums
,
wrappedLinesPrefix
);
}
}
function
createModel
(
text
:
string
):
ISimpleModel
{
function
createModel
(
text
:
string
):
ISimpleModel
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录