Skip to content

Commit

Permalink
fix: wrong scroll sync preview position (close #263) (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyuwoo-choi committed Jul 17, 2018
1 parent f783d92 commit 093c398
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/js/extensions/scrollSync/sectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ class SectionManager {
*/
_isSeTextHeader(lineString, nextLineString) {
return lineString.replace(FIND_SPACE, '') !== ''
&& nextLineString
&& FIND_SETEXT_HEADER_RX.test(nextLineString);
&& !this._isQuote(lineString)
&& nextLineString
&& FIND_SETEXT_HEADER_RX.test(nextLineString);
}

_isImage(lineString) {
Expand Down
15 changes: 15 additions & 0 deletions test/unit/extensions/scrollSync/sectionManager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,21 @@ describe('sectionManager', () => {
expect(sectionManager.sectionByLine(99999)).toBe(sectionList[2]);
});

it('should not create a section for setext heading with quote', () => {
ned.setValue([
'text',
'> quote',
'---'
].join('\n'));

sectionManager.makeSectionList();
const sectionList = sectionManager.getSectionList();

expect(sectionManager.sectionByLine(0)).toBe(sectionList[0]);
expect(sectionManager.sectionByLine(1)).toBe(sectionList[0]);
expect(sectionManager.sectionByLine(99999)).toBe(sectionList[0]);
});

it('create new section of image where at root level', () => {
ned.setValue([
'paragraph',
Expand Down

0 comments on commit 093c398

Please sign in to comment.