diff --git a/addon/search/searchcursor.js b/addon/search/searchcursor.js
index 5feedd2677deefde08cf26dd50bb0c6782b1c997..24d885e7b031d55896cac292188286f26cead168 100644
--- a/addon/search/searchcursor.js
+++ b/addon/search/searchcursor.js
@@ -128,11 +128,13 @@
   // (compensating for codepoints increasing in number during folding)
   function adjustPos(orig, folded, pos, foldFunc) {
     if (orig.length == folded.length) return pos
-    for (var pos1 = Math.min(pos, orig.length);;) {
-      var len1 = foldFunc(orig.slice(0, pos1)).length
-      if (len1 < pos) ++pos1
-      else if (len1 > pos) --pos1
-      else return pos1
+    for (var min = 0, max = pos + Math.max(0, orig.length - folded.length);;) {
+      if (min == max) return min
+      let mid = (min + max) >> 1
+      var len = foldFunc(orig.slice(0, mid)).length
+      if (len == pos) return mid
+      else if (len > pos) max = mid - 1
+      else min = mid + 1
     }
   }
 
diff --git a/test/search_test.js b/test/search_test.js
index 7a6a6604614c96b33faeaf5de870bee85d432ad8..99c8b7e7a88f45fa4f4df695a422a30cf83db466 100644
--- a/test/search_test.js
+++ b/test/search_test.js
@@ -74,4 +74,10 @@
     run(doc, "</b>", true, 0, 8, 0, 12, 1, 8, 1, 12);
     run(doc, "Ä°Ä°", true, 0, 3, 0, 5, 0, 6, 0, 8);
   });
+
+  test("normalize", function() {
+    var doc = new CodeMirror.Doc("yılbaşı\n수 있을까")
+    run(doc, "s", false, 0, 5, 0, 6)
+    run(doc, "이", false, 1, 2, 1, 3)
+  })
 })();