Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve and unify CopyLine, CutLine, DeleteLine, DuplicateLine actions #3335

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Commits on Jun 9, 2024

  1. Fix Cursor{Up,Down} after DeleteLine and CutLine

    After executing CutLine or DeleteLine action, the cursor is at the
    beginning of a line (as expected) but then moving the cursor up or down
    moves it to an unexpected location in the middle of the next or previous
    line. Fix this by updating the cursor's LastVisualX.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    19c69f9 View commit details
    Browse the repository at this point in the history
  2. Fix Cursor{Up,Down} after CopyLine

    After executing the CopyLine action, moving cursor up or down
    unexpectedly moves cursor to the beginning of the line, since its
    LastVisualX value is lost in the selection/deselection manipulations.
    Fix this by restoring the original LastVisualX.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    df8d528 View commit details
    Browse the repository at this point in the history
  3. Fix CopyLine at the last empty line of buffer

    When the cursor is at the last line of buffer and it is an empty line,
    CopyLine does not copy this line, which is correct, but it shows a bogus
    "Copied line" message. Fix this by adding a check for that, same as in
    CutLine and DeleteLine.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    8bc6756 View commit details
    Browse the repository at this point in the history
  4. Make lastCutTime actually work

    The CutLine action has a feature: if we execute it multiple times to cut
    multiple lines, new cut lines are added to the previously cut lines in
    the clipboard instead of replacing the clipboard, unless those
    previously cut lines have been already pasted or the last cut was more
    than 10 seconds ago. This last bit doesn't really work: newly cut lines
    are appended to the clipboard regardless of when was the last cut.
    So fix it.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    52ed431 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    2860efb View commit details
    Browse the repository at this point in the history
  6. Reorganize Copy and CopyLine actions

    Make Copy return false if there is no selection, and change the default
    binding for Ctrl-c from CopyLine|Copy to Copy|CopyLine accordingly,
    to make the semantics more meaningful: copying selection always fails
    if there is no selection.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    830768b View commit details
    Browse the repository at this point in the history
  7. Reorganize Cut and CutLine actions

    Change behavior of the Cut action: don't implicitly call CutLine if
    there is no selection. Instead, make it return false in this case
    and change the default Ctrl-x binding to Cut|CutLine, to make it clear,
    explicit and in line with Copy and CopyLine actions.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    a317aef View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    c1bbd7b View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    9f7bdb1 View commit details
    Browse the repository at this point in the history
  10. CopyLine, CutLine, DeleteLine: respect selection

    When there is a selection containing multiple lines, CutLine, DeleteLine
    and CopyLine actions currently cut/delete/copy just the "current" line,
    as usual. This behavior is at least confusing, since when there is a
    selection, the cursor is not displayed, so the user doesn't know which
    line is the current one.
    
    So change the behavior. When there is a multi-line selection,
    cut/delete/copy all lines covered by the selection, not just the current
    line. Note that it will cut/delete/copy whole lines, not just the
    selection itself, i.e. if the first and/or the last line of the
    selection is only partially within the selection, we will
    cut/delete/copy the entire first and last lines nonetheless.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    fdacb28 View commit details
    Browse the repository at this point in the history
  11. CutLine: make infobar message more useful

    Since CutLine may add lines to the clipboard instead of replacing the
    clipboard, improve its info message to show how many lines are in the
    clipboard in total, not just how many lines were added to it last time.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    e6825f0 View commit details
    Browse the repository at this point in the history
  12. Make Cut, Copy, CopyLine don't mess with CutLine's multi line cuts

    Weird behavior is observed e.g. if we cut some lines with CutLine, then
    copy some selection with Copy, then cut some other lines with CutLine,
    and then paste. The pasted cliboard contains not just the lines that
    were cut at the last step, but also the selection that was copied before
    that.
    
    Fix that by resetting the CutLine's repeated line cuts whenever we
    copy anything to the clipboard via any other action (Cut, Copy or
    CopyLine).
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    04143c7 View commit details
    Browse the repository at this point in the history
  13. CutLine: return if cliboard read failed

    If we ever encounter this clipboard.Read() failure, return false
    immediately. Otherwise, InfoBar.Error(err) will have no effect (it will
    be immediately overwritten by InfoBar.Message()) so we won't even know
    that there was an error.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    33a1bb1 View commit details
    Browse the repository at this point in the history
  14. DuplicateLine: move selection duplication to separate Duplicate action

    - Add a new Duplicate action which just duplicates the selection (and
      returns false if there is no selection).
    - Change the behavior of the DuplicateLine action to only duplicate the
      current line, not the selection.
    - Change the default action bound to Ctrl-d from DuplicateLine to
      Duplicate|DuplicateLine, so that the default behavior doesn't change.
    
    This allows the user to rebind keybindings in a more flexible way, i.e.
    to choose whether a key should duplicate just lines, or just selections,
    or both, - in a similar fashion to Copy, Cut, Delete actions.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    25f71ee View commit details
    Browse the repository at this point in the history
  15. DuplicateLine: respect selections

    Similarly to CutLine, DeleteLine and CopyLine actions, if there is a
    selection, duplicate not just the current line but all the lines covered
    (fully or partially) by the selection.
    dmaluka committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    6f724bc View commit details
    Browse the repository at this point in the history

Commits on Jun 12, 2024

  1. CutLine: remove lastCutTime feature

    The lastCutTime feature (reset the clipboard instead of appending to the
    clipboard if the last CutLine was more than 10 seconds ago) was
    implemented 8 years ago but was always buggy and never really worked,
    until we have accidentally found and fixed the bug just now. No one ever
    complained or noticed that, which means it is not a very useful feature.
    Fixing it changes the existing behavior (essentially adds a new feature
    which did not really exist before) and there is no reason to assume that
    this new behavior will be welcome by users. So it's better to remove
    this feature.
    dmaluka committed Jun 12, 2024
    Configuration menu
    Copy the full SHA
    68d6f43 View commit details
    Browse the repository at this point in the history

Commits on Jun 13, 2024

  1. Configuration menu
    Copy the full SHA
    bf65847 View commit details
    Browse the repository at this point in the history