about summary refs log tree commit diff stats
path: root/text_tests.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-20 12:06:44 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-20 12:12:09 -0700
commit978c1433976a72193a33dc9f2f52e514fce9db41 (patch)
tree332320e6687e0628a9f033482e7bfa689fd51298 /text_tests.lua
parent7508a70ed5cb57beec1a69b996caf5375a446077 (diff)
downloadlines.love-978c1433976a72193a33dc9f2f52e514fce9db41.tar.gz
snapshot: test for a new regression
Caused by commit 3ffc2ed8f.

We might need to bring back a lot of complexity for this.
Diffstat (limited to 'text_tests.lua')
-rw-r--r--text_tests.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/text_tests.lua b/text_tests.lua
index 0fbe98c..93881ea 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -1317,3 +1317,25 @@ function test_undo_delete_text()
   y = y + Line_height
   App.screen.check(y, 'xyz', 'F - test_undo_delete_text/screen:3')
 end
+
+function test_undo_restores_selection()
+  io.write('\ntest_undo_restores_selection')
+  -- display a line of text with some part selected
+  App.screen.init{width=80, height=80}
+  Lines = load_array{'abc'}
+  Line_width = 75
+  Cursor1 = {line=1, pos=1}
+  Selection1 = {line=1, pos=2}
+  Screen_top1 = {line=1, pos=1}
+  Screen_bottom1 = {}
+  App.draw()
+  -- delete selected text
+  App.run_after_textinput('x')
+  check_eq(Lines[1].data, 'xbc', 'F - test_undo_restores_selection/baseline')
+  check_nil(Selection1.line, 'F - test_undo_restores_selection/baseline:selection')
+  -- undo
+  App.run_after_keychord('C-z')
+  -- selection is restored
+  check_eq(Selection1.line, 1, 'F - test_undo_restores_selection/line')
+  check_eq(Selection1.pos, 2, 'F - test_undo_restores_selection/pos')
+end