Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
53125e31
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,发现更多精彩内容 >>
未验证
提交
53125e31
编写于
1月 13, 2020
作者:
A
Alexandru Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass in entire fontInfo when computing line breaks
上级
314d0e12
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
33 deletion
+48
-33
src/vs/editor/browser/view/domLineBreaksComputer.ts
src/vs/editor/browser/view/domLineBreaksComputer.ts
+6
-12
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+1
-1
src/vs/editor/common/viewModel/monospaceLineBreaksComputer.ts
...vs/editor/common/viewModel/monospaceLineBreaksComputer.ts
+3
-2
src/vs/editor/common/viewModel/splitLinesCollection.ts
src/vs/editor/common/viewModel/splitLinesCollection.ts
+17
-13
src/vs/editor/common/viewModel/viewModelImpl.ts
src/vs/editor/common/viewModel/viewModelImpl.ts
+2
-2
src/vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test.ts
...test/common/viewModel/monospaceLineBreaksComputer.test.ts
+17
-1
src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts
...editor/test/common/viewModel/splitLinesCollection.test.ts
+2
-2
未找到文件。
src/vs/editor/browser/view/domLineBreaksComputer.ts
浏览文件 @
53125e31
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
ILineBreaksComputerFactory
,
LineBreakData
,
ILineBreaksComputer
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
IComputedEditorOptions
,
EditorOption
,
WrappingIndent
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
WrappingIndent
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
FontInfo
}
from
'
vs/editor/common/config/fontInfo
'
;
import
{
createStringBuilder
,
IStringBuilder
}
from
'
vs/editor/common/core/stringBuilder
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
...
...
@@ -13,22 +13,16 @@ import { Configuration } from 'vs/editor/browser/config/configuration';
export
class
DOMLineBreaksComputerFactory
implements
ILineBreaksComputerFactory
{
public
static
create
(
options
:
IComputedEditorOptions
):
DOMLineBreaksComputerFactory
{
return
new
DOMLineBreaksComputerFactory
(
options
.
get
(
EditorOption
.
fontInfo
)
);
public
static
create
():
DOMLineBreaksComputerFactory
{
return
new
DOMLineBreaksComputerFactory
();
}
private
_fontInfo
:
FontInfo
;
constructor
(
fontInfo
:
FontInfo
)
{
this
.
_fontInfo
=
fontInfo
;
constructor
()
{
}
public
createLineBreaksComputer
(
tabSize
:
number
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
,
wrappingIndent
:
WrappingIndent
):
ILineBreaksComputer
{
public
createLineBreaksComputer
(
fontInfo
:
FontInfo
,
tabSize
:
number
,
wrappingColumn
:
number
,
wrappingIndent
:
WrappingIndent
):
ILineBreaksComputer
{
tabSize
=
tabSize
|
0
;
//@perf
wrappingColumn
=
+
wrappingColumn
;
//@perf
columnsForFullWidthChar
=
+
columnsForFullWidthChar
;
//@perf
let
requests
:
string
[]
=
[];
return
{
...
...
@@ -36,7 +30,7 @@ export class DOMLineBreaksComputerFactory implements ILineBreaksComputerFactory
requests
.
push
(
lineText
);
},
finalize
:
()
=>
{
return
createLineBreaks
(
requests
,
this
.
_
fontInfo
,
tabSize
,
wrappingColumn
,
wrappingIndent
);
return
createLineBreaks
(
requests
,
fontInfo
,
tabSize
,
wrappingColumn
,
wrappingIndent
);
}
};
}
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
53125e31
...
...
@@ -1342,7 +1342,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
this
.
_id
,
this
.
_configuration
,
model
,
DOMLineBreaksComputerFactory
.
create
(
this
.
_configuration
.
options
),
DOMLineBreaksComputerFactory
.
create
(),
MonospaceLineBreaksComputerFactory
.
create
(
this
.
_configuration
.
options
),
(
callback
)
=>
dom
.
scheduleAtNextAnimationFrame
(
callback
)
);
...
...
src/vs/editor/common/viewModel/monospaceLineBreaksComputer.ts
浏览文件 @
53125e31
...
...
@@ -8,6 +8,7 @@ import * as strings from 'vs/base/common/strings';
import
{
WrappingIndent
,
IComputedEditorOptions
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CharacterClassifier
}
from
'
vs/editor/common/core/characterClassifier
'
;
import
{
ILineBreaksComputerFactory
,
LineBreakData
,
ILineBreaksComputer
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
FontInfo
}
from
'
vs/editor/common/config/fontInfo
'
;
const
enum
CharacterClass
{
NONE
=
0
,
...
...
@@ -69,10 +70,9 @@ export class MonospaceLineBreaksComputerFactory implements ILineBreaksComputerFa
this
.
classifier
=
new
WrappingCharacterClassifier
(
breakBeforeChars
,
breakAfterChars
);
}
public
createLineBreaksComputer
(
tabSize
:
number
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
,
wrappingIndent
:
WrappingIndent
):
ILineBreaksComputer
{
public
createLineBreaksComputer
(
fontInfo
:
FontInfo
,
tabSize
:
number
,
wrappingColumn
:
number
,
wrappingIndent
:
WrappingIndent
):
ILineBreaksComputer
{
tabSize
=
tabSize
|
0
;
//@perf
wrappingColumn
=
+
wrappingColumn
;
//@perf
columnsForFullWidthChar
=
+
columnsForFullWidthChar
;
//@perf
let
requests
:
string
[]
=
[];
let
previousBreakingData
:
(
LineBreakData
|
null
)[]
=
[];
...
...
@@ -82,6 +82,7 @@ export class MonospaceLineBreaksComputerFactory implements ILineBreaksComputerFa
previousBreakingData
.
push
(
previousLineBreakData
);
},
finalize
:
()
=>
{
const
columnsForFullWidthChar
=
fontInfo
.
typicalFullwidthCharacterWidth
/
fontInfo
.
typicalHalfwidthCharacterWidth
;
//@perf
let
result
:
(
LineBreakData
|
null
)[]
=
[];
for
(
let
i
=
0
,
len
=
requests
.
length
;
i
<
len
;
i
++
)
{
const
previousLineBreakData
=
previousBreakingData
[
i
];
...
...
src/vs/editor/common/viewModel/splitLinesCollection.ts
浏览文件 @
53125e31
...
...
@@ -15,6 +15,7 @@ import { PrefixSumIndexOfResult } from 'vs/editor/common/viewModel/prefixSumComp
import
{
ICoordinatesConverter
,
IOverviewRulerDecorations
,
ViewLineData
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
ITheme
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
FontInfo
}
from
'
vs/editor/common/config/fontInfo
'
;
export
class
OutputPosition
{
outputLineIndex
:
number
;
...
...
@@ -75,7 +76,7 @@ export interface ILineBreaksComputer {
}
export
interface
ILineBreaksComputerFactory
{
createLineBreaksComputer
(
tabSize
:
number
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
,
wrappingIndent
:
WrappingIndent
):
ILineBreaksComputer
;
createLineBreaksComputer
(
fontInfo
:
FontInfo
,
tabSize
:
number
,
wrappingColumn
:
number
,
wrappingIndent
:
WrappingIndent
):
ILineBreaksComputer
;
}
export
interface
ISimpleModel
{
...
...
@@ -108,7 +109,7 @@ export interface ISplitLine {
export
interface
IViewModelLinesCollection
extends
IDisposable
{
createCoordinatesConverter
():
ICoordinatesConverter
;
setWrappingSettings
(
wrappingIndent
:
WrappingIndent
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
):
boolean
;
setWrappingSettings
(
fontInfo
:
FontInfo
,
wrappingColumn
:
number
,
wrappingIndent
:
WrappingIndent
):
boolean
;
setTabSize
(
newTabSize
:
number
):
boolean
;
getHiddenAreas
():
Range
[];
setHiddenAreas
(
_ranges
:
Range
[]):
boolean
;
...
...
@@ -274,10 +275,10 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
private
readonly
_domLineBreaksComputerFactory
:
ILineBreaksComputerFactory
;
private
readonly
_monospaceLineBreaksComputerFactory
:
ILineBreaksComputerFactory
;
private
fontInfo
:
FontInfo
;
private
tabSize
:
number
;
private
wrappingColumn
:
number
;
private
columnsForFullWidthChar
:
number
;
private
wrappingIndent
:
WrappingIndent
;
private
tabSize
:
number
;
private
lines
!
:
ISplitLine
[];
private
prefixSumComputer
!
:
LineNumberMapper
;
...
...
@@ -288,18 +289,18 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
model
:
ITextModel
,
domLineBreaksComputerFactory
:
ILineBreaksComputerFactory
,
monospaceLineBreaksComputerFactory
:
ILineBreaksComputerFactory
,
fontInfo
:
FontInfo
,
tabSize
:
number
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
,
wrappingIndent
:
WrappingIndent
)
{
this
.
model
=
model
;
this
.
_validModelVersionId
=
-
1
;
this
.
_domLineBreaksComputerFactory
=
domLineBreaksComputerFactory
;
this
.
_monospaceLineBreaksComputerFactory
=
monospaceLineBreaksComputerFactory
;
this
.
fontInfo
=
fontInfo
;
this
.
tabSize
=
tabSize
;
this
.
wrappingColumn
=
wrappingColumn
;
this
.
columnsForFullWidthChar
=
columnsForFullWidthChar
;
this
.
wrappingIndent
=
wrappingIndent
;
this
.
_constructLines
(
/*resetHiddenAreas*/
true
,
null
);
...
...
@@ -482,16 +483,19 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
return
true
;
}
public
setWrappingSettings
(
wrappingIndent
:
WrappingIndent
,
wrappingColumn
:
number
,
columnsForFullWidthChar
:
number
):
boolean
{
if
(
this
.
wrappingIndent
===
wrappingIndent
&&
this
.
wrappingColumn
===
wrappingColumn
&&
this
.
columnsForFullWidthChar
===
columnsForFullWidthChar
)
{
public
setWrappingSettings
(
fontInfo
:
FontInfo
,
wrappingColumn
:
number
,
wrappingIndent
:
WrappingIndent
):
boolean
{
const
equalFontInfo
=
this
.
fontInfo
.
equals
(
fontInfo
);
const
equalWrappingColumn
=
(
this
.
wrappingColumn
===
wrappingColumn
);
const
equalWrappingIndent
=
(
this
.
wrappingIndent
===
wrappingIndent
);
if
(
equalFontInfo
&&
equalWrappingColumn
&&
equalWrappingIndent
)
{
return
false
;
}
const
onlyWrappingColumnChanged
=
(
this
.
wrappingIndent
===
wrappingIndent
&&
this
.
wrappingColumn
!==
wrappingColumn
&&
this
.
columnsForFullWidthChar
===
columnsForFullWidthChar
);
const
onlyWrappingColumnChanged
=
(
equalFontInfo
&&
!
equalWrappingColumn
&&
equalWrappingIndent
);
this
.
wrappingIndent
=
wrappingIndent
;
this
.
fontInfo
=
fontInfo
;
this
.
wrappingColumn
=
wrappingColumn
;
this
.
columnsForFullWidthChar
=
columnsForFullWidthChar
;
this
.
wrappingIndent
=
wrappingIndent
;
let
previousLineBreaks
:
((
LineBreakData
|
null
)[])
|
null
=
null
;
if
(
onlyWrappingColumnChanged
)
{
...
...
@@ -512,7 +516,7 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
?
this
.
_domLineBreaksComputerFactory
:
this
.
_monospaceLineBreaksComputerFactory
);
return
lineBreaksComputerFactory
.
createLineBreaksComputer
(
this
.
tabSize
,
this
.
wrappingColumn
,
this
.
columnsForFullWidthChar
,
this
.
wrappingIndent
);
return
lineBreaksComputerFactory
.
createLineBreaksComputer
(
this
.
fontInfo
,
this
.
tabSize
,
this
.
wrappingColumn
,
this
.
wrappingIndent
);
}
public
onModelFlushed
():
void
{
...
...
@@ -1453,7 +1457,7 @@ export class IdentityLinesCollection implements IViewModelLinesCollection {
return
false
;
}
public
setWrappingSettings
(
_
wrappingIndent
:
WrappingIndent
,
_wrappingColumn
:
number
,
_columnsForFullWidthChar
:
number
):
boolean
{
public
setWrappingSettings
(
_
fontInfo
:
FontInfo
,
_wrappingColumn
:
number
,
_wrappingIndent
:
WrappingIndent
):
boolean
{
return
false
;
}
...
...
src/vs/editor/common/viewModel/viewModelImpl.ts
浏览文件 @
53125e31
...
...
@@ -75,9 +75,9 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
model
,
domLineBreaksComputerFactory
,
monospaceLineBreaksComputerFactory
,
fontInfo
,
this
.
model
.
getOptions
().
tabSize
,
wrappingInfo
.
wrappingColumn
,
fontInfo
.
typicalFullwidthCharacterWidth
/
fontInfo
.
typicalHalfwidthCharacterWidth
,
wrappingIndent
);
}
...
...
@@ -157,7 +157,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
const
fontInfo
=
options
.
get
(
EditorOption
.
fontInfo
);
const
wrappingIndent
=
options
.
get
(
EditorOption
.
wrappingIndent
);
if
(
this
.
lines
.
setWrappingSettings
(
wrappingIndent
,
wrappingInfo
.
wrappingColumn
,
fontInfo
.
typicalFullwidthCharacterWidth
/
fontInfo
.
typicalHalfwidthCharacterWidth
))
{
if
(
this
.
lines
.
setWrappingSettings
(
fontInfo
,
wrappingInfo
.
wrappingColumn
,
wrappingIndent
))
{
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
());
...
...
src/vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test.ts
浏览文件 @
53125e31
...
...
@@ -6,6 +6,7 @@ import * as assert from 'assert';
import
{
WrappingIndent
,
EditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
MonospaceLineBreaksComputerFactory
}
from
'
vs/editor/common/viewModel/monospaceLineBreaksComputer
'
;
import
{
ILineBreaksComputerFactory
,
LineBreakData
}
from
'
vs/editor/common/viewModel/splitLinesCollection
'
;
import
{
FontInfo
}
from
'
vs/editor/common/config/fontInfo
'
;
function
parseAnnotatedText
(
annotatedText
:
string
):
{
text
:
string
;
indices
:
number
[];
}
{
let
text
=
''
;
...
...
@@ -43,7 +44,22 @@ function toAnnotatedText(text: string, lineBreakData: LineBreakData | null): str
}
function
getLineBreakData
(
factory
:
ILineBreaksComputerFactory
,
tabSize
:
number
,
breakAfter
:
number
,
columnsForFullWidthChar
:
number
,
wrappingIndent
:
WrappingIndent
,
text
:
string
,
previousLineBreakData
:
LineBreakData
|
null
):
LineBreakData
|
null
{
const
lineBreaksComputer
=
factory
.
createLineBreaksComputer
(
tabSize
,
breakAfter
,
columnsForFullWidthChar
,
wrappingIndent
);
const
fontInfo
=
new
FontInfo
({
zoomLevel
:
0
,
fontFamily
:
'
testFontFamily
'
,
fontWeight
:
'
normal
'
,
fontSize
:
14
,
fontFeatureSettings
:
''
,
lineHeight
:
19
,
letterSpacing
:
0
,
isMonospace
:
true
,
typicalHalfwidthCharacterWidth
:
7
,
typicalFullwidthCharacterWidth
:
14
,
canUseHalfwidthRightwardsArrow
:
true
,
spaceWidth
:
7
,
maxDigitWidth
:
7
},
false
);
const
lineBreaksComputer
=
factory
.
createLineBreaksComputer
(
fontInfo
,
tabSize
,
breakAfter
,
wrappingIndent
);
const
previousLineBreakDataClone
=
previousLineBreakData
?
new
LineBreakData
(
previousLineBreakData
.
breakOffsets
.
slice
(
0
),
previousLineBreakData
.
breakOffsetsVisibleColumn
.
slice
(
0
),
previousLineBreakData
.
wrappedTextIndentLength
)
:
null
;
lineBreaksComputer
.
addRequest
(
text
,
previousLineBreakDataClone
);
return
lineBreaksComputer
.
finalize
()[
0
];
...
...
src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts
浏览文件 @
53125e31
...
...
@@ -109,9 +109,9 @@ suite('Editor ViewModel - SplitLinesCollection', () => {
model
,
lineBreaksComputerFactory
,
lineBreaksComputerFactory
,
fontInfo
,
model
.
getOptions
().
tabSize
,
wrappingInfo
.
wrappingColumn
,
fontInfo
.
typicalFullwidthCharacterWidth
/
fontInfo
.
typicalHalfwidthCharacterWidth
,
wrappingIndent
);
...
...
@@ -750,9 +750,9 @@ suite('SplitLinesCollection', () => {
model
,
lineBreaksComputerFactory
,
lineBreaksComputerFactory
,
fontInfo
,
model
.
getOptions
().
tabSize
,
wrappingInfo
.
wrappingColumn
,
fontInfo
.
typicalFullwidthCharacterWidth
/
fontInfo
.
typicalHalfwidthCharacterWidth
,
wrappingIndent
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录