Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
c249c6f4
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,发现更多精彩内容 >>
提交
c249c6f4
编写于
3月 24, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize PrefixSumComputer
上级
b57dffa7
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
164 addition
and
173 deletion
+164
-173
src/vs/editor/common/model/mirrorModel.ts
src/vs/editor/common/model/mirrorModel.ts
+3
-6
src/vs/editor/common/viewModel/characterHardWrappingLineMapper.ts
...ditor/common/viewModel/characterHardWrappingLineMapper.ts
+4
-10
src/vs/editor/common/viewModel/prefixSumComputer.ts
src/vs/editor/common/viewModel/prefixSumComputer.ts
+38
-15
src/vs/editor/common/viewModel/splitLinesCollection.ts
src/vs/editor/common/viewModel/splitLinesCollection.ts
+70
-81
src/vs/editor/test/common/viewModel/characterHardWrappingLineMapper.test.ts
.../common/viewModel/characterHardWrappingLineMapper.test.ts
+13
-20
src/vs/editor/test/common/viewModel/prefixSumComputer.test.ts
...vs/editor/test/common/viewModel/prefixSumComputer.test.ts
+35
-38
src/vs/workbench/api/node/extHostDocuments.ts
src/vs/workbench/api/node/extHostDocuments.ts
+1
-3
未找到文件。
src/vs/editor/common/model/mirrorModel.ts
浏览文件 @
c249c6f4
...
...
@@ -13,7 +13,7 @@ import {TextModel} from 'vs/editor/common/model/textModel';
import
{
TextModelWithTokens
}
from
'
vs/editor/common/model/textModelWithTokens
'
;
import
{
IMode
}
from
'
vs/editor/common/modes
'
;
import
{
IResourceService
}
from
'
vs/editor/common/services/resourceService
'
;
import
{
IPrefixSumIndexOfResult
,
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
export
interface
IMirrorModelEvents
{
contentChanged
:
editorCommon
.
IModelContentChangedEvent
[];
...
...
@@ -115,11 +115,8 @@ export class AbstractMirrorModel extends TextModelWithTokens implements editorCo
}
this
.
_ensurePrefixSum
();
var
r
:
IPrefixSumIndexOfResult
=
{
index
:
0
,
remainder
:
0
};
this
.
_lineStarts
.
getIndexOf
(
offset
,
r
);
let
r
=
this
.
_lineStarts
.
getIndexOf
(
offset
);
return
{
lineNumber
:
r
.
index
+
1
,
column
:
this
.
getEOL
().
length
+
r
.
remainder
...
...
src/vs/editor/common/viewModel/characterHardWrappingLineMapper.ts
浏览文件 @
c249c6f4
...
...
@@ -7,12 +7,7 @@
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
WrappingIndent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
ILineMapperFactory
,
ILineMapping
,
IOutputPosition
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
var
throwawayIndexOfResult
=
{
index
:
-
1
,
remainder
:
-
1
};
import
{
ILineMapperFactory
,
ILineMapping
,
OutputPosition
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
var
BREAK_BEFORE_CLASS
=
1
;
var
BREAK_AFTER_CLASS
=
2
;
...
...
@@ -244,9 +239,8 @@ export class CharacterHardWrappingLineMapping implements ILineMapping {
}
}
public
getOutputPositionOfInputOffset
(
inputOffset
:
number
,
result
:
IOutputPosition
):
void
{
this
.
_prefixSums
.
getIndexOf
(
inputOffset
,
throwawayIndexOfResult
);
result
.
outputLineIndex
=
throwawayIndexOfResult
.
index
;
result
.
outputOffset
=
throwawayIndexOfResult
.
remainder
;
public
getOutputPositionOfInputOffset
(
inputOffset
:
number
):
OutputPosition
{
let
r
=
this
.
_prefixSums
.
getIndexOf
(
inputOffset
);
return
new
OutputPosition
(
r
.
index
,
r
.
remainder
);
}
}
\ No newline at end of file
src/vs/editor/common/viewModel/prefixSumComputer.ts
浏览文件 @
c249c6f4
...
...
@@ -4,9 +4,16 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
export
interface
IPrefixSumIndexOfResult
{
export
class
PrefixSumIndexOfResult
{
prefixSumIndexOfResultTrait
:
void
;
index
:
number
;
remainder
:
number
;
constructor
(
index
:
number
,
remainder
:
number
)
{
this
.
index
=
index
;
this
.
remainder
=
remainder
;
}
}
export
class
PrefixSumComputer
{
...
...
@@ -29,7 +36,7 @@ export class PrefixSumComputer {
constructor
(
values
:
number
[])
{
this
.
values
=
values
;
this
.
prefixSum
=
[];
for
(
var
i
=
0
,
len
=
this
.
values
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
this
.
values
.
length
;
i
<
len
;
i
++
)
{
this
.
prefixSum
[
i
]
=
0
;
}
this
.
prefixSumValidIndex
=
-
1
;
...
...
@@ -40,6 +47,9 @@ export class PrefixSumComputer {
}
public
insertValue
(
insertIndex
:
number
,
value
:
number
):
void
{
insertIndex
=
Math
.
floor
(
insertIndex
);
//@perf
value
=
Math
.
floor
(
value
);
//@perf
this
.
values
.
splice
(
insertIndex
,
0
,
value
);
this
.
prefixSum
.
splice
(
insertIndex
,
0
,
0
);
if
(
insertIndex
-
1
<
this
.
prefixSumValidIndex
)
{
...
...
@@ -48,6 +58,8 @@ export class PrefixSumComputer {
}
public
insertValues
(
insertIndex
:
number
,
values
:
number
[]):
void
{
insertIndex
=
Math
.
floor
(
insertIndex
);
//@perf
if
(
values
.
length
===
0
)
{
return
;
}
...
...
@@ -61,14 +73,19 @@ export class PrefixSumComputer {
}
private
static
_zeroArray
(
count
:
number
):
number
[]
{
var
r
:
number
[]
=
new
Array
<
number
>
(
count
);
for
(
var
i
=
0
;
i
<
count
;
i
++
)
{
count
=
Math
.
floor
(
count
);
//@perf
let
r
:
number
[]
=
[];
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
r
[
i
]
=
0
;
}
return
r
;
}
public
changeValue
(
index
:
number
,
value
:
number
):
void
{
index
=
Math
.
floor
(
index
);
//@perf
value
=
Math
.
floor
(
value
);
//@perf
if
(
this
.
values
[
index
]
===
value
)
{
return
;
}
...
...
@@ -79,6 +96,9 @@ export class PrefixSumComputer {
}
public
removeValues
(
startIndex
:
number
,
cnt
:
number
):
void
{
startIndex
=
Math
.
floor
(
startIndex
);
//@perf
cnt
=
Math
.
floor
(
cnt
);
//@perf
this
.
values
.
splice
(
startIndex
,
cnt
);
this
.
prefixSum
.
splice
(
startIndex
,
cnt
);
if
(
startIndex
-
1
<
this
.
prefixSumValidIndex
)
{
...
...
@@ -94,6 +114,8 @@ export class PrefixSumComputer {
}
public
getAccumulatedValue
(
index
:
number
):
number
{
index
=
Math
.
floor
(
index
);
//@perf
if
(
index
<
0
)
{
return
0
;
}
...
...
@@ -101,7 +123,7 @@ export class PrefixSumComputer {
return
this
.
prefixSum
[
index
];
}
var
startIndex
=
this
.
prefixSumValidIndex
+
1
;
let
startIndex
=
this
.
prefixSumValidIndex
+
1
;
if
(
startIndex
===
0
)
{
this
.
prefixSum
[
0
]
=
this
.
values
[
0
];
startIndex
++
;
...
...
@@ -111,19 +133,21 @@ export class PrefixSumComputer {
index
=
this
.
values
.
length
-
1
;
}
for
(
var
i
=
startIndex
;
i
<=
index
;
i
++
)
{
for
(
let
i
=
startIndex
;
i
<=
index
;
i
++
)
{
this
.
prefixSum
[
i
]
=
this
.
prefixSum
[
i
-
1
]
+
this
.
values
[
i
];
}
this
.
prefixSumValidIndex
=
Math
.
max
(
this
.
prefixSumValidIndex
,
index
);
return
this
.
prefixSum
[
index
];
}
public
getIndexOf
(
accumulatedValue
:
number
,
result
:
IPrefixSumIndexOfResult
):
void
{
var
low
=
0
,
high
=
this
.
values
.
length
-
1
,
mid
:
number
,
midStart
:
number
,
midStop
:
number
;
public
getIndexOf
(
accumulatedValue
:
number
):
PrefixSumIndexOfResult
{
accumulatedValue
=
Math
.
floor
(
accumulatedValue
);
//@perf
let
low
=
0
;
let
high
=
this
.
values
.
length
-
1
;
let
mid
:
number
;
let
midStop
:
number
;
let
midStart
:
number
;
while
(
low
<=
high
)
{
mid
=
low
+
(
(
high
-
low
)
/
2
)
|
0
;
...
...
@@ -140,7 +164,6 @@ export class PrefixSumComputer {
}
}
result
.
index
=
mid
;
result
.
remainder
=
accumulatedValue
-
midStart
;
return
new
PrefixSumIndexOfResult
(
mid
,
accumulatedValue
-
midStart
);
}
}
src/vs/editor/common/viewModel/splitLinesCollection.ts
浏览文件 @
c249c6f4
...
...
@@ -8,32 +8,31 @@ import {Position} from 'vs/editor/common/core/position';
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
FilteredLineTokens
,
IdentityFilteredLineTokens
}
from
'
vs/editor/common/viewModel/filteredLineTokens
'
;
import
{
IPrefixSumIndexOfResult
,
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
ILinesCollection
}
from
'
vs/editor/common/viewModel/viewModel
'
;
export
interface
IOutputPosition
{
export
class
OutputPosition
{
_outputPositionTrait
:
void
;
outputLineIndex
:
number
;
outputOffset
:
number
;
constructor
(
outputLineIndex
:
number
,
outputOffset
:
number
)
{
this
.
outputLineIndex
=
outputLineIndex
;
this
.
outputOffset
=
outputOffset
;
}
}
export
interface
ILineMapping
{
getOutputLineCount
():
number
;
getWrappedLinesIndent
():
string
;
getInputOffsetOfOutputPosition
(
outputLineIndex
:
number
,
outputOffset
:
number
):
number
;
getOutputPositionOfInputOffset
(
inputOffset
:
number
,
result
:
IOutputPosition
):
void
;
getOutputPositionOfInputOffset
(
inputOffset
:
number
):
OutputPosition
;
}
export
interface
ILineMapperFactory
{
createLineMapping
(
lineText
:
string
,
tabSize
:
number
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
,
wrappingIndent
:
editorCommon
.
WrappingIndent
):
ILineMapping
;
}
var
tmpOutputPosition
:
IOutputPosition
=
{
outputLineIndex
:
0
,
outputOffset
:
0
};
export
interface
IModel
{
getLineTokens
(
lineNumber
:
number
,
inaccurateTokensAcceptable
?:
boolean
):
editorCommon
.
ILineTokens
;
getLineContent
(
lineNumber
:
number
):
string
;
...
...
@@ -166,9 +165,9 @@ export class SplitLine implements ISplitLine {
if
(
!
this
.
_isVisible
)
{
throw
new
Error
(
'
Not supported
'
);
}
var
startOffset
=
this
.
getInputStartOffsetOfOutputLineIndex
(
outputLineIndex
);
var
endOffset
=
this
.
getInputEndOffsetOfOutputLineIndex
(
model
,
myLineNumber
,
outputLineIndex
);
var
r
=
model
.
getLineContent
(
myLineNumber
).
substring
(
startOffset
,
endOffset
);
let
startOffset
=
this
.
getInputStartOffsetOfOutputLineIndex
(
outputLineIndex
);
let
endOffset
=
this
.
getInputEndOffsetOfOutputLineIndex
(
model
,
myLineNumber
,
outputLineIndex
);
let
r
=
model
.
getLineContent
(
myLineNumber
).
substring
(
startOffset
,
endOffset
);
if
(
outputLineIndex
>
0
)
{
r
=
this
.
wrappedIndent
+
r
;
...
...
@@ -199,9 +198,9 @@ export class SplitLine implements ISplitLine {
if
(
!
this
.
_isVisible
)
{
throw
new
Error
(
'
Not supported
'
);
}
var
startOffset
=
this
.
getInputStartOffsetOfOutputLineIndex
(
outputLineIndex
);
var
endOffset
=
this
.
getInputEndOffsetOfOutputLineIndex
(
model
,
myLineNumber
,
outputLineIndex
);
var
deltaStartIndex
=
0
;
let
startOffset
=
this
.
getInputStartOffsetOfOutputLineIndex
(
outputLineIndex
);
let
endOffset
=
this
.
getInputEndOffsetOfOutputLineIndex
(
model
,
myLineNumber
,
outputLineIndex
);
let
deltaStartIndex
=
0
;
if
(
outputLineIndex
>
0
)
{
deltaStartIndex
=
this
.
wrappedIndentLength
;
}
...
...
@@ -212,7 +211,7 @@ export class SplitLine implements ISplitLine {
if
(
!
this
.
_isVisible
)
{
throw
new
Error
(
'
Not supported
'
);
}
var
adjustedColumn
=
outputColumn
-
1
;
let
adjustedColumn
=
outputColumn
-
1
;
if
(
outputLineIndex
>
0
)
{
if
(
adjustedColumn
<
this
.
wrappedIndentLength
)
{
adjustedColumn
=
0
;
...
...
@@ -227,9 +226,9 @@ export class SplitLine implements ISplitLine {
if
(
!
this
.
_isVisible
)
{
throw
new
Error
(
'
Not supported
'
);
}
this
.
positionMapper
.
getOutputPositionOfInputOffset
(
inputColumn
-
1
,
tmpOutputPosition
);
var
outputLineIndex
=
tmpOutputPosition
.
outputLineIndex
;
var
outputColumn
=
tmpOutputPosition
.
outputOffset
+
1
;
let
r
=
this
.
positionMapper
.
getOutputPositionOfInputOffset
(
inputColumn
-
1
);
let
outputLineIndex
=
r
.
outputLineIndex
;
let
outputColumn
=
r
.
outputOffset
+
1
;
if
(
outputLineIndex
>
0
)
{
outputColumn
+=
this
.
wrappedIndentLength
;
...
...
@@ -241,7 +240,7 @@ export class SplitLine implements ISplitLine {
}
function
createSplitLine
(
linePositionMapperFactory
:
ILineMapperFactory
,
text
:
string
,
tabSize
:
number
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
,
wrappingIndent
:
editorCommon
.
WrappingIndent
,
isVisible
:
boolean
):
ISplitLine
{
var
positionMapper
=
linePositionMapperFactory
.
createLineMapping
(
text
,
tabSize
,
wrappingColumn
,
columnsForFullWidthChar
,
wrappingIndent
);
let
positionMapper
=
linePositionMapperFactory
.
createLineMapping
(
text
,
tabSize
,
wrappingColumn
,
columnsForFullWidthChar
,
wrappingIndent
);
if
(
positionMapper
===
null
)
{
// No mapping needed
return
new
IdentitySplitLine
(
isVisible
);
...
...
@@ -263,7 +262,6 @@ export class SplitLinesCollection implements ILinesCollection {
private
prefixSumComputer
:
PrefixSumComputer
;
private
linePositionMapperFactory
:
ILineMapperFactory
;
private
tmpIndexOfResult
:
IPrefixSumIndexOfResult
;
private
hiddenAreasIds
:
string
[];
constructor
(
model
:
editorCommon
.
IModel
,
linePositionMapperFactory
:
ILineMapperFactory
,
tabSize
:
number
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
,
wrappingIndent
:
editorCommon
.
WrappingIndent
)
{
...
...
@@ -276,11 +274,6 @@ export class SplitLinesCollection implements ILinesCollection {
this
.
linePositionMapperFactory
=
linePositionMapperFactory
;
this
.
_constructLines
(
true
);
this
.
tmpIndexOfResult
=
{
index
:
0
,
remainder
:
0
};
}
public
dispose
():
void
{
...
...
@@ -288,7 +281,7 @@ export class SplitLinesCollection implements ILinesCollection {
}
private
_ensureValidState
():
void
{
var
modelVersion
=
this
.
model
.
getVersionId
();
let
modelVersion
=
this
.
model
.
getVersionId
();
if
(
modelVersion
!==
this
.
_validModelVersionId
)
{
throw
new
Error
(
'
SplitLinesCollection: attempt to access a
\'
newer
\'
model
'
);
}
...
...
@@ -488,13 +481,13 @@ export class SplitLinesCollection implements ILinesCollection {
}
this
.
_validModelVersionId
=
versionId
;
var
outputFromLineNumber
=
(
fromLineNumber
===
1
?
1
:
this
.
prefixSumComputer
.
getAccumulatedValue
(
fromLineNumber
-
2
)
+
1
);
var
outputToLineNumber
=
this
.
prefixSumComputer
.
getAccumulatedValue
(
toLineNumber
-
1
);
let
outputFromLineNumber
=
(
fromLineNumber
===
1
?
1
:
this
.
prefixSumComputer
.
getAccumulatedValue
(
fromLineNumber
-
2
)
+
1
);
let
outputToLineNumber
=
this
.
prefixSumComputer
.
getAccumulatedValue
(
toLineNumber
-
1
);
this
.
lines
.
splice
(
fromLineNumber
-
1
,
toLineNumber
-
fromLineNumber
+
1
);
this
.
prefixSumComputer
.
removeValues
(
fromLineNumber
-
1
,
toLineNumber
-
fromLineNumber
+
1
);
var
e
:
editorCommon
.
IViewLinesDeletedEvent
=
{
let
e
:
editorCommon
.
IViewLinesDeletedEvent
=
{
fromLineNumber
:
outputFromLineNumber
,
toLineNumber
:
outputToLineNumber
};
...
...
@@ -507,30 +500,27 @@ export class SplitLinesCollection implements ILinesCollection {
}
this
.
_validModelVersionId
=
versionId
;
var
hiddenAreas
=
this
.
getHiddenAreas
();
var
isInHiddenArea
=
false
;
var
testPosition
=
new
Position
(
fromLineNumber
,
1
);
for
(
var
i
=
0
;
i
<
hiddenAreas
.
length
;
i
++
)
{
let
hiddenAreas
=
this
.
getHiddenAreas
();
let
isInHiddenArea
=
false
;
let
testPosition
=
new
Position
(
fromLineNumber
,
1
);
for
(
let
i
=
0
;
i
<
hiddenAreas
.
length
;
i
++
)
{
if
(
hiddenAreas
[
i
].
containsPosition
(
testPosition
))
{
isInHiddenArea
=
true
;
break
;
}
}
var
outputFromLineNumber
=
(
fromLineNumber
===
1
?
1
:
this
.
prefixSumComputer
.
getAccumulatedValue
(
fromLineNumber
-
2
)
+
1
);
var
line
:
ISplitLine
,
outputLineCount
:
number
,
totalOutputLineCount
=
0
;
let
outputFromLineNumber
=
(
fromLineNumber
===
1
?
1
:
this
.
prefixSumComputer
.
getAccumulatedValue
(
fromLineNumber
-
2
)
+
1
);
var
insertLines
:
ISplitLine
[]
=
[],
insertPrefixSumValues
:
number
[]
=
[];
let
totalOutputLineCount
=
0
;
let
insertLines
:
ISplitLine
[]
=
[];
let
insertPrefixSumValues
:
number
[]
=
[];
for
(
var
i
=
0
,
len
=
text
.
length
;
i
<
len
;
i
++
)
{
var
line
=
createSplitLine
(
this
.
linePositionMapperFactory
,
text
[
i
],
this
.
tabSize
,
this
.
wrappingColumn
,
this
.
columnsForFullWidthChar
,
this
.
wrappingIndent
,
!
isInHiddenArea
);
for
(
let
i
=
0
,
len
=
text
.
length
;
i
<
len
;
i
++
)
{
let
line
=
createSplitLine
(
this
.
linePositionMapperFactory
,
text
[
i
],
this
.
tabSize
,
this
.
wrappingColumn
,
this
.
columnsForFullWidthChar
,
this
.
wrappingIndent
,
!
isInHiddenArea
);
insertLines
.
push
(
line
);
outputLineCount
=
line
.
getOutputLineCount
();
let
outputLineCount
=
line
.
getOutputLineCount
();
totalOutputLineCount
+=
outputLineCount
;
insertPrefixSumValues
.
push
(
outputLineCount
);
}
...
...
@@ -539,7 +529,7 @@ export class SplitLinesCollection implements ILinesCollection {
this
.
prefixSumComputer
.
insertValues
(
fromLineNumber
-
1
,
insertPrefixSumValues
);
var
e
:
editorCommon
.
IViewLinesInsertedEvent
=
{
let
e
:
editorCommon
.
IViewLinesInsertedEvent
=
{
fromLineNumber
:
outputFromLineNumber
,
toLineNumber
:
outputFromLineNumber
+
totalOutputLineCount
-
1
};
...
...
@@ -551,21 +541,21 @@ export class SplitLinesCollection implements ILinesCollection {
return
;
}
this
.
_validModelVersionId
=
versionId
;
var
lineIndex
=
lineNumber
-
1
;
let
lineIndex
=
lineNumber
-
1
;
var
oldOutputLineCount
=
this
.
lines
[
lineIndex
].
getOutputLineCount
();
var
isVisible
=
this
.
lines
[
lineIndex
].
isVisible
();
var
line
=
createSplitLine
(
this
.
linePositionMapperFactory
,
newText
,
this
.
tabSize
,
this
.
wrappingColumn
,
this
.
columnsForFullWidthChar
,
this
.
wrappingIndent
,
isVisible
);
let
oldOutputLineCount
=
this
.
lines
[
lineIndex
].
getOutputLineCount
();
let
isVisible
=
this
.
lines
[
lineIndex
].
isVisible
();
let
line
=
createSplitLine
(
this
.
linePositionMapperFactory
,
newText
,
this
.
tabSize
,
this
.
wrappingColumn
,
this
.
columnsForFullWidthChar
,
this
.
wrappingIndent
,
isVisible
);
this
.
lines
[
lineIndex
]
=
line
;
var
newOutputLineCount
=
this
.
lines
[
lineIndex
].
getOutputLineCount
();
let
newOutputLineCount
=
this
.
lines
[
lineIndex
].
getOutputLineCount
();
var
lineMappingChanged
=
false
,
changeFrom
=
0
,
changeTo
=
-
1
,
insertFrom
=
0
,
insertTo
=
-
1
,
deleteFrom
=
0
,
deleteTo
=
-
1
;
let
lineMappingChanged
=
false
;
let
changeFrom
=
0
;
let
changeTo
=
-
1
;
let
insertFrom
=
0
;
let
insertTo
=
-
1
;
let
deleteFrom
=
0
;
let
deleteTo
=
-
1
;
if
(
oldOutputLineCount
>
newOutputLineCount
)
{
changeFrom
=
(
lineNumber
===
1
?
1
:
this
.
prefixSumComputer
.
getAccumulatedValue
(
lineNumber
-
2
)
+
1
);
...
...
@@ -586,13 +576,12 @@ export class SplitLinesCollection implements ILinesCollection {
this
.
prefixSumComputer
.
changeValue
(
lineIndex
,
newOutputLineCount
);
var
i
:
number
,
e1
:
editorCommon
.
IViewLineChangedEvent
,
e2
:
editorCommon
.
IViewLinesInsertedEvent
,
e3
:
editorCommon
.
IViewLinesDeletedEvent
;
let
e1
:
editorCommon
.
IViewLineChangedEvent
;
let
e2
:
editorCommon
.
IViewLinesInsertedEvent
;
let
e3
:
editorCommon
.
IViewLinesDeletedEvent
;
if
(
changeFrom
<=
changeTo
)
{
for
(
var
i
=
changeFrom
;
i
<=
changeTo
;
i
++
)
{
for
(
let
i
=
changeFrom
;
i
<=
changeTo
;
i
++
)
{
e1
=
{
lineNumber
:
i
};
...
...
@@ -636,9 +625,9 @@ export class SplitLinesCollection implements ILinesCollection {
public
getOutputLineContent
(
outputLineNumber
:
number
):
string
{
this
.
_ensureValidState
();
outputLineNumber
=
this
.
_toValidOutputLineNumber
(
outputLineNumber
);
this
.
prefixSumComputer
.
getIndexOf
(
outputLineNumber
-
1
,
this
.
tmpIndexOfResult
);
var
lineIndex
=
this
.
tmpIndexOfResult
.
index
;
var
remainder
=
this
.
tmpIndexOfResult
.
remainder
;
let
r
=
this
.
prefixSumComputer
.
getIndexOf
(
outputLineNumber
-
1
);
let
lineIndex
=
r
.
index
;
let
remainder
=
r
.
remainder
;
return
this
.
lines
[
lineIndex
].
getOutputLineContent
(
this
.
model
,
lineIndex
+
1
,
remainder
);
}
...
...
@@ -646,9 +635,9 @@ export class SplitLinesCollection implements ILinesCollection {
public
getOutputLineMinColumn
(
outputLineNumber
:
number
):
number
{
this
.
_ensureValidState
();
outputLineNumber
=
this
.
_toValidOutputLineNumber
(
outputLineNumber
);
this
.
prefixSumComputer
.
getIndexOf
(
outputLineNumber
-
1
,
this
.
tmpIndexOfResult
);
var
lineIndex
=
this
.
tmpIndexOfResult
.
index
;
var
remainder
=
this
.
tmpIndexOfResult
.
remainder
;
let
r
=
this
.
prefixSumComputer
.
getIndexOf
(
outputLineNumber
-
1
);
let
lineIndex
=
r
.
index
;
let
remainder
=
r
.
remainder
;
return
this
.
lines
[
lineIndex
].
getOutputLineMinColumn
(
this
.
model
,
lineIndex
+
1
,
remainder
);
}
...
...
@@ -656,9 +645,9 @@ export class SplitLinesCollection implements ILinesCollection {
public
getOutputLineMaxColumn
(
outputLineNumber
:
number
):
number
{
this
.
_ensureValidState
();
outputLineNumber
=
this
.
_toValidOutputLineNumber
(
outputLineNumber
);
this
.
prefixSumComputer
.
getIndexOf
(
outputLineNumber
-
1
,
this
.
tmpIndexOfResult
);
var
lineIndex
=
this
.
tmpIndexOfResult
.
index
;
var
remainder
=
this
.
tmpIndexOfResult
.
remainder
;
let
r
=
this
.
prefixSumComputer
.
getIndexOf
(
outputLineNumber
-
1
);
let
lineIndex
=
r
.
index
;
let
remainder
=
r
.
remainder
;
return
this
.
lines
[
lineIndex
].
getOutputLineMaxColumn
(
this
.
model
,
lineIndex
+
1
,
remainder
);
}
...
...
@@ -666,9 +655,9 @@ export class SplitLinesCollection implements ILinesCollection {
public
getOutputLineTokens
(
outputLineNumber
:
number
,
inaccurateTokensAcceptable
:
boolean
):
editorCommon
.
IViewLineTokens
{
this
.
_ensureValidState
();
outputLineNumber
=
this
.
_toValidOutputLineNumber
(
outputLineNumber
);
this
.
prefixSumComputer
.
getIndexOf
(
outputLineNumber
-
1
,
this
.
tmpIndexOfResult
);
var
lineIndex
=
this
.
tmpIndexOfResult
.
index
;
var
remainder
=
this
.
tmpIndexOfResult
.
remainder
;
let
r
=
this
.
prefixSumComputer
.
getIndexOf
(
outputLineNumber
-
1
);
let
lineIndex
=
r
.
index
;
let
remainder
=
r
.
remainder
;
return
this
.
lines
[
lineIndex
].
getOutputLineTokens
(
this
.
model
,
lineIndex
+
1
,
remainder
,
inaccurateTokensAcceptable
);
}
...
...
@@ -677,11 +666,11 @@ export class SplitLinesCollection implements ILinesCollection {
this
.
_ensureValidState
();
viewLineNumber
=
this
.
_toValidOutputLineNumber
(
viewLineNumber
);
this
.
prefixSumComputer
.
getIndexOf
(
viewLineNumber
-
1
,
this
.
tmpIndexOfResult
);
var
lineIndex
=
this
.
tmpIndexOfResult
.
index
;
var
remainder
=
this
.
tmpIndexOfResult
.
remainder
;
let
r
=
this
.
prefixSumComputer
.
getIndexOf
(
viewLineNumber
-
1
);
let
lineIndex
=
r
.
index
;
let
remainder
=
r
.
remainder
;
var
inputColumn
=
this
.
lines
[
lineIndex
].
getInputColumnOfOutputPosition
(
remainder
,
viewColumn
);
let
inputColumn
=
this
.
lines
[
lineIndex
].
getInputColumnOfOutputPosition
(
remainder
,
viewColumn
);
// console.log('out -> in ' + viewLineNumber + ',' + viewColumn + ' ===> ' + (lineIndex+1) + ',' + inputColumn);
return
this
.
model
.
validatePosition
(
new
Position
(
lineIndex
+
1
,
inputColumn
));
}
...
...
@@ -703,9 +692,9 @@ export class SplitLinesCollection implements ILinesCollection {
// console.log('in -> out ' + inputLineNumber + ',' + inputColumn + ' ===> ' + 1 + ',' + 1);
return
new
Position
(
1
,
1
);
}
var
deltaLineNumber
=
1
+
(
lineIndex
===
0
?
0
:
this
.
prefixSumComputer
.
getAccumulatedValue
(
lineIndex
-
1
));
let
deltaLineNumber
=
1
+
(
lineIndex
===
0
?
0
:
this
.
prefixSumComputer
.
getAccumulatedValue
(
lineIndex
-
1
));
var
r
:
editorCommon
.
IEditorPosition
;
let
r
:
editorCommon
.
IEditorPosition
;
if
(
lineIndexChanged
)
{
r
=
this
.
lines
[
lineIndex
].
getOutputPositionOfInputPosition
(
deltaLineNumber
,
this
.
model
.
getLineMaxColumn
(
lineIndex
+
1
));
}
else
{
...
...
src/vs/editor/test/common/viewModel/characterHardWrappingLineMapper.test.ts
浏览文件 @
c249c6f4
...
...
@@ -7,7 +7,7 @@
import
*
as
assert
from
'
assert
'
;
import
{
WrappingIndent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CharacterHardWrappingLineMapperFactory
}
from
'
vs/editor/common/viewModel/characterHardWrappingLineMapper
'
;
import
{
ILineMapperFactory
,
ILineMapping
,
I
OutputPosition
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
ILineMapperFactory
,
ILineMapping
,
OutputPosition
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
function
safeGetOutputLineCount
(
mapper
:
ILineMapping
):
number
{
if
(
!
mapper
)
{
...
...
@@ -16,13 +16,11 @@ function safeGetOutputLineCount(mapper:ILineMapping): number {
return
mapper
.
getOutputLineCount
();
}
function
safeGetOutputPositionOfInputOffset
(
mapper
:
ILineMapping
,
inputOffset
:
number
,
result
:
IOutputPosition
):
void
{
function
safeGetOutputPositionOfInputOffset
(
mapper
:
ILineMapping
,
inputOffset
:
number
):
OutputPosition
{
if
(
!
mapper
)
{
result
.
outputLineIndex
=
0
;
result
.
outputOffset
=
inputOffset
;
return
;
return
new
OutputPosition
(
0
,
inputOffset
);
}
mapper
.
getOutputPositionOfInputOffset
(
inputOffset
,
resul
t
);
return
mapper
.
getOutputPositionOfInputOffset
(
inputOffse
t
);
}
function
safeGetInputOffsetOfOutputPosition
(
mapper
:
ILineMapping
,
outputLineIndex
:
number
,
outputOffset
:
number
):
number
{
...
...
@@ -34,26 +32,21 @@ function safeGetInputOffsetOfOutputPosition(mapper:ILineMapping, outputLineIndex
function
assertMappingIdentity
(
mapper
:
ILineMapping
,
offset
:
number
,
expectedLineIndex
:
number
)
{
var
result
=
{
outputLineIndex
:
-
1
,
outputOffset
:
-
1
};
safeGetOutputPositionOfInputOffset
(
mapper
,
offset
,
result
);
let
result
=
safeGetOutputPositionOfInputOffset
(
mapper
,
offset
);
assert
.
ok
(
result
.
outputLineIndex
!==
-
1
);
assert
.
ok
(
result
.
outputOffset
!==
-
1
);
assert
.
equal
(
result
.
outputLineIndex
,
expectedLineIndex
);
var
actualOffset
=
safeGetInputOffsetOfOutputPosition
(
mapper
,
result
.
outputLineIndex
,
result
.
outputOffset
);
let
actualOffset
=
safeGetInputOffsetOfOutputPosition
(
mapper
,
result
.
outputLineIndex
,
result
.
outputOffset
);
assert
.
equal
(
actualOffset
,
offset
);
}
function
assertLineMapping
(
factory
:
ILineMapperFactory
,
tabSize
:
number
,
breakAfter
:
number
,
annotatedText
:
string
)
{
var
rawText
=
''
;
var
currentLineIndex
=
0
;
var
lineIndices
:
number
[]
=
[];
for
(
var
i
=
0
,
len
=
annotatedText
.
length
;
i
<
len
;
i
++
)
{
let
rawText
=
''
;
let
currentLineIndex
=
0
;
let
lineIndices
:
number
[]
=
[];
for
(
let
i
=
0
,
len
=
annotatedText
.
length
;
i
<
len
;
i
++
)
{
if
(
annotatedText
.
charAt
(
i
)
===
'
|
'
)
{
currentLineIndex
++
;
}
else
{
...
...
@@ -62,10 +55,10 @@ function assertLineMapping(factory:ILineMapperFactory, tabSize:number, breakAfte
}
}
var
mapper
=
factory
.
createLineMapping
(
rawText
,
tabSize
,
breakAfter
,
1
,
WrappingIndent
.
None
);
let
mapper
=
factory
.
createLineMapping
(
rawText
,
tabSize
,
breakAfter
,
1
,
WrappingIndent
.
None
);
assert
.
equal
(
safeGetOutputLineCount
(
mapper
),
(
lineIndices
.
length
>
0
?
lineIndices
[
lineIndices
.
length
-
1
]
+
1
:
1
));
for
(
var
i
=
0
,
len
=
rawText
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
rawText
.
length
;
i
<
len
;
i
++
)
{
assertMappingIdentity
(
mapper
,
i
,
lineIndices
[
i
]);
}
}
...
...
@@ -73,7 +66,7 @@ function assertLineMapping(factory:ILineMapperFactory, tabSize:number, breakAfte
suite
(
'
Editor ViewModel - CharacterHardWrappingLineMapper
'
,
()
=>
{
test
(
'
CharacterHardWrappingLineMapper
'
,
()
=>
{
var
factory
=
new
CharacterHardWrappingLineMapperFactory
(
'
(
'
,
'
)
'
,
'
.
'
);
let
factory
=
new
CharacterHardWrappingLineMapperFactory
(
'
(
'
,
'
)
'
,
'
.
'
);
// Empty string
assertLineMapping
(
factory
,
4
,
5
,
''
);
...
...
src/vs/editor/test/common/viewModel/prefixSumComputer.test.ts
浏览文件 @
c249c6f4
...
...
@@ -5,15 +5,12 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
IPrefixSumIndexOfResult
,
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
PrefixSumComputer
,
PrefixSumIndexOfResult
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
suite
(
'
Editor ViewModel - PrefixSumComputer
'
,
()
=>
{
test
(
'
PrefixSumComputer
'
,
()
=>
{
var
indexOfResult
:
IPrefixSumIndexOfResult
=
{
index
:
0
,
remainder
:
0
};
let
indexOfResult
:
PrefixSumIndexOfResult
;
var
psc
=
new
PrefixSumComputer
([
1
,
1
,
2
,
1
,
3
]);
assert
.
equal
(
psc
.
getTotalValue
(),
8
);
...
...
@@ -23,31 +20,31 @@ suite('Editor ViewModel - PrefixSumComputer', () => {
assert
.
equal
(
psc
.
getAccumulatedValue
(
2
),
4
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
3
),
5
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
4
),
8
);
psc
.
getIndexOf
(
0
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
0
);
assert
.
equal
(
indexOfResult
.
index
,
0
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
1
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
1
);
assert
.
equal
(
indexOfResult
.
index
,
1
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
2
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
2
);
assert
.
equal
(
indexOfResult
.
index
,
2
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
3
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
3
);
assert
.
equal
(
indexOfResult
.
index
,
2
);
assert
.
equal
(
indexOfResult
.
remainder
,
1
);
psc
.
getIndexOf
(
4
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
4
);
assert
.
equal
(
indexOfResult
.
index
,
3
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
5
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
5
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
6
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
6
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
1
);
psc
.
getIndexOf
(
7
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
7
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
2
);
psc
.
getIndexOf
(
8
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
8
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
3
);
...
...
@@ -68,28 +65,28 @@ suite('Editor ViewModel - PrefixSumComputer', () => {
assert
.
equal
(
psc
.
getAccumulatedValue
(
2
),
3
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
3
),
4
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
4
),
7
);
psc
.
getIndexOf
(
0
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
0
);
assert
.
equal
(
indexOfResult
.
index
,
0
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
1
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
1
);
assert
.
equal
(
indexOfResult
.
index
,
2
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
2
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
2
);
assert
.
equal
(
indexOfResult
.
index
,
2
);
assert
.
equal
(
indexOfResult
.
remainder
,
1
);
psc
.
getIndexOf
(
3
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
3
);
assert
.
equal
(
indexOfResult
.
index
,
3
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
4
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
4
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
5
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
5
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
1
);
psc
.
getIndexOf
(
6
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
6
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
2
);
psc
.
getIndexOf
(
7
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
7
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
3
);
...
...
@@ -101,22 +98,22 @@ suite('Editor ViewModel - PrefixSumComputer', () => {
assert
.
equal
(
psc
.
getAccumulatedValue
(
2
),
1
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
3
),
2
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
4
),
5
);
psc
.
getIndexOf
(
0
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
0
);
assert
.
equal
(
indexOfResult
.
index
,
0
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
1
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
1
);
assert
.
equal
(
indexOfResult
.
index
,
3
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
2
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
2
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
3
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
3
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
1
);
psc
.
getIndexOf
(
4
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
4
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
2
);
psc
.
getIndexOf
(
5
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
5
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
3
);
...
...
@@ -128,19 +125,19 @@ suite('Editor ViewModel - PrefixSumComputer', () => {
assert
.
equal
(
psc
.
getAccumulatedValue
(
2
),
1
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
3
),
1
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
4
),
4
);
psc
.
getIndexOf
(
0
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
0
);
assert
.
equal
(
indexOfResult
.
index
,
0
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
1
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
1
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
2
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
2
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
1
);
psc
.
getIndexOf
(
3
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
3
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
2
);
psc
.
getIndexOf
(
4
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
4
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
3
);
...
...
@@ -154,19 +151,19 @@ suite('Editor ViewModel - PrefixSumComputer', () => {
assert
.
equal
(
psc
.
getAccumulatedValue
(
2
),
2
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
3
),
3
);
assert
.
equal
(
psc
.
getAccumulatedValue
(
4
),
4
);
psc
.
getIndexOf
(
0
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
0
);
assert
.
equal
(
indexOfResult
.
index
,
0
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
1
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
1
);
assert
.
equal
(
indexOfResult
.
index
,
1
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
2
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
2
);
assert
.
equal
(
indexOfResult
.
index
,
3
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
3
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
3
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
0
);
psc
.
getIndexOf
(
4
,
indexOfResult
);
indexOfResult
=
psc
.
getIndexOf
(
4
);
assert
.
equal
(
indexOfResult
.
index
,
4
);
assert
.
equal
(
indexOfResult
.
remainder
,
1
);
});
...
...
src/vs/workbench/api/node/extHostDocuments.ts
浏览文件 @
c249c6f4
...
...
@@ -8,7 +8,6 @@ import {toErrorMessage, onUnexpectedError} from 'vs/base/common/errors';
import
{
IEmitterEvent
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
*
as
EditorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
IPrefixSumIndexOfResult
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
MirrorModel2
}
from
'
vs/editor/common/model/mirrorModel2
'
;
import
{
Remotable
,
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
...
...
@@ -378,8 +377,7 @@ export class ExtHostDocumentData extends MirrorModel2 {
offset
=
Math
.
max
(
0
,
offset
);
this
.
_ensureLineStarts
();
let
out
:
IPrefixSumIndexOfResult
=
{
index
:
0
,
remainder
:
0
};
this
.
_lineStarts
.
getIndexOf
(
offset
,
out
);
let
out
=
this
.
_lineStarts
.
getIndexOf
(
offset
);
let
lineLength
=
this
.
_lines
[
out
.
index
].
length
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录