about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-20 11:33:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-20 11:33:04 -0700
commitd90617ee2434cdb9fc881656a4da8515927a83e4 (patch)
tree01c5aaff59a2614a1b4d2de2ff80eadfa082b636 /text.lua
parent3986e99fe0586e35a0c649114a07e6dd90f769fc (diff)
downloadtext.love-d90617ee2434cdb9fc881656a4da8515927a83e4.tar.gz
remove some redundant checks
Now all the cases manage Selection1 similarly.
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua40
1 files changed, 10 insertions, 30 deletions
diff --git a/text.lua b/text.lua
index 2888c1f..11c6c7b 100644
--- a/text.lua
+++ b/text.lua
@@ -272,14 +272,10 @@ function Text.keychord_pressed(chord)
     Selection1 = {}
   --== shortcuts that move the cursor
   elseif chord == 'left' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Text.left()
   elseif chord == 'right' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Text.right()
   elseif chord == 'S-left' then
     if Selection1.line == nil then
@@ -293,14 +289,10 @@ function Text.keychord_pressed(chord)
     Text.right()
   -- C- hotkeys reserved for drawings, so we'll use M-
   elseif chord == 'M-left' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Text.word_left()
   elseif chord == 'M-right' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Text.word_right()
   elseif chord == 'M-S-left' then
     if Selection1.line == nil then
@@ -313,14 +305,10 @@ function Text.keychord_pressed(chord)
     end
     Text.word_right()
   elseif chord == 'home' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Cursor1.pos = 1
   elseif chord == 'end' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1
   elseif chord == 'S-home' then
     if Selection1.line == nil then
@@ -333,14 +321,10 @@ function Text.keychord_pressed(chord)
     end
     Cursor1.pos = utf8.len(Lines[Cursor1.line].data) + 1
   elseif chord == 'up' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Text.up()
   elseif chord == 'down' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Text.down()
   elseif chord == 'S-up' then
     if Selection1.line == nil then
@@ -353,14 +337,10 @@ function Text.keychord_pressed(chord)
     end
     Text.down()
   elseif chord == 'pageup' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Text.pageup()
   elseif chord == 'pagedown' then
-    if Selection1.line then
-      Selection1 = {}
-    end
+    Selection1 = {}
     Text.pagedown()
   elseif chord == 'S-pageup' then
     if Selection1.line == nil then