monospaceLineBreaksComputer.ts ×15

Frontier kind: Code frontier

unlabeled · c_78ad252d31c8

3 tests · 15629 LOC · 44 files · introduces 0 tests · 206 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges206 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1379 ranges15629 lines · 44 files · Browse complete extent
All tests (intent)
3 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationmonospaceLineBreaksComputer.ts ×4 · 13 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 7 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 8 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 8 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #33366: Word wrap algorithm behaves differently around punctuation|occurrence=1, monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #152773: Word wrap algorithm behaves differently with bracket followed by comma|occurrence=1 · 0 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 3 introduced LOCmonospaceLineBreaksCompu…modelLineProjectionData.ts ×1 · 1 introduced LOCmodelLineProjectionData.…monospaceLineBreaksComputer.ts ×1 · 4 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×3 · 17 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×4 · 14 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 10 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×2 · 4 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 3 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×1 · 2 introduced LOCmonospaceLineBreaksCompu…monospaceLineBreaksComputer.ts ×24 · 170 introduced LOCmonospaceLineBreaksCompu…modelLineProjectionData.ts ×2 · 5 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×4 · 32 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×1 · 17 introduced LOCmodelLineProjectionData.…modelLineProjectionData.ts ×18 · 97 introduced LOCmodelLineProjectionData.…textModelEvents.ts ×25 · 438 introduced LOCtextModelEvents.ts ×25editorOptions.ts ×92 · 6015 introduced LOCeditorOptions.ts ×92contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×3 · 7 introduced LOCcontextkey.ts ×3contextkey.ts ×1 · 3 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 3 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 4 introduced LOCcontextkey.ts ×1contextkey.ts ×201 · 796 introduced LOCcontextkey.ts ×201strings.ts ×1 · 2 introduced LOCstrings.ts ×1strings.ts ×2 · 3 introduced LOCstrings.ts ×2strings.ts ×1 · 1 introduced LOCstrings.ts ×1wordHelper.ts ×5 · 70 introduced LOCwordHelper.ts ×5strings.ts ×1 · 2 introduced LOCstrings.ts ×1strings.ts ×1 · 2 introduced LOCstrings.ts ×1strings.ts ×1 · 46 introduced LOCstrings.ts ×1strings.test|title=Strings trimWhitespace|occurrence=1 · 0 introduced LOCstrings.test|title=Strin…strings.ts ×101 · 542 introduced LOCstrings.ts ×101scrollable.ts ×32 · 205 introduced LOCscrollable.ts ×32cancellation.test|title=CancellationToken None|occurrence=1 · 0 introduced LOCcancellation.test|title=…cancellation.ts ×18 · 90 introduced LOCcancellation.ts ×18event.ts ×2 · 4 introduced LOCevent.ts ×2event.ts ×2 · 6 introduced LOCevent.ts ×2event.ts ×93 · 864 introduced LOCevent.ts ×93range.ts ×40 · 247 introduced LOCrange.ts ×40scanner.ts ×13 · 13 introduced LOCscanner.ts ×13scanner.ts ×3 · 3 introduced LOCscanner.ts ×3scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×36 · 181 introduced LOCscanner.ts ×36model.ts ×10 · 1559 introduced LOCmodel.ts ×10characterClassifier.ts ×1 · 2 introduced LOCcharacterClassifier.ts ×…characterClassifier.ts ×4 · 20 introduced LOCcharacterClassifier.ts ×…linkedList.ts ×1 · 2 introduced LOClinkedList.ts ×1linkedList.ts ×3 · 11 introduced LOClinkedList.ts ×3position.ts ×16 · 113 introduced LOCposition.ts ×16linkedList.ts ×1 · 4 introduced LOClinkedList.ts ×1characterClassifier.ts ×10 · 51 introduced LOCcharacterClassifier.ts ×…uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3nls.ts ×1 · 1 introduced LOCnls.ts ×1nls.ts ×3 · 9 introduced LOCnls.ts ×3nls.ts ×1 · 1 introduced LOCnls.ts ×1linkedList.ts ×13 · 44 introduced LOClinkedList.ts ×13nls.ts ×6 · 13 introduced LOCnls.ts ×6objects.ts ×13 · 65 introduced LOCobjects.ts ×13instantiation.ts ×5 · 111 introduced LOCinstantiation.ts ×5lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lazy.ts ×1 · 2 introduced LOClazy.ts ×1lazy.ts ×3 · 37 introduced LOClazy.ts ×3lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1uint.ts ×2 · 43 introduced LOCuint.ts ×2lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/cache.ts · 153 LOCcommon/cache.tssrc/vs/base/common/cancellation.ts · 206 LOCcommon/cancellation.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/event.ts · 1964 LOCcommon/event.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lazy.ts · 57 LOCcommon/lazy.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/linkedList.ts · 151 LOCcommon/linkedList.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/objects.ts · 286 LOCcommon/objects.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/scrollable.ts · 522 LOCcommon/scrollable.tssrc/vs/base/common/stopwatch.ts · 41 LOCcommon/stopwatch.tssrc/vs/base/common/strings.ts · 1413 LOCcommon/strings.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uint.ts · 59 LOCcommon/uint.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/editor/common/config/editorOptions.ts · 6891 LOCconfig/editorOptions.tssrc/vs/editor/common/config/editorZoom.ts · 34 LOCconfig/editorZoom.tssrc/vs/editor/common/config/fontInfo.ts · 244 LOCconfig/fontInfo.tssrc/vs/editor/common/core/characterClassifier.ts · 86 LOCcore/characterClassifier…src/vs/editor/common/core/misc/textModelDefaults.ts · 17 LOCmisc/textModelDefaults.t…src/vs/editor/common/core/position.ts · 184 LOCcore/position.tssrc/vs/editor/common/core/range.ts · 520 LOCcore/range.tssrc/vs/editor/common/core/wordHelper.ts · 175 LOCcore/wordHelper.tssrc/vs/editor/common/model.ts · 1622 LOCcommon/model.tssrc/vs/editor/common/modelLineProjectionData.ts · 346 LOCcommon/modelLineProjecti…src/vs/editor/common/textModelEvents.ts · 594 LOCcommon/textModelEvents.t…src/vs/editor/common/viewModel/monospaceLineBreaksComputer.ts · 555 LOCviewModel/monospaceLineB…src/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/platform/accessibility/common/accessibility.ts · 57 LOCcommon/accessibility.tssrc/vs/platform/contextkey/common/contextkey.ts · 2183 LOCcommon/contextkey.tssrc/vs/platform/contextkey/common/scanner.ts · 384 LOCcommon/scanner.tssrc/vs/platform/instantiation/common/instantiation.ts · 130 LOCcommon/instantiation.tscancellation.test|title=CancellationToken None|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/cancellation.test|title=CancellationToken None|occurrence=1cancellation.test|title=…charCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…strings.test|title=Strings isFullWidthCharacter|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/strings.test|title=Strings isFullWidthCharacter|occurrence=1strings.test|title=Strin…strings.test|title=Strings trimWhitespace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/strings.test|title=Strings trimWhitespace|occurrence=1strings.test|title=Strin…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer incremental 1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer MonospaceLineBreaksComputer incremental 1|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #110392: Occasional crash when resize with panel on the right|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #110392: Occasional crash when resize with panel on the right|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #152773: Word wrap algorithm behaves differently with bracket followed by comma|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #152773: Word wrap algorithm behaves differently with bracket followed by comma|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #33366: Word wrap algorithm behaves differently around punctuation|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #33366: Word wrap algorithm behaves differently around punctuation|occurrence=1monospaceLineBreaksCompu…monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #95686: CRITICAL: loop forever on the monospaceLineBreaksComputer|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewModel/monospaceLineBreaksComputer.test|title=Editor ViewModel - MonospaceLineBreaksComputer issue #95686: CRITICAL: loop forever on the monospaceLineBreaksComputer|occurrence=1monospaceLineBreaksCompu…Focused concept · monospaceLineBreaksComputer.ts ×15 · 206 introduced LOCmonospaceLineBreaksCompu…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 206 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/viewModel/monospaceLineBreaksComputer.ts 206 introduced LOC · 15 ranges

