diff --git a/apps/core/src/js/extensions/scrollFollow.sectionManager.js b/apps/core/src/js/extensions/scrollFollow.sectionManager.js index 75424d8cdc..0dc5184602 100644 --- a/apps/core/src/js/extensions/scrollFollow.sectionManager.js +++ b/apps/core/src/js/extensions/scrollFollow.sectionManager.js @@ -5,7 +5,8 @@ 'use strict'; -var setextHeaderRx = /^ *(?:\={1,}|-{1,})\s*$/; +var FIND_SETEXT_HEADER_RX = /^ *(?:\={1,}|-{1,})\s*$/, + FIND_SPACE = /\s/g; /* * SectionManager @@ -104,7 +105,10 @@ SectionManager.prototype._eachLineState = function(iteratee) { ) { isSection = true; //setext header - } else if (this.cm.getLine(i+1) && this.cm.getLine(i+1).match(setextHeaderRx)) { + } else if (this.cm.getLine(i).replace(FIND_SPACE, '') !== '' + && this.cm.getLine(i+1) + && this.cm.getLine(i+1).match(FIND_SETEXT_HEADER_RX) + ) { isSection = true; } diff --git a/apps/core/test/extensions/scrollFollow.sectionManager.spec.js b/apps/core/test/extensions/scrollFollow.sectionManager.spec.js index 559ff057b4..3f537b3e48 100644 --- a/apps/core/test/extensions/scrollFollow.sectionManager.spec.js +++ b/apps/core/test/extensions/scrollFollow.sectionManager.spec.js @@ -161,6 +161,41 @@ describe('scrollFollow.sectionManager', function() { expect(sectionManager.getSectionList().length).toEqual(3); }); + it('dont make section with line', function() { + ned.setValue([ + 'paragraph', + 'header1', + '=======', + 'paragraph', + ' ', + '------', + 'paragraph' + ].join('\n')); + + + sectionManager.makeSectionList(); + + expect(sectionManager.getSectionList().length).toEqual(2); + }); + + xit('dont make section with line #2', function() { + ned.setValue([ + 'paragraph', + 'header1', + '=======', + '``` javascript', + 'var mm = 1;', + '```', + '------', + 'paragraph' + ].join('\n')); + + + sectionManager.makeSectionList(); + + expect(sectionManager.getSectionList().length).toEqual(2); + }); + it('section list have line info', function() { var sectionList;