about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--main.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/main.lua b/main.lua
index cb4858b..93a97a9 100644
--- a/main.lua
+++ b/main.lua
@@ -267,9 +267,13 @@ function keychord_pressed(chord)
   -- Don't handle any keys here that would trigger love.textinput above.
   -- shortcuts for text
   if chord == 'return' then
-    table.insert(Lines, Cursor_line+1, {mode='text', data=''})
-    Cursor_line = Cursor_line+1
-    Cursor_pos = 1
+    local byte_offset = utf8.offset(Lines[Cursor_line].data, Cursor_pos)
+    if byte_offset then
+      table.insert(Lines, Cursor_line+1, {mode='text', data=string.sub(Lines[Cursor_line].data, byte_offset)})
+      Lines[Cursor_line].data = string.sub(Lines[Cursor_line].data, 1, byte_offset)
+      Cursor_line = Cursor_line+1
+      Cursor_pos = 1
+    end
   elseif chord == 'left' then
     if Cursor_pos > 1 then
       Cursor_pos = Cursor_pos-1
268974bb84551df485bd5'>23e9be3 ^
f421e1d ^
2a0a770 ^
bc95ec4 ^
f421e1d ^







a8a8965 ^
f421e1d ^



a8a8965 ^
f421e1d ^






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