@@ -42,11 +42,27 @@ export class DOMLineBreaksComputerFactory implements ILineBreaksComputerFactory
42
42
}
43
43
}
44
44
45
- function createLineBreaks ( requests : string [ ] , fontInfo : FontInfo , tabSize : number , firstLineBreakColumn : number , wrappingIndent : WrappingIndent , injectedTexts : ( LineInjectedText [ ] | null ) [ ] ) : ( LineBreakData | null ) [ ] {
45
+ function createLineBreaks ( requests : string [ ] , fontInfo : FontInfo , tabSize : number , firstLineBreakColumn : number , wrappingIndent : WrappingIndent , injectedTextsPerLine : ( LineInjectedText [ ] | null ) [ ] ) : ( LineBreakData | null ) [ ] {
46
+ function createEmptyLineBreakWithPossiblyInjectedText ( requestIdx : number ) : LineBreakData | null {
47
+ const injectedTexts = injectedTextsPerLine [ requestIdx ] ;
48
+ if ( injectedTexts ) {
49
+ const lineText = LineInjectedText . applyInjectedText ( requests [ requestIdx ] , injectedTexts ) ;
50
+
51
+ const injectionTexts = injectedTexts . map ( t => t . text ) ;
52
+ const injectionOffsets = injectedTexts . map ( text => text . column - 1 ) ;
53
+
54
+ // creating a `LineBreakData` with an invalid `breakOffsetsVisibleColumn` is OK
55
+ // because `breakOffsetsVisibleColumn` will never be used because it contains injected text
56
+ return new LineBreakData ( [ lineText . length ] , [ ] , 0 , injectionTexts , injectionOffsets ) ;
57
+ } else {
58
+ return null ;
59
+ }
60
+ }
61
+
46
62
if ( firstLineBreakColumn === - 1 ) {
47
- const result : null [ ] = [ ] ;
63
+ const result : ( LineBreakData | null ) [ ] = [ ] ;
48
64
for ( let i = 0 , len = requests . length ; i < len ; i ++ ) {
49
- result [ i ] = null ;
65
+ result [ i ] = createEmptyLineBreakWithPossiblyInjectedText ( i ) ;
50
66
}
51
67
return result ;
52
68
}
@@ -69,7 +85,7 @@ function createLineBreaks(requests: string[], fontInfo: FontInfo, tabSize: numbe
69
85
const allCharOffsets : number [ ] [ ] = [ ] ;
70
86
const allVisibleColumns : number [ ] [ ] = [ ] ;
71
87
for ( let i = 0 ; i < requests . length ; i ++ ) {
72
- const lineContent = LineInjectedText . applyInjectedText ( requests [ i ] , injectedTexts [ i ] ) ;
88
+ const lineContent = LineInjectedText . applyInjectedText ( requests [ i ] , injectedTextsPerLine [ i ] ) ;
73
89
74
90
let firstNonWhitespaceIndex = 0 ;
75
91
let wrappedTextIndentLength = 0 ;
@@ -130,7 +146,7 @@ function createLineBreaks(requests: string[], fontInfo: FontInfo, tabSize: numbe
130
146
const lineDomNode = lineDomNodes [ i ] ;
131
147
const breakOffsets : number [ ] | null = readLineBreaks ( range , lineDomNode , renderLineContents [ i ] , allCharOffsets [ i ] ) ;
132
148
if ( breakOffsets === null ) {
133
- result [ i ] = null ;
149
+ result [ i ] = createEmptyLineBreakWithPossiblyInjectedText ( i ) ;
134
150
continue ;
135
151
}
136
152
@@ -152,7 +168,7 @@ function createLineBreaks(requests: string[], fontInfo: FontInfo, tabSize: numbe
152
168
153
169
let injectionTexts : string [ ] | null ;
154
170
let injectionOffsets : number [ ] | null ;
155
- const curInjectedTexts = injectedTexts [ i ] ;
171
+ const curInjectedTexts = injectedTextsPerLine [ i ] ;
156
172
if ( curInjectedTexts ) {
157
173
injectionTexts = curInjectedTexts . map ( t => t . text ) ;
158
174
injectionOffsets = curInjectedTexts . map ( text => text . column - 1 ) ;
0 commit comments