about summary refs log tree commit diff stats
path: root/select.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-19 09:03:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-19 09:06:41 -0700
commit703ed905c13a837c683aed0bf09bb68b0d7c9430 (patch)
tree646003b6fe6ec9d54581174c17062b9c2e12475c /select.lua
parentb6fa2aae6e9b0793280139ad7e5edd2468eac494 (diff)
downloadtext.love-703ed905c13a837c683aed0bf09bb68b0d7c9430.tar.gz
bugfix: crash in Text.up() after return
Let's just make all the utf8.offset calculations more defensive.
Diffstat (limited to 'select.lua')
-rw-r--r--select.lua14
1 files changed, 7 insertions, 7 deletions
diff --git a/select.lua b/select.lua
index 839e770..5659015 100644
--- a/select.lua
+++ b/select.lua
@@ -55,9 +55,9 @@ end
 -- Returns some intermediate computation useful elsewhere.
 function Text.draw_highlight(line, x,y, pos, lo,hi)
   if lo then
-    local lo_offset = utf8.offset(line.data, lo)
-    local hi_offset = utf8.offset(line.data, hi)
-    local pos_offset = utf8.offset(line.data, pos)
+    local lo_offset = Text.offset(line.data, lo)
+    local hi_offset = Text.offset(line.data, hi)
+    local pos_offset = Text.offset(line.data, pos)
     local lo_px
     if pos == lo then
       lo_px = 0
@@ -137,8 +137,8 @@ function Text.delete_selection_without_undo()
   -- delete everything between min (inclusive) and max (exclusive)
   Lines[minl].fragments = nil
   Lines[minl].screen_line_starting_pos = nil
-  local min_offset = utf8.offset(Lines[minl].data, minp)
-  local max_offset = utf8.offset(Lines[maxl].data, maxp)
+  local min_offset = Text.offset(Lines[minl].data, minp)
+  local max_offset = Text.offset(Lines[maxl].data, maxp)
   if minl == maxl then
 --?     print('minl == maxl')
     Lines[minl].data = Lines[minl].data:sub(1, min_offset-1)..Lines[minl].data:sub(max_offset)
@@ -165,8 +165,8 @@ function Text.selection()
       minp,maxp = maxp,minp
     end
   end
-  local min_offset = utf8.offset(Lines[minl].data, minp)
-  local max_offset = utf8.offset(Lines[maxl].data, maxp)
+  local min_offset = Text.offset(Lines[minl].data, minp)
+  local max_offset = Text.offset(Lines[maxl].data, maxp)
   if minl == maxl then
     return Lines[minl].data:sub(min_offset, max_offset-1)
   end
-01-13 11:46:01 -0500 snapshot of project "lynx", label v2-8-2dev_13' href='/ingrix/lynx-snapshots/commit/lynx_help/keystrokes/edit_help.html?id=a2e9461739dd215db90a5cee2c22a74e5f57d151'>a2e94617 ^
4525eb4b ^
a2e94617 ^








8ce6b560 ^
a2e94617 ^






c5fef0d4 ^
c7bfda90 ^
a2e94617 ^
4525eb4b ^





8ce6b560 ^
a2e94617 ^

8ce6b560 ^
4525eb4b ^






e087f6d4


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71