Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a3b97734
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,发现更多精彩内容 >>
提交
a3b97734
编写于
2月 22, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #21073: SplitLinesCollection: attempt to access a 'newer' model
上级
31452516
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
116 addition
and
73 deletion
+116
-73
src/vs/editor/common/viewModel/viewModelImpl.ts
src/vs/editor/common/viewModel/viewModelImpl.ts
+9
-13
src/vs/editor/test/common/viewModel/testViewModel.ts
src/vs/editor/test/common/viewModel/testViewModel.ts
+48
-0
src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts
...editor/test/common/viewModel/viewModelDecorations.test.ts
+13
-55
src/vs/editor/test/common/viewModel/viewModelImpl.test.ts
src/vs/editor/test/common/viewModel/viewModelImpl.test.ts
+44
-0
test/all.js
test/all.js
+2
-5
未找到文件。
src/vs/editor/common/viewModel/viewModelImpl.ts
浏览文件 @
a3b97734
...
...
@@ -255,7 +255,7 @@ export class ViewModel implements IViewModel {
public
getCenteredRangeInViewport
():
Range
{
if
(
this
.
_centeredViewLine
===
-
1
)
{
// Never got rendered
// Never got rendered
or not rendered since last content change event
return
null
;
}
let
viewLineNumber
=
this
.
_centeredViewLine
;
...
...
@@ -267,6 +267,7 @@ export class ViewModel implements IViewModel {
const
containsModelContentChangeEvent
=
ViewModel
.
_containsModelContentChangeEvent
(
events
);
if
(
containsModelContentChangeEvent
)
{
this
.
_centeredViewLine
=
-
1
;
this
.
configuration
.
setMaxLineNumber
(
this
.
model
.
getLineCount
());
}
...
...
@@ -284,23 +285,18 @@ export class ViewModel implements IViewModel {
previousCenteredModelRange
=
this
.
getCenteredRangeInViewport
();
}
let
i
:
number
,
len
:
number
,
e
:
EmitterEvent
,
data
:
any
,
modelContentChangedEvent
:
editorCommon
.
IModelContentChangedEvent
,
hadOtherModelChange
=
false
,
hadModelLineChangeThatChangedLineMapping
=
false
,
revealPreviousCenteredModelRange
=
false
;
let
hadOtherModelChange
=
false
;
let
hadModelLineChangeThatChangedLineMapping
=
false
;
let
revealPreviousCenteredModelRange
=
false
;
for
(
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
e
=
events
[
i
];
data
=
e
.
getData
();
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
let
e
=
events
[
i
];
let
data
=
e
.
getData
();
switch
(
e
.
getType
())
{
case
editorCommon
.
EventType
.
ModelRawContentChanged
:
modelContentChangedEvent
=
<
editorCommon
.
IModelContentChangedEvent
>
data
;
let
modelContentChangedEvent
=
<
editorCommon
.
IModelContentChangedEvent
>
data
;
switch
(
modelContentChangedEvent
.
changeType
)
{
case
editorCommon
.
EventType
.
ModelRawContentChangedFlush
:
...
...
src/vs/editor/test/common/viewModel/testViewModel.ts
0 → 100644
浏览文件 @
a3b97734
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
import
{
CharacterHardWrappingLineMapperFactory
}
from
'
vs/editor/common/viewModel/characterHardWrappingLineMapper
'
;
import
{
MockConfiguration
}
from
'
vs/editor/test/common/mocks/mockConfiguration
'
;
import
{
SplitLinesCollection
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
ViewModel
}
from
'
vs/editor/common/viewModel/viewModelImpl
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
export
function
testViewModel
(
text
:
string
[],
options
:
editorCommon
.
ICodeEditorWidgetCreationOptions
,
callback
:
(
viewModel
:
ViewModel
,
model
:
Model
)
=>
void
):
void
{
const
EDITOR_ID
=
1
;
let
configuration
=
new
MockConfiguration
(
options
);
let
model
=
Model
.
createFromString
(
text
.
join
(
'
\n
'
));
let
factory
=
new
CharacterHardWrappingLineMapperFactory
(
configuration
.
editor
.
wrappingInfo
.
wordWrapBreakBeforeCharacters
,
configuration
.
editor
.
wrappingInfo
.
wordWrapBreakAfterCharacters
,
configuration
.
editor
.
wrappingInfo
.
wordWrapBreakObtrusiveCharacters
);
let
linesCollection
=
new
SplitLinesCollection
(
model
,
factory
,
model
.
getOptions
().
tabSize
,
configuration
.
editor
.
wrappingInfo
.
wrappingColumn
,
configuration
.
editor
.
fontInfo
.
typicalFullwidthCharacterWidth
/
configuration
.
editor
.
fontInfo
.
typicalHalfwidthCharacterWidth
,
configuration
.
editor
.
wrappingInfo
.
wrappingIndent
);
let
viewModel
=
new
ViewModel
(
linesCollection
,
EDITOR_ID
,
configuration
,
model
);
callback
(
viewModel
,
model
);
viewModel
.
dispose
();
model
.
dispose
();
configuration
.
dispose
();
}
src/vs/editor/test/common/viewModel/viewModelDecorations.test.ts
浏览文件 @
a3b97734
...
...
@@ -5,63 +5,18 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
CharacterHardWrappingLineMapperFactory
}
from
'
vs/editor/common/viewModel/characterHardWrappingLineMapper
'
;
import
{
MockConfiguration
}
from
'
vs/editor/test/common/mocks/mockConfiguration
'
;
import
{
SplitLinesCollection
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
ViewModel
}
from
'
vs/editor/common/viewModel/viewModelImpl
'
;
import
{
testViewModel
}
from
'
vs/editor/test/common/viewModel/testViewModel
'
;
suite
(
'
ViewModelDecorations
'
,
()
=>
{
interface
ITestViewModelOpts
{
wrappingColumn
:
number
;
text
:
string
;
}
function
withTestViewModel
(
opts
:
ITestViewModelOpts
,
callback
:
(
viewModel
:
ViewModel
,
model
:
Model
)
=>
void
):
void
{
const
EDITOR_ID
=
1
;
let
configuration
=
new
MockConfiguration
({
wrappingColumn
:
opts
.
wrappingColumn
});
let
model
=
Model
.
createFromString
(
opts
.
text
);
let
factory
=
new
CharacterHardWrappingLineMapperFactory
(
configuration
.
editor
.
wrappingInfo
.
wordWrapBreakBeforeCharacters
,
configuration
.
editor
.
wrappingInfo
.
wordWrapBreakAfterCharacters
,
configuration
.
editor
.
wrappingInfo
.
wordWrapBreakObtrusiveCharacters
);
let
linesCollection
=
new
SplitLinesCollection
(
model
,
factory
,
model
.
getOptions
().
tabSize
,
configuration
.
editor
.
wrappingInfo
.
wrappingColumn
,
configuration
.
editor
.
fontInfo
.
typicalFullwidthCharacterWidth
/
configuration
.
editor
.
fontInfo
.
typicalHalfwidthCharacterWidth
,
configuration
.
editor
.
wrappingInfo
.
wrappingIndent
);
let
viewModel
=
new
ViewModel
(
linesCollection
,
EDITOR_ID
,
configuration
,
model
);
callback
(
viewModel
,
model
);
viewModel
.
dispose
();
model
.
dispose
();
configuration
.
dispose
();
}
test
(
'
getDecorationsViewportData
'
,
()
=>
{
withTestViewModel
({
text
:
'
hello world, this is a buffer that will be wrapped
'
,
const
text
=
[
'
hello world, this is a buffer that will be wrapped
'
];
const
opts
=
{
wrappingColumn
:
13
},
(
viewModel
,
model
)
=>
{
};
testViewModel
(
text
,
opts
,
(
viewModel
,
model
)
=>
{
assert
.
equal
(
viewModel
.
getLineContent
(
1
),
'
hello world,
'
);
assert
.
equal
(
viewModel
.
getLineContent
(
2
),
'
this is a
'
);
assert
.
equal
(
viewModel
.
getLineContent
(
3
),
'
buffer that
'
);
...
...
@@ -309,10 +264,13 @@ suite('ViewModelDecorations', () => {
});
test
(
'
issue #17208: Problem scrolling in 1.8.0
'
,
()
=>
{
withTestViewModel
({
text
:
'
hello world, this is a buffer that will be wrapped
'
,
const
text
=
[
'
hello world, this is a buffer that will be wrapped
'
];
const
opts
=
{
wrappingColumn
:
13
},
(
viewModel
,
model
)
=>
{
};
testViewModel
(
text
,
opts
,
(
viewModel
,
model
)
=>
{
assert
.
equal
(
viewModel
.
getLineContent
(
1
),
'
hello world,
'
);
assert
.
equal
(
viewModel
.
getLineContent
(
2
),
'
this is a
'
);
assert
.
equal
(
viewModel
.
getLineContent
(
3
),
'
buffer that
'
);
...
...
src/vs/editor/test/common/viewModel/viewModelImpl.test.ts
0 → 100644
浏览文件 @
a3b97734
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
testViewModel
}
from
'
vs/editor/test/common/viewModel/testViewModel
'
;
suite
(
'
ViewModel
'
,
()
=>
{
test
(
'
issue #21073: SplitLinesCollection: attempt to access a
\'
newer
\'
model
'
,
()
=>
{
const
text
=
[
''
];
const
opts
=
{
lineNumbersMinChars
:
1
};
testViewModel
(
text
,
opts
,
(
viewModel
,
model
)
=>
{
assert
.
equal
(
viewModel
.
getLineCount
(),
1
);
viewModel
.
setViewport
(
1
,
1
,
1
);
model
.
applyEdits
([{
identifier
:
null
,
range
:
new
Range
(
1
,
1
,
1
,
1
),
text
:
[
'
line01
'
,
'
line02
'
,
'
line03
'
,
'
line04
'
,
'
line05
'
,
'
line06
'
,
'
line07
'
,
'
line08
'
,
'
line09
'
,
'
line10
'
,
].
join
(
'
\n
'
),
forceMoveMarkers
:
false
}]);
assert
.
equal
(
viewModel
.
getLineCount
(),
10
);
});
});
});
test/all.js
浏览文件 @
a3b97734
...
...
@@ -254,11 +254,8 @@ function main() {
// replace the default unexpected error handler to be useful during tests
loader
([
'
vs/base/common/errors
'
],
function
(
errors
)
{
errors
.
setUnexpectedErrorHandler
(
function
(
err
)
{
try
{
throw
new
Error
(
'
oops
'
);
}
catch
(
e
)
{
unexpectedErrors
.
push
((
err
&&
err
.
message
?
err
.
message
:
err
)
+
'
\n
'
+
e
.
stack
);
}
let
stack
=
(
err
&&
err
.
stack
)
||
(
new
Error
().
stack
);
unexpectedErrors
.
push
((
err
&&
err
.
message
?
err
.
message
:
err
)
+
'
\n
'
+
stack
);
});
// fire up mocha
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录