Open complete file

45 const isLineFeedWrappingEnabled = wrapOnEscapedLineFeeds && lineText.includes('"') && lineText.includes('\\n');
46 if (previousLineBreakData && !previousLineBreakData.injectionOptions && !injectedText && !isLineFeedWrappingEnabled) {
47 > result[i] = createLineBreaksFromPreviousLineBreaks(this.classifier, previousLineBreakData, lineText, tabSize, wrappingColumn, columnsForFullWidthChar, wrappingIndent, wordBreak); monospaceLineBreaksComputer.ts
48 } else {
49 result[i] = createLineBreaks(this.classifier, lineText, injectedText, tabSize, wrappingColumn, columnsForFullWidthChar, wrappingIndent, wordBreak, isLineFeedWrappingEnabled);
103 let arrPool2: number[] = [];
104
105 > function createLineBreaksFromPreviousLineBreaks(classifier: WrappingCharacterClassifier, previousBreakingData: ModelLineProjectionData, lineText: string, tabSize: number, firstLineBreakColumn: number, columnsForFullWidthChar: number, wrappingIndent: WrappingIndent, wordBreak: 'normal' | 'keepAll'): ModelLineProjectionData | null { monospaceLineBreaksComputer.ts
106 > if (firstLineBreakColumn === -1) {
107 return null;
108 }
110 > const len = lineText.length;
111 > if (len <= 1) {
112 return null;
113 }
115 > const isKeepAll = (wordBreak === 'keepAll');
116 >
117 > const prevBreakingOffsets = previousBreakingData.breakOffsets;
118 > const prevBreakingOffsetsVisibleColumn = previousBreakingData.breakOffsetsVisibleColumn;
119 >
120 > const wrappedTextIndentLength = computeWrappedTextIndentLength(lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent);
121 > const wrappedLineBreakColumn = firstLineBreakColumn - wrappedTextIndentLength;
122 >
123 > const breakingOffsets: number[] = arrPool1;
124 > const breakingOffsetsVisibleColumn: number[] = arrPool2;
125 > let breakingOffsetsCount = 0;
126 > let lastBreakingOffset = 0;
127 > let lastBreakingOffsetVisibleColumn = 0;
128 >
129 > let breakingColumn = firstLineBreakColumn;
130 > const prevLen = prevBreakingOffsets.length;
131 > let prevIndex = 0;
132 >
133 > if (prevIndex >= 0) {
134 > let bestDistance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex] - breakingColumn);
135 > while (prevIndex + 1 < prevLen) {
136 > const distance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex + 1] - breakingColumn);
137 > if (distance >= bestDistance) {
138 > break;
139 > }
140 > bestDistance = distance;
141 > prevIndex++;
142 > }
143 > }
144 >
145 > while (prevIndex < prevLen) {
146 > // Allow for prevIndex to be -1 (for the case where we hit a tab when walking backwards from the first break)
147 > let prevBreakOffset = prevIndex < 0 ? 0 : prevBreakingOffsets[prevIndex];
148 > let prevBreakOffsetVisibleColumn = prevIndex < 0 ? 0 : prevBreakingOffsetsVisibleColumn[prevIndex];
149 > if (lastBreakingOffset > prevBreakOffset) {
150 prevBreakOffset = lastBreakingOffset;
151 prevBreakOffsetVisibleColumn = lastBreakingOffsetVisibleColumn;
152 }
154 > let breakOffset = 0;
155 > let breakOffsetVisibleColumn = 0;
156 >
157 > let forcedBreakOffset = 0;
158 > let forcedBreakOffsetVisibleColumn = 0;
159 >
160 > // initially, we search as much as possible to the right (if it fits)
161 > if (prevBreakOffsetVisibleColumn <= breakingColumn) {
162 > let visibleColumn = prevBreakOffsetVisibleColumn;
163 > let prevCharCode = prevBreakOffset === 0 ? CharCode.Null : lineText.charCodeAt(prevBreakOffset - 1);
164 > let prevCharCodeClass = prevBreakOffset === 0 ? CharacterClass.NONE : classifier.get(prevCharCode);
165 > let entireLineFits = true;
166 > for (let i = prevBreakOffset; i < len; i++) {
167 > const charStartOffset = i;
168 > const charCode = lineText.charCodeAt(i);
169 > let charCodeClass: number;
170 > let charWidth: number;
171 >
172 > if (strings.isHighSurrogate(charCode)) {
173 // A surrogate pair must always be considered as a single unit, so it is never to be broken
174 i++;
175 charCodeClass = CharacterClass.NONE;
176 charWidth = 2;
178 > charCodeClass = classifier.get(charCode);
179 > charWidth = computeCharWidth(charCode, visibleColumn, tabSize, columnsForFullWidthChar);
180 > }
181 >
182 > if (charStartOffset > lastBreakingOffset && canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass, isKeepAll)) {
183 > breakOffset = charStartOffset;
184 > breakOffsetVisibleColumn = visibleColumn;
185 > }
186 >
187 > visibleColumn += charWidth;
188 >
189 > // check if adding character at `i` will go over the breaking column
190 > if (visibleColumn > breakingColumn) {
191 > // We need to break at least before character at `i`:
192 > if (charStartOffset > lastBreakingOffset) {
193 > forcedBreakOffset = charStartOffset;
194 > forcedBreakOffsetVisibleColumn = visibleColumn - charWidth;
195 > } else {
196 // we need to advance at least by one character
197 forcedBreakOffset = i + 1;
198 forcedBreakOffsetVisibleColumn = visibleColumn;
199 }
201 > if (visibleColumn - breakOffsetVisibleColumn > wrappedLineBreakColumn) {
202 > // Cannot break at `breakOffset` => reset it if it was set
203 > breakOffset = 0;
204 > }
205 >
206 > entireLineFits = false;
207 > break;
208 > }
209 >
210 > prevCharCode = charCode;
211 > prevCharCodeClass = charCodeClass;
212 > }
213 >
214 > if (entireLineFits) {
215 > // there is no more need to break => stop the outer loop!
216 > if (breakingOffsetsCount > 0) {
217 > // Add last segment, no need to assign to `lastBreakingOffset` and `lastBreakingOffsetVisibleColumn`
218 > breakingOffsets[breakingOffsetsCount] = prevBreakingOffsets[prevBreakingOffsets.length - 1];
219 > breakingOffsetsVisibleColumn[breakingOffsetsCount] = prevBreakingOffsetsVisibleColumn[prevBreakingOffsets.length - 1];
220 > breakingOffsetsCount++;
221 > }
222 > break;
223 > }
224 > }
225 >
226 > if (breakOffset === 0) {
227 > // must search left
228 > let visibleColumn = prevBreakOffsetVisibleColumn;
229 > let charCode = lineText.charCodeAt(prevBreakOffset);
230 > let charCodeClass = classifier.get(charCode);
231 > let hitATabCharacter = false;
232 > for (let i = prevBreakOffset - 1; i >= lastBreakingOffset; i--) {
233 > const charStartOffset = i + 1;
234 > const prevCharCode = lineText.charCodeAt(i);
235 >
236 > if (prevCharCode === CharCode.Tab) {
237 // cannot determine the width of a tab when going backwards, so we must go forwards
238 hitATabCharacter = true;
239 break;
240 }
242 > let prevCharCodeClass: number;
243 > let prevCharWidth: number;
244 >
245 > if (strings.isLowSurrogate(prevCharCode)) {
246 // A surrogate pair must always be considered as a single unit, so it is never to be broken
247 i--;
248 prevCharCodeClass = CharacterClass.NONE;
249 prevCharWidth = 2;
251 > prevCharCodeClass = classifier.get(prevCharCode);
252 > prevCharWidth = (strings.isFullWidthCharacter(prevCharCode) ? columnsForFullWidthChar : 1);
253 > }
254 >
255 > if (visibleColumn <= breakingColumn) {
256 > if (forcedBreakOffset === 0) {
257 > forcedBreakOffset = charStartOffset;
258 > forcedBreakOffsetVisibleColumn = visibleColumn;
259 > }
260 >
261 > if (visibleColumn <= breakingColumn - wrappedLineBreakColumn) {
262 // went too far!
263 break;
264 }
266 > if (canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass, isKeepAll)) {
267 > breakOffset = charStartOffset;
268 > breakOffsetVisibleColumn = visibleColumn;
269 > break;
270 > }
271 > }
272 >
273 > visibleColumn -= prevCharWidth;
274 > charCode = prevCharCode;
275 > charCodeClass = prevCharCodeClass;
276 > }
277 >
278 > if (breakOffset !== 0) {
279 > const remainingWidthOfNextLine = wrappedLineBreakColumn - (forcedBreakOffsetVisibleColumn - breakOffsetVisibleColumn);
280 > if (remainingWidthOfNextLine <= tabSize) {
281 > const charCodeAtForcedBreakOffset = lineText.charCodeAt(forcedBreakOffset);
282 > let charWidth: number;
283 > if (strings.isHighSurrogate(charCodeAtForcedBreakOffset)) {
284 // A surrogate pair must always be considered as a single unit, so it is never to be broken
285 charWidth = 2;
287 > charWidth = computeCharWidth(charCodeAtForcedBreakOffset, forcedBreakOffsetVisibleColumn, tabSize, columnsForFullWidthChar);
288 > }
289 > if (remainingWidthOfNextLine - charWidth < 0) {
290 // it is not worth it to break at breakOffset, it just introduces an extra needless line!
291 breakOffset = 0;
292 }
294 > }
295 >
296 > if (hitATabCharacter) {
297 // cannot determine the width of a tab when going backwards, so we must go forwards from the previous break
298 prevIndex--;
299 continue;
300 }
302 >
303 > if (breakOffset === 0) {
304 > // Could not find a good breaking point
305 > breakOffset = forcedBreakOffset;
306 > breakOffsetVisibleColumn = forcedBreakOffsetVisibleColumn;
307 > }
308 >
309 > if (breakOffset <= lastBreakingOffset) {
310 // Make sure that we are advancing (at least one character)
311 const charCode = lineText.charCodeAt(lastBreakingOffset);
319 }
320 }
322 > lastBreakingOffset = breakOffset;
323 > breakingOffsets[breakingOffsetsCount] = breakOffset;
324 > lastBreakingOffsetVisibleColumn = breakOffsetVisibleColumn;
325 > breakingOffsetsVisibleColumn[breakingOffsetsCount] = breakOffsetVisibleColumn;
326 > breakingOffsetsCount++;
327 > breakingColumn = breakOffsetVisibleColumn + wrappedLineBreakColumn;
328 >
329 > while (prevIndex < 0 || (prevIndex < prevLen && prevBreakingOffsetsVisibleColumn[prevIndex] < breakOffsetVisibleColumn)) {
330 > prevIndex++;
331 > }
332 >
333 > let bestDistance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex] - breakingColumn);
334 > while (prevIndex + 1 < prevLen) {
335 > const distance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex + 1] - breakingColumn);
336 > if (distance >= bestDistance) {
337 > break;
338 > }
339 > bestDistance = distance;
340 > prevIndex++;
341 > }
342 > }
343 >
344 > if (breakingOffsetsCount === 0) {
345 return null;
346 }
348 > // Doing here some object reuse which ends up helping a huge deal with GC pauses!
349 > breakingOffsets.length = breakingOffsetsCount;
350 > breakingOffsetsVisibleColumn.length = breakingOffsetsCount;
351 > arrPool1 = previousBreakingData.breakOffsets;
352 > arrPool2 = previousBreakingData.breakOffsetsVisibleColumn;
353 > previousBreakingData.breakOffsets = breakingOffsets;
354 > previousBreakingData.breakOffsetsVisibleColumn = breakingOffsetsVisibleColumn;
355 > previousBreakingData.wrappedTextIndentLength = wrappedTextIndentLength;
356 > return previousBreakingData;
357 > }
358
359 function createLineBreaks(classifier: WrappingCharacterClassifier, _lineText: string, injectedTexts: LineInjectedText[] | null, tabSize: number, firstLineBreakColumn: number, columnsForFullWidthChar: number, wrappingIndent: WrappingIndent, wordBreak: 'normal' | 'keepAll', wrapOnEscapedLineFeeds: boolean): ModelLineProjectionData | null {