From 4e9298dda1fb67527d5fdd3172217b803b27e652 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 8 Feb 2024 02:23:56 -0800 Subject: bugfix in cursor positioning scenario: - create a long wrapping line - tap past end of first screen line Before this commit the cursor would be positioned not quite at the end of the screen line but one character before. In effect there was no way to position cursor at end of a wrapping line. I'm not sure how this bug has lasted so long. It was introduced in commit 8d3adfa36 back in June 2022, which was itself billed as a bugfix for "clicking past end of screen line". But when I go back to it this bug exists even back then. How did I miss it?! I wrote a test back then -- and the test was wrong, has always been wrong. --- source_text.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source_text.lua') diff --git a/source_text.lua b/source_text.lua index b22d358..7c1838c 100644 --- a/source_text.lua +++ b/source_text.lua @@ -798,7 +798,7 @@ function Text.to_pos_on_line(State, line_index, mx, my) -- (The final screen line positions past end of screen line as always.) if screen_line_index < #line_cache.screen_line_starting_pos and mx > State.left + Text.screen_line_width(State, line_index, screen_line_index) then --? print('past end of non-final line; return') - return line_cache.screen_line_starting_pos[screen_line_index+1]-1 + return line_cache.screen_line_starting_pos[screen_line_index+1] end local s = string.sub(line.data, screen_line_starting_byte_offset) --? print('return', mx, Text.nearest_cursor_pos(State.font, s, mx, State.left), '=>', screen_line_starting_pos + Text.nearest_cursor_pos(State.font, s, mx, State.left) - 1) -- cgit 1.4.1-2-gfad0 input type='hidden' name='id' value='d20ad73467c0636edea6133d7bd4b38bbfdefc55'/>
path: root/svc/cache.go
blob: c51478bf488552ebd175c11933d2d4fb16bced53 (plain) (blame)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98