Skip to content

Commit

Permalink
Visual X, deletion column respects stick eol
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdl89 committed Mar 30, 2024
1 parent 643e01d commit 476f5fb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
13 changes: 11 additions & 2 deletions evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,10 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
;; Special exceptions to ever saving column:
(not (memq evil-this-motion '(evil-forward-word-begin
evil-forward-WORD-begin))))
(move-to-column evil-operator-start-col))))
(move-to-column (if (and (eq most-positive-fixnum temporary-goal-column)
(memq last-command '(next-line previous-line)))
temporary-goal-column
evil-operator-start-col)))))

(evil-define-operator evil-delete-line (beg end type register yank-handler)
"Delete to end of line."
Expand All @@ -1526,7 +1529,13 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
(let ((temporary-goal-column most-positive-fixnum)
(last-command 'next-line))
(evil-delete beg end 'block register yank-handler))
(evil-delete beg end type register yank-handler))))
(evil-delete beg end type register yank-handler)
(evil-first-non-blank)
(when (and (not evil-start-of-line) evil-operator-start-col)
(move-to-column (if (and (eq most-positive-fixnum temporary-goal-column)
(memq last-command '(next-line previous-line)))
temporary-goal-column
evil-operator-start-col))))))

(evil-define-operator evil-delete-whole-line
(beg end type register yank-handler)
Expand Down
1 change: 1 addition & 0 deletions evil-maps.el
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@
(define-key evil-visual-state-map "R" 'evil-change-whole-line)
(define-key evil-visual-state-map "u" 'evil-downcase)
(define-key evil-visual-state-map "U" 'evil-upcase)
(define-key evil-visual-state-map "X" 'evil-delete-line)
(define-key evil-visual-state-map "z=" 'ispell-word)
(define-key evil-visual-state-map "a" evil-outer-text-objects-map)
(define-key evil-visual-state-map "i" evil-inner-text-objects-map)
Expand Down
10 changes: 9 additions & 1 deletion evil-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,7 @@ then enter the text in that file's own buffer."))
";; This <buffe[r]> is for notes,
and for Lisp evaluation."
("D")
"[a]nd for Lisp evaluation."))
"and for Lisp [e]valuation."))
(ert-info ("Act on each line of block selection")
(evil-test-buffer
:visual block
Expand Down Expand Up @@ -2218,6 +2218,14 @@ ine3 line3 line3 l\n"))
("\C-w")
"alpha [b]ravo charlie delta")))

(ert-deftest evil-test-visual-X ()
"Test `X' in visual state."
:tags '(evil)
(evil-test-buffer
"This is line one\nThis is lin[e] two\nThis is line three"
("v$oX")
"This is line one\nThis is lin[e] three"))

(ert-deftest evil-test-delete-back-to-indentation ()
"Test `evil-delete-back-to-indentation' in insert & replace states."
:tags '(evil)
Expand Down

3 comments on commit 476f5fb

@axelf4
Copy link
Collaborator

@axelf4 axelf4 commented on 476f5fb Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change unfortunately breaks evil-delete-line/evil-change-line with evil-start-of-line set to nil for me, in that they now move the cursor to BOL instead of leaving it in place. Let me know if you want me to file a proper issue.

@tomdl89
Copy link
Member Author

@tomdl89 tomdl89 commented on 476f5fb Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @axelf4 - I should've thought of that! If I don't find time to fix today, I'll revert until I do. No need for an issue.

@tomdl89
Copy link
Member Author

@tomdl89 tomdl89 commented on 476f5fb Apr 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should now be fixed in master @axelf4. Thanks again for spotting.

Please sign in to comment.