bugfix: delete selection before pasting

[?]
Jun 21, 2022, 4:53 PM
KMRJOSLYYHHPGMYXBSLUQTICP6F4LXRCGYSP55YTZQSX4SZISDEAC

Dependencies

  • [2] AOIRVVJA revert selection logic to before commit 3ffc2ed8f
  • [3] AVLAYODP much simpler
  • [4] XDB5D7H7 some early returns should be asserts
  • [5] VJ77YABH more efficient undo/redo
  • [6] DRFE3B3Z mouse buttons are integers, not strings
  • [*] LXTTOB33 extract a couple of files
  • [*] 4WAFGF4Z selection bugfix
  • [*] VG75U7IM bugfix: typing should delete highlighted text
  • [*] BULPIBEG beginnings of a module for the text editor
  • [*] OTIBCAUJ love2d scaffold
  • [*] AVTNUQYR basic test-enabled framework
  • [*] Z4XRNDTR find text

Change contents

  • edit in text_tests.lua at line 262
    [9.617]
    [10.520]
    end
    function test_cut()
    io.write('\ntest_cut')
    -- 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()
    -- press a key
    App.run_after_keychord('C-x')
    check_eq(App.clipboard, 'a', 'F - test_cut/clipboard')
    -- selected text is deleted
    check_eq(Lines[1].data, 'bc', 'F - test_cut/data')
    end
    function test_paste_replaces_selection()
    io.write('\ntest_paste_replaces_selection')
    -- display a line of text with a selection
    App.screen.init{width=80, height=80}
    Lines = load_array{'abc', 'def'}
    Line_width = 75
    Cursor1 = {line=2, pos=1}
    Selection1 = {line=1, pos=1}
    Screen_top1 = {line=1, pos=1}
    Screen_bottom1 = {}
    App.draw()
    -- set clipboard
    App.clipboard = 'xyz'
    -- paste selection
    App.run_after_keychord('C-v')
    -- selection is reset since shift key is not pressed
    -- selection includes the newline, so it's also deleted
    check_eq(Lines[1].data, 'xyzdef', 'F - test_paste_replaces_selection')
  • edit in text.lua at line 145
    [3.98][2.36:96]()
    if Selection1.line then
    Text.delete_selection()
    end
  • edit in main.lua at line 413
    [13.1550]
    [14.3090]
    if Selection1.line and not App.shift_down() and chord ~= 'C-c' and chord ~= 'C-x' and chord ~= 'backspace' and backspace ~= 'delete' then
    Text.delete_selection()
    end