Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eb1d2a52
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,发现更多精彩内容 >>
提交
eb1d2a52
编写于
7月 06, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add and use `IdentityCoordinatesConverter` (#30180)
上级
810164ab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
189 addition
and
15 deletion
+189
-15
src/vs/editor/common/viewModel/splitLinesCollection.ts
src/vs/editor/common/viewModel/splitLinesCollection.ts
+166
-0
src/vs/editor/common/viewModel/viewModelImpl.ts
src/vs/editor/common/viewModel/viewModelImpl.ts
+23
-15
未找到文件。
src/vs/editor/common/viewModel/splitLinesCollection.ts
浏览文件 @
eb1d2a52
...
...
@@ -928,3 +928,169 @@ function createSplitLine(linePositionMapperFactory: ILineMapperFactory, text: st
return
new
SplitLine
(
positionMapper
,
isVisible
);
}
}
export
class
IdentityCoordinatesConverter
implements
ICoordinatesConverter
{
private
readonly
_lines
:
IdentityLinesCollection
;
constructor
(
lines
:
IdentityLinesCollection
)
{
this
.
_lines
=
lines
;
}
private
_validPosition
(
pos
:
Position
):
Position
{
return
this
.
_lines
.
model
.
validatePosition
(
pos
);
}
private
_validRange
(
range
:
Range
):
Range
{
return
this
.
_lines
.
model
.
validateRange
(
range
);
}
private
_validSelection
(
selection
:
Selection
):
Selection
{
let
selectionStart
=
this
.
_validPosition
(
new
Position
(
selection
.
selectionStartLineNumber
,
selection
.
selectionStartColumn
));
let
position
=
this
.
_validPosition
(
new
Position
(
selection
.
positionLineNumber
,
selection
.
positionColumn
));
return
new
Selection
(
selectionStart
.
lineNumber
,
selectionStart
.
column
,
position
.
lineNumber
,
position
.
column
);
}
// View -> Model conversion and related methods
public
convertViewPositionToModelPosition
(
viewPosition
:
Position
):
Position
{
return
this
.
_validPosition
(
viewPosition
);
}
public
convertViewRangeToModelRange
(
viewRange
:
Range
):
Range
{
return
this
.
_validRange
(
viewRange
);
}
public
convertViewSelectionToModelSelection
(
viewSelection
:
Selection
):
Selection
{
return
this
.
_validSelection
(
viewSelection
);
}
public
validateViewPosition
(
viewPosition
:
Position
,
expectedModelPosition
:
Position
):
Position
{
return
this
.
_validPosition
(
expectedModelPosition
);
}
public
validateViewRange
(
viewRange
:
Range
,
expectedModelRange
:
Range
):
Range
{
return
this
.
_validRange
(
expectedModelRange
);
}
// Model -> View conversion and related methods
public
convertModelPositionToViewPosition
(
modelPosition
:
Position
):
Position
{
return
this
.
_validPosition
(
modelPosition
);
}
public
convertModelRangeToViewRange
(
modelRange
:
Range
):
Range
{
return
this
.
_validRange
(
modelRange
);
}
public
convertModelSelectionToViewSelection
(
modelSelection
:
Selection
):
Selection
{
return
this
.
_validSelection
(
modelSelection
);
}
public
modelPositionIsVisible
(
modelPosition
:
Position
):
boolean
{
const
lineCount
=
this
.
_lines
.
model
.
getLineCount
();
if
(
modelPosition
.
lineNumber
<
1
||
modelPosition
.
lineNumber
>
lineCount
)
{
// invalid arguments
return
false
;
}
return
true
;
}
}
export
class
IdentityLinesCollection
implements
IViewModelLinesCollection
{
public
readonly
model
:
editorCommon
.
IModel
;
constructor
(
model
:
editorCommon
.
IModel
)
{
this
.
model
=
model
;
}
public
dispose
():
void
{
}
public
createCoordinatesConverter
():
ICoordinatesConverter
{
return
new
IdentityCoordinatesConverter
(
this
);
}
public
setHiddenAreas
(
_ranges
:
Range
[]):
boolean
{
return
false
;
}
public
setTabSize
(
newTabSize
:
number
):
boolean
{
return
false
;
}
public
setWrappingSettings
(
wrappingIndent
:
WrappingIndent
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
):
boolean
{
return
false
;
}
public
onModelFlushed
():
void
{
}
public
onModelLinesDeleted
(
versionId
:
number
,
fromLineNumber
:
number
,
toLineNumber
:
number
):
viewEvents
.
ViewLinesDeletedEvent
{
return
new
viewEvents
.
ViewLinesDeletedEvent
(
fromLineNumber
,
toLineNumber
);
}
public
onModelLinesInserted
(
versionId
:
number
,
fromLineNumber
:
number
,
toLineNumber
:
number
,
text
:
string
[]):
viewEvents
.
ViewLinesInsertedEvent
{
return
new
viewEvents
.
ViewLinesInsertedEvent
(
fromLineNumber
,
toLineNumber
);
}
public
onModelLineChanged
(
versionId
:
number
,
lineNumber
:
number
,
newText
:
string
):
[
boolean
,
viewEvents
.
ViewLinesChangedEvent
,
viewEvents
.
ViewLinesInsertedEvent
,
viewEvents
.
ViewLinesDeletedEvent
]
{
return
[
false
,
new
viewEvents
.
ViewLinesChangedEvent
(
lineNumber
,
lineNumber
),
null
,
null
];
}
public
acceptVersionId
(
versionId
:
number
):
void
{
}
public
getViewLineCount
():
number
{
return
this
.
model
.
getLineCount
();
}
public
warmUpLookupCache
(
viewStartLineNumber
:
number
,
viewEndLineNumber
:
number
):
void
{
}
public
getViewLineIndentGuide
(
viewLineNumber
:
number
):
number
{
return
0
;
}
public
getViewLineContent
(
viewLineNumber
:
number
):
string
{
return
this
.
model
.
getLineContent
(
viewLineNumber
);
}
public
getViewLineMinColumn
(
viewLineNumber
:
number
):
number
{
return
this
.
model
.
getLineMinColumn
(
viewLineNumber
);
}
public
getViewLineMaxColumn
(
viewLineNumber
:
number
):
number
{
return
this
.
model
.
getLineMaxColumn
(
viewLineNumber
);
}
public
getViewLineData
(
viewLineNumber
:
number
):
ViewLineData
{
let
lineTokens
=
this
.
model
.
getLineTokens
(
viewLineNumber
);
let
lineContent
=
lineTokens
.
getLineContent
();
return
new
ViewLineData
(
lineContent
,
1
,
lineContent
.
length
+
1
,
lineTokens
.
inflate
()
);
}
public
getViewLinesData
(
viewStartLineNumber
:
number
,
viewEndLineNumber
:
number
,
needed
:
boolean
[]):
ViewLineData
[]
{
const
lineCount
=
this
.
model
.
getLineCount
();
viewStartLineNumber
=
Math
.
min
(
Math
.
max
(
1
,
viewStartLineNumber
),
lineCount
);
viewEndLineNumber
=
Math
.
min
(
Math
.
max
(
1
,
viewEndLineNumber
),
lineCount
);
let
result
:
ViewLineData
[]
=
[];
for
(
let
lineNumber
=
viewStartLineNumber
;
lineNumber
<=
viewEndLineNumber
;
lineNumber
++
)
{
let
idx
=
lineNumber
-
viewStartLineNumber
;
if
(
!
needed
[
idx
])
{
result
[
idx
]
=
null
;
}
result
[
idx
]
=
this
.
getViewLineData
(
lineNumber
);
}
return
result
;
}
}
src/vs/editor/common/viewModel/viewModelImpl.ts
浏览文件 @
eb1d2a52
...
...
@@ -13,7 +13,7 @@ import { TokenizationRegistry, ColorId, LanguageId } from 'vs/editor/common/mode
import
{
tokenizeLineToHTML
}
from
'
vs/editor/common/modes/textToHtmlTokenizer
'
;
import
{
ViewModelDecorations
}
from
'
vs/editor/common/viewModel/viewModelDecorations
'
;
import
{
MinimapLinesRenderingData
,
ViewLineRenderingData
,
ViewModelDecoration
,
IViewModel
,
ICoordinatesConverter
,
ViewEventsCollector
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
SplitLinesCollection
,
IViewModelLinesCollection
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
SplitLinesCollection
,
IViewModelLinesCollection
,
IdentityLinesCollection
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
{
MinimapTokensColorTracker
}
from
'
vs/editor/common/view/minimapCharRenderer
'
;
import
*
as
textModelEvents
from
'
vs/editor/common/model/textModelEvents
'
;
...
...
@@ -21,6 +21,8 @@ import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOption
import
{
CharacterHardWrappingLineMapperFactory
}
from
'
vs/editor/common/viewModel/characterHardWrappingLineMapper
'
;
import
{
ViewLayout
}
from
'
vs/editor/common/viewLayout/viewLayout
'
;
const
USE_IDENTITY_LINES_COLLECTION
=
true
;
export
class
ViewModel
extends
viewEvents
.
ViewEventEmitter
implements
IViewModel
{
private
readonly
editorId
:
number
;
...
...
@@ -42,22 +44,28 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
configuration
=
configuration
;
this
.
model
=
model
;
const
conf
=
this
.
configuration
.
editor
;
if
(
USE_IDENTITY_LINES_COLLECTION
&&
this
.
model
.
isTooLargeForTokenization
())
{
let
hardWrappingLineMapperFactory
=
new
CharacterHardWrappingLineMapperFactory
(
conf
.
wrappingInfo
.
wordWrapBreakBeforeCharacters
,
conf
.
wrappingInfo
.
wordWrapBreakAfterCharacters
,
conf
.
wrappingInfo
.
wordWrapBreakObtrusiveCharacters
);
this
.
lines
=
new
IdentityLinesCollection
(
this
.
model
);
this
.
lines
=
new
SplitLinesCollection
(
this
.
model
,
hardWrappingLineMapperFactory
,
this
.
model
.
getOptions
().
tabSize
,
conf
.
wrappingInfo
.
wrappingColumn
,
conf
.
fontInfo
.
typicalFullwidthCharacterWidth
/
conf
.
fontInfo
.
typicalHalfwidthCharacterWidth
,
conf
.
wrappingInfo
.
wrappingIndent
);
}
else
{
const
conf
=
this
.
configuration
.
editor
;
let
hardWrappingLineMapperFactory
=
new
CharacterHardWrappingLineMapperFactory
(
conf
.
wrappingInfo
.
wordWrapBreakBeforeCharacters
,
conf
.
wrappingInfo
.
wordWrapBreakAfterCharacters
,
conf
.
wrappingInfo
.
wordWrapBreakObtrusiveCharacters
);
this
.
lines
=
new
SplitLinesCollection
(
this
.
model
,
hardWrappingLineMapperFactory
,
this
.
model
.
getOptions
().
tabSize
,
conf
.
wrappingInfo
.
wrappingColumn
,
conf
.
fontInfo
.
typicalFullwidthCharacterWidth
/
conf
.
fontInfo
.
typicalHalfwidthCharacterWidth
,
conf
.
wrappingInfo
.
wrappingIndent
);
}
this
.
coordinatesConverter
=
this
.
lines
.
createCoordinatesConverter
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录