@@ -7,7 +7,7 @@ import { CharCode } from 'vs/base/common/charCode';
77import * as strings from 'vs/base/common/strings' ;
88import { WrappingIndent , IComputedEditorOptions , EditorOption } from 'vs/editor/common/config/editorOptions' ;
99import { CharacterClassifier } from 'vs/editor/common/core/characterClassifier' ;
10- import { ILineMapperFactory , LineBreakingData , ILineMappingComputer } from 'vs/editor/common/viewModel/splitLinesCollection' ;
10+ import { ILineBreaksComputerFactory , LineBreakData , ILineBreaksComputer } from 'vs/editor/common/viewModel/splitLinesCollection' ;
1111
1212const enum CharacterClass {
1313 NONE = 0 ,
@@ -51,10 +51,10 @@ class WrappingCharacterClassifier extends CharacterClassifier<CharacterClass> {
5151 }
5252}
5353
54- export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactory {
54+ export class MonospaceLineBreaksComputerFactory implements ILineBreaksComputerFactory {
5555
56- public static create ( options : IComputedEditorOptions ) : CharacterHardWrappingLineMapperFactory {
57- return new CharacterHardWrappingLineMapperFactory (
56+ public static create ( options : IComputedEditorOptions ) : MonospaceLineBreaksComputerFactory {
57+ return new MonospaceLineBreaksComputerFactory (
5858 options . get ( EditorOption . wordWrapBreakBeforeCharacters ) ,
5959 options . get ( EditorOption . wordWrapBreakAfterCharacters )
6060 ) ;
@@ -66,26 +66,26 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
6666 this . classifier = new WrappingCharacterClassifier ( breakBeforeChars , breakAfterChars ) ;
6767 }
6868
69- public createLineMappingComputer ( tabSize : number , wrappingColumn : number , columnsForFullWidthChar : number , wrappingIndent : WrappingIndent ) : ILineMappingComputer {
69+ public createLineBreaksComputer ( tabSize : number , wrappingColumn : number , columnsForFullWidthChar : number , wrappingIndent : WrappingIndent ) : ILineBreaksComputer {
7070 tabSize = tabSize | 0 ; //@perf
7171 wrappingColumn = + wrappingColumn ; //@perf
7272 columnsForFullWidthChar = + columnsForFullWidthChar ; //@perf
7373
7474 let requests : string [ ] = [ ] ;
75- let previousBreakingData : ( LineBreakingData | null ) [ ] = [ ] ;
75+ let previousBreakingData : ( LineBreakData | null ) [ ] = [ ] ;
7676 return {
77- addRequest : ( lineText : string , previousLineBreakingData : LineBreakingData | null ) => {
77+ addRequest : ( lineText : string , previousLineBreakData : LineBreakData | null ) => {
7878 requests . push ( lineText ) ;
79- previousBreakingData . push ( previousLineBreakingData ) ;
79+ previousBreakingData . push ( previousLineBreakData ) ;
8080 } ,
8181 finalize : ( ) => {
82- let result : ( LineBreakingData | null ) [ ] = [ ] ;
82+ let result : ( LineBreakData | null ) [ ] = [ ] ;
8383 for ( let i = 0 , len = requests . length ; i < len ; i ++ ) {
84- const previousLineBreakingData = previousBreakingData [ i ] ;
85- if ( previousLineBreakingData ) {
86- result [ i ] = createLineMappingFromPreviousLineMapping ( this . classifier , previousLineBreakingData , requests [ i ] , tabSize , wrappingColumn , columnsForFullWidthChar , wrappingIndent ) ;
84+ const previousLineBreakData = previousBreakingData [ i ] ;
85+ if ( previousLineBreakData ) {
86+ result [ i ] = createLineBreaksFromPreviousLineBreaks ( this . classifier , previousLineBreakData , requests [ i ] , tabSize , wrappingColumn , columnsForFullWidthChar , wrappingIndent ) ;
8787 } else {
88- result [ i ] = createLineMapping ( this . classifier , requests [ i ] , tabSize , wrappingColumn , columnsForFullWidthChar , wrappingIndent ) ;
88+ result [ i ] = createLineBreaks ( this . classifier , requests [ i ] , tabSize , wrappingColumn , columnsForFullWidthChar , wrappingIndent ) ;
8989 }
9090 }
9191 return result ;
@@ -96,8 +96,8 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
9696
9797let arrPool1 : number [ ] = [ ] ;
9898let arrPool2 : number [ ] = [ ] ;
99- function createLineMappingFromPreviousLineMapping ( classifier : WrappingCharacterClassifier , previousBreakingData : LineBreakingData , lineText : string , tabSize : number , firstLineBreakingColumn : number , columnsForFullWidthChar : number , hardWrappingIndent : WrappingIndent ) : LineBreakingData | null {
100- if ( firstLineBreakingColumn === - 1 ) {
99+ function createLineBreaksFromPreviousLineBreaks ( classifier : WrappingCharacterClassifier , previousBreakingData : LineBreakData , lineText : string , tabSize : number , firstLineBreakColumn : number , columnsForFullWidthChar : number , wrappingIndent : WrappingIndent ) : LineBreakData | null {
100+ if ( firstLineBreakColumn === - 1 ) {
101101 return null ;
102102 }
103103
@@ -107,16 +107,16 @@ function createLineMappingFromPreviousLineMapping(classifier: WrappingCharacterC
107107 }
108108
109109 const prevBreakingOffsets = previousBreakingData . breakOffsets ;
110- const prevBreakingOffsetsVisibleColumn = previousBreakingData . breakingOffsetsVisibleColumn ;
110+ const prevBreakingOffsetsVisibleColumn = previousBreakingData . breakOffsetsVisibleColumn ;
111111
112- const wrappedTextIndentLength = computeWrappedTextIndentLength ( lineText , tabSize , firstLineBreakingColumn , columnsForFullWidthChar , hardWrappingIndent ) ;
113- const wrappedLineBreakingColumn = firstLineBreakingColumn - wrappedTextIndentLength ;
112+ const wrappedTextIndentLength = computeWrappedTextIndentLength ( lineText , tabSize , firstLineBreakColumn , columnsForFullWidthChar , wrappingIndent ) ;
113+ const wrappedLineBreakColumn = firstLineBreakColumn - wrappedTextIndentLength ;
114114
115115 let breakingOffsets : number [ ] = arrPool1 ;
116116 let breakingOffsetsVisibleColumn : number [ ] = arrPool2 ;
117117 let breakingOffsetsCount : number = 0 ;
118118
119- let breakingColumn = firstLineBreakingColumn ;
119+ let breakingColumn = firstLineBreakColumn ;
120120 const prevLen = prevBreakingOffsets . length ;
121121 let prevIndex = 0 ;
122122
@@ -178,7 +178,7 @@ function createLineMappingFromPreviousLineMapping(classifier: WrappingCharacterC
178178 forcedBreakOffset = charStartOffset ;
179179 forcedBreakOffsetVisibleColumn = visibleColumn - charWidth ;
180180
181- if ( visibleColumn - breakOffsetVisibleColumn > wrappedLineBreakingColumn ) {
181+ if ( visibleColumn - breakOffsetVisibleColumn > wrappedLineBreakColumn ) {
182182 // Cannot break at `breakOffset` => reset it if it was set
183183 breakOffset = 0 ;
184184 }
@@ -238,7 +238,7 @@ function createLineMappingFromPreviousLineMapping(classifier: WrappingCharacterC
238238 forcedBreakOffsetVisibleColumn = visibleColumn ;
239239 }
240240
241- if ( visibleColumn <= breakingColumn - wrappedLineBreakingColumn ) {
241+ if ( visibleColumn <= breakingColumn - wrappedLineBreakColumn ) {
242242 // went too far!
243243 break ;
244244 }
@@ -256,7 +256,7 @@ function createLineMappingFromPreviousLineMapping(classifier: WrappingCharacterC
256256 }
257257
258258 if ( breakOffset !== 0 ) {
259- const remainingWidthOfNextLine = wrappedLineBreakingColumn - ( forcedBreakOffsetVisibleColumn - breakOffsetVisibleColumn ) ;
259+ const remainingWidthOfNextLine = wrappedLineBreakColumn - ( forcedBreakOffsetVisibleColumn - breakOffsetVisibleColumn ) ;
260260 if ( remainingWidthOfNextLine <= tabSize ) {
261261 const charCodeAtForcedBreakOffset = lineText . charCodeAt ( forcedBreakOffset ) ;
262262 let charWidth : number ;
@@ -289,7 +289,7 @@ function createLineMappingFromPreviousLineMapping(classifier: WrappingCharacterC
289289 breakingOffsets [ breakingOffsetsCount ] = breakOffset ;
290290 breakingOffsetsVisibleColumn [ breakingOffsetsCount ] = breakOffsetVisibleColumn ;
291291 breakingOffsetsCount ++ ;
292- breakingColumn = breakOffsetVisibleColumn + wrappedLineBreakingColumn ;
292+ breakingColumn = breakOffsetVisibleColumn + wrappedLineBreakColumn ;
293293
294294 while ( prevIndex < 0 || ( prevIndex < prevLen && prevBreakingOffsetsVisibleColumn [ prevIndex ] < breakOffsetVisibleColumn ) ) {
295295 prevIndex ++ ;
@@ -314,15 +314,15 @@ function createLineMappingFromPreviousLineMapping(classifier: WrappingCharacterC
314314 breakingOffsets . length = breakingOffsetsCount ;
315315 breakingOffsetsVisibleColumn . length = breakingOffsetsCount ;
316316 arrPool1 = previousBreakingData . breakOffsets ;
317- arrPool2 = previousBreakingData . breakingOffsetsVisibleColumn ;
317+ arrPool2 = previousBreakingData . breakOffsetsVisibleColumn ;
318318 previousBreakingData . breakOffsets = breakingOffsets ;
319- previousBreakingData . breakingOffsetsVisibleColumn = breakingOffsetsVisibleColumn ;
319+ previousBreakingData . breakOffsetsVisibleColumn = breakingOffsetsVisibleColumn ;
320320 previousBreakingData . wrappedTextIndentLength = wrappedTextIndentLength ;
321321 return previousBreakingData ;
322322}
323323
324- function createLineMapping ( classifier : WrappingCharacterClassifier , lineText : string , tabSize : number , firstLineBreakingColumn : number , columnsForFullWidthChar : number , hardWrappingIndent : WrappingIndent ) : LineBreakingData | null {
325- if ( firstLineBreakingColumn === - 1 ) {
324+ function createLineBreaks ( classifier : WrappingCharacterClassifier , lineText : string , tabSize : number , firstLineBreakColumn : number , columnsForFullWidthChar : number , wrappingIndent : WrappingIndent ) : LineBreakData | null {
325+ if ( firstLineBreakColumn === - 1 ) {
326326 return null ;
327327 }
328328
@@ -331,16 +331,16 @@ function createLineMapping(classifier: WrappingCharacterClassifier, lineText: st
331331 return null ;
332332 }
333333
334- const wrappedTextIndentLength = computeWrappedTextIndentLength ( lineText , tabSize , firstLineBreakingColumn , columnsForFullWidthChar , hardWrappingIndent ) ;
335- const wrappedLineBreakingColumn = firstLineBreakingColumn - wrappedTextIndentLength ;
334+ const wrappedTextIndentLength = computeWrappedTextIndentLength ( lineText , tabSize , firstLineBreakColumn , columnsForFullWidthChar , wrappingIndent ) ;
335+ const wrappedLineBreakColumn = firstLineBreakColumn - wrappedTextIndentLength ;
336336
337337 let breakingOffsets : number [ ] = [ ] ;
338338 let breakingOffsetsVisibleColumn : number [ ] = [ ] ;
339339 let breakingOffsetsCount : number = 0 ;
340340 let breakOffset = 0 ;
341341 let breakOffsetVisibleColumn = 0 ;
342342
343- let breakingColumn = firstLineBreakingColumn ;
343+ let breakingColumn = firstLineBreakColumn ;
344344 let prevCharCode = lineText . charCodeAt ( 0 ) ;
345345 let prevCharCodeClass = classifier . get ( prevCharCode ) ;
346346 let visibleColumn = computeCharWidth ( prevCharCode , 0 , tabSize , columnsForFullWidthChar ) ;
@@ -381,7 +381,7 @@ function createLineMapping(classifier: WrappingCharacterClassifier, lineText: st
381381 if ( visibleColumn > breakingColumn ) {
382382 // We need to break at least before character at `i`:
383383
384- if ( breakOffset === 0 || visibleColumn - breakOffsetVisibleColumn > wrappedLineBreakingColumn ) {
384+ if ( breakOffset === 0 || visibleColumn - breakOffsetVisibleColumn > wrappedLineBreakColumn ) {
385385 // Cannot break at `breakOffset`, must break at `i`
386386 breakOffset = charStartOffset ;
387387 breakOffsetVisibleColumn = visibleColumn - charWidth ;
@@ -390,7 +390,7 @@ function createLineMapping(classifier: WrappingCharacterClassifier, lineText: st
390390 breakingOffsets [ breakingOffsetsCount ] = breakOffset ;
391391 breakingOffsetsVisibleColumn [ breakingOffsetsCount ] = breakOffsetVisibleColumn ;
392392 breakingOffsetsCount ++ ;
393- breakingColumn = breakOffsetVisibleColumn + wrappedLineBreakingColumn ;
393+ breakingColumn = breakOffsetVisibleColumn + wrappedLineBreakColumn ;
394394 breakOffset = 0 ;
395395 }
396396
@@ -406,7 +406,7 @@ function createLineMapping(classifier: WrappingCharacterClassifier, lineText: st
406406 breakingOffsets [ breakingOffsetsCount ] = len ;
407407 breakingOffsetsVisibleColumn [ breakingOffsetsCount ] = visibleColumn ;
408408
409- return new LineBreakingData ( breakingOffsets , breakingOffsetsVisibleColumn , wrappedTextIndentLength ) ;
409+ return new LineBreakData ( breakingOffsets , breakingOffsetsVisibleColumn , wrappedTextIndentLength ) ;
410410}
411411
412412function computeCharWidth ( charCode : number , visibleColumn : number , tabSize : number , columnsForFullWidthChar : number ) : number {
@@ -436,9 +436,9 @@ function canBreak(prevCharCodeClass: CharacterClass, charCodeClass: CharacterCla
436436 ) ;
437437}
438438
439- function computeWrappedTextIndentLength ( lineText : string , tabSize : number , firstLineBreakingColumn : number , columnsForFullWidthChar : number , hardWrappingIndent : WrappingIndent ) : number {
439+ function computeWrappedTextIndentLength ( lineText : string , tabSize : number , firstLineBreakColumn : number , columnsForFullWidthChar : number , wrappingIndent : WrappingIndent ) : number {
440440 let wrappedTextIndentLength = 0 ;
441- if ( hardWrappingIndent !== WrappingIndent . None ) {
441+ if ( wrappingIndent !== WrappingIndent . None ) {
442442 const firstNonWhitespaceIndex = strings . firstNonWhitespaceIndex ( lineText ) ;
443443 if ( firstNonWhitespaceIndex !== - 1 ) {
444444 // Track existing indent
@@ -449,14 +449,14 @@ function computeWrappedTextIndentLength(lineText: string, tabSize: number, first
449449 }
450450
451451 // Increase indent of continuation lines, if desired
452- const numberOfAdditionalTabs = ( hardWrappingIndent === WrappingIndent . DeepIndent ? 2 : hardWrappingIndent === WrappingIndent . Indent ? 1 : 0 ) ;
452+ const numberOfAdditionalTabs = ( wrappingIndent === WrappingIndent . DeepIndent ? 2 : wrappingIndent === WrappingIndent . Indent ? 1 : 0 ) ;
453453 for ( let i = 0 ; i < numberOfAdditionalTabs ; i ++ ) {
454454 const charWidth = tabCharacterWidth ( wrappedTextIndentLength , tabSize ) ;
455455 wrappedTextIndentLength += charWidth ;
456456 }
457457
458458 // Force sticking to beginning of line if no character would fit except for the indentation
459- if ( wrappedTextIndentLength + columnsForFullWidthChar > firstLineBreakingColumn ) {
459+ if ( wrappedTextIndentLength + columnsForFullWidthChar > firstLineBreakColumn ) {
460460 wrappedTextIndentLength = 0 ;
461461 }
462462 }
0 commit comments