@@ -126,9 +126,9 @@ class MarkdownTocTools {
126126 let tocRange = this . getTocRange ( ) ;
127127 this . updateOptions ( tocRange ) ;
128128 let headerList = this . getHeaderList ( ) ;
129-
129+
130130 window . activeTextEditor . edit ( function ( editBuilder ) {
131- headerList . forEach ( element => {
131+ headerList . forEach ( element => {
132132 let newHeader = element . header + " " + element . orderedList + " " + element . baseTitle
133133 editBuilder . replace ( element . range , newHeader ) ;
134134 } ) ;
@@ -203,7 +203,7 @@ class MarkdownTocTools {
203203 let optionsText = window . activeTextEditor . document . lineAt ( tocRange . start . line ) . text ;
204204 let options = optionsText . match ( REGEXP_TOC_CONFIG ) ;
205205 if ( options == null ) return ;
206-
206+
207207 options . forEach ( element => {
208208 let pair = REGEXP_TOC_CONFIG_ITEM . exec ( element )
209209 let key = pair [ 1 ] . toLocaleLowerCase ( ) ;
@@ -265,9 +265,14 @@ class MarkdownTocTools {
265265
266266 private createToc ( editBuilder : TextEditorEdit , headerList : any [ ] , insertPosition : Position ) {
267267 let lineEnding = < string > workspace . getConfiguration ( "files" ) . get ( "eol" ) ;
268+ console . log ( 'lineEnding' , lineEnding ) ;
269+ if ( lineEnding === "auto" ) {
270+ lineEnding = "\n" ;
271+ }
272+
268273 let tabSize = < number > workspace . getConfiguration ( "[markdown]" ) [ "editor.tabSize" ] ;
269274 let insertSpaces = < boolean > workspace . getConfiguration ( "[markdown]" ) [ "editor.insertSpaces" ] ;
270-
275+
271276 if ( tabSize === undefined || tabSize === null ) {
272277 tabSize = < number > workspace . getConfiguration ( "editor" ) . get ( "tabSize" ) ;
273278 }
@@ -278,7 +283,7 @@ class MarkdownTocTools {
278283 let tab = '\t' ;
279284 if ( insertSpaces && tabSize > 0 ) {
280285 tab = " " . repeat ( tabSize ) ;
281- }
286+ }
282287
283288 let optionsText = [ ] ;
284289 optionsText . push ( '<!-- TOC ' ) ;
@@ -302,7 +307,7 @@ class MarkdownTocTools {
302307 minDepth = Math . min ( element . depth , minDepth ) ;
303308 } ) ;
304309 let startDepth = Math . max ( minDepth , this . options . DEPTH_FROM ) ;
305-
310+
306311 headerList . forEach ( element => {
307312 if ( element . depth <= this . options . DEPTH_TO ) {
308313 let length = element . depth - startDepth ;
@@ -312,7 +317,7 @@ class MarkdownTocTools {
312317 waitResetList [ index ] = false ;
313318 }
314319 }
315-
320+
316321 let row = [
317322 tab . repeat ( length ) ,
318323 this . options . ORDERED_LIST ? ( ++ indicesOfDepth [ length ] + '. ' ) : '- ' ,
@@ -376,7 +381,7 @@ class MarkdownTocTools {
376381 } else {
377382 hashMap [ title ] += 1 ;
378383 }
379-
384+
380385 let hash = this . getHash ( title , this . options . ANCHOR_MODE , hashMap [ title ] ) ;
381386 headerList . push ( {
382387 line : index ,
0 commit comments