Return cursor position for query object (fixes #228)

Change-Id: I8a7e872dfcce38d2f525d07c1bb3fc84f25250c3
diff --git a/dev/js/src/hint/input.js b/dev/js/src/hint/input.js
index cabaa84..520b9e4 100644
--- a/dev/js/src/hint/input.js
+++ b/dev/js/src/hint/input.js
@@ -40,6 +40,16 @@
       window.addEventListener('resize', re);
       this._el.addEventListener('onfocus', re);
       this.reposition();
+
+      // Prevent multiselections
+      this._el.addEventListener("select", () => {
+        const start = this._el.selectionStart;
+        const end = this._el.selectionEnd;
+        if (start !== null && end !== null && start !== end) {
+          this._el.setSelectionRange(start, end);
+        }
+      });
+
       return this;
     },
 
@@ -198,6 +208,13 @@
         value.substring(0, start),
         value.substring(start, value.length)
       );
+    },
+
+    /**
+     * Return the cursor character offsets
+     */
+    selectionRange : function () {
+      return [this._el.selectionStart, this._el.selectionEnd];
     }
   }
 });