aboutsummaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-08 19:24:33 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-08 19:24:33 -0500
commitfa963722a79c26c1642bbf81a2e153bd0c1a3fe8 (patch)
treee5ea8f9130f75c2a0f66acdff6949669a85ce4b5 /ext/fg
parentb05960967098262c619e28be5238539c26b7b697 (diff)
Fix seekForward and seekBackward not handling length=0 case correctly
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/source.js8
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;