55'use strict' ;
66
77import { ViewLineToken } from 'vs/editor/common/core/viewLineToken' ;
8+ import { CharCode } from 'vs/base/common/charCode' ;
89
910export class RenderLineInput {
1011 _renderLineInputBrand : void ;
@@ -49,16 +50,6 @@ export class RenderLineOutput {
4950 }
5051}
5152
52- const _space = ' ' . charCodeAt ( 0 ) ;
53- const _tab = '\t' . charCodeAt ( 0 ) ;
54- const _lowerThan = '<' . charCodeAt ( 0 ) ;
55- const _greaterThan = '>' . charCodeAt ( 0 ) ;
56- const _ampersand = '&' . charCodeAt ( 0 ) ;
57- const _carriageReturn = '\r' . charCodeAt ( 0 ) ;
58- const _controlCharacterSequenceConversionStart = 9216 ;
59- const _lineSeparator = '\u2028' . charCodeAt ( 0 ) ; //http://www.fileformat.info/info/unicode/char/2028/index.htm
60- const _bom = 65279 ;
61-
6253export function renderLine ( input :RenderLineInput ) : RenderLineOutput {
6354 const lineText = input . lineContent ;
6455 const lineTextLength = lineText . length ;
@@ -92,6 +83,8 @@ function isWhitespace(type:string): boolean {
9283function isControlCharacter ( characterCode : number ) : boolean {
9384 return characterCode < 32 ;
9485}
86+
87+ const _controlCharacterSequenceConversionStart = 9216 ;
9588function controlCharacterToPrintable ( characterCode : number ) : string {
9689 return String . fromCharCode ( _controlCharacterSequenceConversionStart + characterCode ) ;
9790}
@@ -128,7 +121,7 @@ function renderLineActual(lineText: string, lineTextLength: number, tabSize: num
128121 charOffsetInPartArr [ charIndex ] = charOffsetInPart ;
129122 let charCode = lineText . charCodeAt ( charIndex ) ;
130123
131- if ( charCode === _tab ) {
124+ if ( charCode === CharCode . Tab ) {
132125 let insertSpacesCount = tabSize - ( charIndex + tabsCharDelta ) % tabSize ;
133126 tabsCharDelta += insertSpacesCount - 1 ;
134127 charOffsetInPart += insertSpacesCount - 1 ;
@@ -143,7 +136,7 @@ function renderLineActual(lineText: string, lineTextLength: number, tabSize: num
143136 insertSpacesCount -- ;
144137 }
145138 } else {
146- // must be _space
139+ // must be CharCode.Space
147140 partContent += '·' ;
148141 partContentCnt ++ ;
149142 }
@@ -175,7 +168,7 @@ function renderLineActual(lineText: string, lineTextLength: number, tabSize: num
175168 let charCode = lineText . charCodeAt ( charIndex ) ;
176169
177170 switch ( charCode ) {
178- case _tab :
171+ case CharCode . Tab :
179172 let insertSpacesCount = tabSize - ( charIndex + tabsCharDelta ) % tabSize ;
180173 tabsCharDelta += insertSpacesCount - 1 ;
181174 charOffsetInPart += insertSpacesCount - 1 ;
@@ -185,32 +178,32 @@ function renderLineActual(lineText: string, lineTextLength: number, tabSize: num
185178 }
186179 break ;
187180
188- case _space :
181+ case CharCode . Space :
189182 out += ' ' ;
190183 break ;
191184
192- case _lowerThan :
185+ case CharCode . LessThan :
193186 out += '<' ;
194187 break ;
195188
196- case _greaterThan :
189+ case CharCode . GreaterThan :
197190 out += '>' ;
198191 break ;
199192
200- case _ampersand :
193+ case CharCode . Ampersand :
201194 out += '&' ;
202195 break ;
203196
204- case 0 :
197+ case CharCode . Null :
205198 out += '�' ;
206199 break ;
207200
208- case _bom :
209- case _lineSeparator :
201+ case CharCode . UTF8_BOM :
202+ case CharCode . LINE_SEPARATOR_2028 :
210203 out += '\ufffd' ;
211204 break ;
212205
213- case _carriageReturn :
206+ case CharCode . CarriageReturn :
214207 // zero width space, because carriage return would introduce a line break
215208 out += '​' ;
216209 break ;
0 commit comments