diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-11-08 19:24:33 -0500 | 
|---|---|---|
| committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-11-08 19:24:33 -0500 | 
| commit | fa963722a79c26c1642bbf81a2e153bd0c1a3fe8 (patch) | |
| tree | e5ea8f9130f75c2a0f66acdff6949669a85ce4b5 /ext | |
| parent | b05960967098262c619e28be5238539c26b7b697 (diff) | |
Fix seekForward and seekBackward not handling length=0 case correctly
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/fg/js/source.js | 8 | 
1 files changed, 8 insertions, 0 deletions
| diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js index c3da9f46..5be521fa 100644 --- a/ext/fg/js/source.js +++ b/ext/fg/js/source.js @@ -108,6 +108,10 @@ class TextSourceRange {      static seekForward(node, offset, length) {          const state = {node, offset, remainder: length, content: ''}; +        if (length <= 0) { +            return state; +        } +          const TEXT_NODE = Node.TEXT_NODE;          const ELEMENT_NODE = Node.ELEMENT_NODE;          let resetOffset = false; @@ -166,6 +170,10 @@ class TextSourceRange {      static seekBackward(node, offset, length) {          const state = {node, offset, remainder: length, content: ''}; +        if (length <= 0) { +            return state; +        } +          const TEXT_NODE = Node.TEXT_NODE;          const ELEMENT_NODE = Node.ELEMENT_NODE;          let resetOffset = false; |