about summary refs log tree commit diff stats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-16 18:30:03 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-16 18:30:03 +0100
commita3b2d9189f3b25c7cf79985beac843cc46c37cfc (patch)
tree7b371adff64309f98edcf8115eba6461a9c3bce0 /src/utils
parent3f2bc1069142ae13f9991102a0c01cd1291b08e8 (diff)
downloadchawan-a3b2d9189f3b25c7cf79985beac843cc46c37cfc.tar.gz
strwidth & url fixes
* actually search Combining for isCombining
* fix searchInMap
* fix cmpRange of url
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/map.nim6
-rw-r--r--src/utils/strwidth.nim2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/utils/map.nim b/src/utils/map.nim
index 2a3515a1..620dec58 100644
--- a/src/utils/map.nim
+++ b/src/utils/map.nim
@@ -11,10 +11,10 @@ func isInMap*[U, T](a: openArray[(U, T)], u: U): bool =
 
 func isInRange*[U](a: openArray[(U, U)], u: U): bool =
   let res = binarySearch(a, u, proc(x: (U, U), y: U): int =
-    if x[0] < y:
-      -1
-    elif x[1] > y:
+    if x[0] > y:
       1
+    elif x[1] < y:
+      -1
     else:
       0
   )
diff --git a/src/utils/strwidth.nim b/src/utils/strwidth.nim
index bcf9d034..a27cb8b1 100644
--- a/src/utils/strwidth.nim
+++ b/src/utils/strwidth.nim
@@ -98,7 +98,7 @@ func isDoubleWidthAmbiguousHigh(r: Rune): bool =
   return r.isDoubleWidthHigh()
 
 func isCombining(r: Rune): bool =
-  return DoubleWidthAmbiguousRanges.isInRange(uint32(r))
+  return Combining.isInRange(uint32(r))
 
 # Lookup tables for characters on the BMP. This "only" takes up 8k of space
 # per table, as opposed to the 135k that storing all characters would require.