All places where string.sub was being passed a _pos variable.
CPZGQT72EBP3SEDBPDWQRK5IUGA664PHXNP2GOHJLP43PKPWF25AC
4VKEE43Z7MUPNIAOCK36INVBNHRTSWRRN37TIKRPXPH3DRKGHHAQC
ZPUQSPQPQFVRUIHGLAWW3IDBYODIWDHO62HAC3WWF5TM3CIJGHNQC
BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC
5L7K4GBDEAFH44LMLNKVFMHLWDNXXBKRPEI347VE5ZLXVFSMD2FAC
HOSPP2ANSW654DYRTC6CQUQA2GUKV6T2FI7QBKXD2DZS3R32IMGAC
BJ5X5O4ACBBJ56LRBBSTCW6IBQP4HAEOOOPNH3SKTA4F66YTOIDAC
local s = string.sub(Lines[Cursor1.line].data, screen_line_starting_pos)
local screen_line_starting_byte_offset = utf8.offset(Lines[Cursor1.line].data, screen_line_starting_pos)
assert(screen_line_starting_byte_offset)
local s = string.sub(Lines[Cursor1.line].data, screen_line_starting_byte_offset)
local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_pos)
local new_screen_line_starting_byte_offset = utf8.offset(Lines[Cursor1.line].data, new_screen_line_starting_pos)
assert(new_screen_line_starting_byte_offset)
local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_byte_offset)
local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_pos)
local new_screen_line_starting_byte_offset = utf8.offset(Lines[Cursor1.line].data, new_screen_line_starting_pos)
assert(new_screen_line_starting_byte_offset)
local s = string.sub(Lines[Cursor1.line].data, new_screen_line_starting_byte_offset)
--? print('iter', y, screen_line_index, screen_line_starting_pos, string.sub(line.data, screen_line_starting_pos))
local screen_line_starting_byte_offset = utf8.offset(line.data, screen_line_starting_pos)
assert(screen_line_starting_byte_offset)
--? print('iter', y, screen_line_index, screen_line_starting_pos, string.sub(line.data, screen_line_starting_byte_offset))
-- static properties of the code
All strings are UTF-8. Bytes within them are not characters.
I try to label byte offsets as _offset, and character positions as _pos.
For example, string.sub should never use a _pos to substring, only an _offset.
Wish I had some static typing here. We're not going to try to write tests to catch issues like this.
-- manual tests