Skip to content

Commit

Permalink
fix: trailing bracket in json with highlightMode enabled (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta authored Feb 1, 2021
1 parent ad4072d commit 4f34ef6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions __tests__/codeMirror.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ test('should work with modes', () => {
);
});

test('should keep trailing json bracket if highlightMode is enabled', () => {
expect(
shallow(
syntaxHighlighter('{ "a": 1 }', 'json', {
highlightMode: true,
})
).html()
).toBe(
'<div class="cm-s-neo CodeEditor"><div class="CodeMirror"><div class="cm-linerow "><span class="cm-lineNumber">1</span>{ <span class="cm-property">&quot;a&quot;</span>: <span class="cm-number">1</span> }</div></div></div>'
);
});

test('should have a dark theme', () => {
expect(shallow(syntaxHighlighter('{ "a": 1 }', 'json', { dark: true })).hasClass('cm-s-material-palenight')).toBe(
true
Expand Down
2 changes: 1 addition & 1 deletion src/codeMirror/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const StyledSyntaxHighlighter = ({ output, ranges }) => {

const enumerateMatches = (o, final) => {
// Case where a single line break
if (o.length === 1) {
if (o.length === 1 && lineBreakRegex.test(o)) {
incrementLine(true);
// Case with multiple consecutive line breaks
} else {
Expand Down

0 comments on commit 4f34ef6

Please sign in to comment.