Skip to content

Commit

Permalink
fixed some scrollFollow code
Browse files Browse the repository at this point in the history
  • Loading branch information
shiren authored and seonim-ryu committed Jan 2, 2020
1 parent f6c1a2c commit 8351c73
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/core/src/js/extensions/scrollFollow.sectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

'use strict';

var setextHeaderRx = /^ *(?:\={1,}|-{1,})\s*$/;
var FIND_SETEXT_HEADER_RX = /^ *(?:\={1,}|-{1,})\s*$/,
FIND_SPACE = /\s/g;

/*
* SectionManager
Expand Down Expand Up @@ -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;
}

Expand Down
35 changes: 35 additions & 0 deletions apps/core/test/extensions/scrollFollow.sectionManager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 8351c73

Please sign in to comment.