I'm duplicating the bounds check when drawing cursor and search highlight because they're separate concerns and require subtly different logic.
HALQLPZNGJTWL3XZVV2YLCUHMK33PNMWXMADBHIKEOSLI3PQMULQC
ZPQI5UL3V6QIZXWGXO2DZOCCTLIUOQSRP3LIQKEARIQQSNA6RO6AC
PHWEOV6NI6C4JEUJIHNC7OIUNEXCBJ3FODJUL6UUBI53GGMS3GTAC
I64IPGJXWRTGHHVAYJUBUIWFR4BY6NM5P7TLTV4JOD7K4BVYDECQC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
HALS7E5UGKCP3DFY456F7Z3Y6WNGIABOCV2SHT34D5ZAGNCPV5PQC
SDEY7LFJ4LY735OZAJ6X5Y2SE3MFBT4X4TWLHVW3SS2JAK757E6QC
GZ5WULJVEZJJQPQPSQZE7CEPIYPJ2BJDYUJBMZRA5HLOO7TE3DOQC
KKMFQDR43ZWVCDRHQLWWX3FCWCFA3ZSXYOBRJNPHUQZR2XPKWULAC
if pos <= State.cursor1.pos and pos + frag_len >= State.cursor1.pos then
if State.search_term then
if State.search_term then
if pos <= State.cursor1.pos and pos + frag_len >= State.cursor1.pos then
if pos <= State.cursor1.pos and pos + frag_len >= State.cursor1.pos then
if State.search_term then
if State.search_term then
if pos <= State.cursor1.pos and pos + frag_len >= State.cursor1.pos then