Skip to content

Commit

Permalink
Extract preventOverlap/0 in cleditHighlighter
Browse files Browse the repository at this point in the history
Replaces comments, follows example of `highlight/1` in same file
  • Loading branch information
yakryder committed Oct 9, 2019
1 parent 2fdbb67 commit 79c244a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/services/editor/cledit/cleditHighlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ function Highlighter(editor) {
return false;
});

if (leftIndex - rightIndex > sectionList.length) {
// Prevent overlap
rightIndex = leftIndex - sectionList.length;
}
const preventOverlap = () => {
if (leftIndex - rightIndex > sectionList.length) {
rightIndex = leftIndex - sectionList.length;
}
return rightIndex;
};

rightIndex = preventOverlap();

const leftSections = sectionList.slice(0, leftIndex);
modifiedSections = newSectionList.slice(leftIndex, newSectionList.length + rightIndex);
Expand Down

0 comments on commit 79c244a

Please sign in to comment.