Commit b515edb9 authored by Stephen Leake's avatar Stephen Leake

Fix bug in delete-indentation when region is inactive

* test/lisp/simple-tests.el: Add tests for delete-indentation.
(simple-delete-indentation-no-region): Works with no region.
(simple-delete-indentation-inactive-region): Was broken with inactive
region; now fixed.

* lisp/simple.el (delete-indentation): Check (use-region-p) before using BEG.
parent c1b63af4
Pipeline #1057 passed with stage
in 48 minutes and 43 seconds
......@@ -617,7 +617,8 @@ region is ignored if prefix argument is given.)"
(+ (point) (length fill-prefix)))))
(delete-region (point) (+ (point) (length fill-prefix))))
(fixup-whitespace)
(if (and beg
(if (and (use-region-p)
beg
(not arg)
(< beg (point-at-bol)))
(beginning-of-line)))))
......
......@@ -213,6 +213,40 @@
(should (= x 0)))
(remove-hook 'post-self-insert-hook inc))))
;;; `delete-indentation'
(ert-deftest simple-delete-indentation-no-region ()
"delete-indentation works when no mark is set."
;; interactive \r returns nil for BEG END args
(unwind-protect
(with-temp-buffer
(insert (concat "zero line \n"
"first line \n"
"second line"))
(delete-indentation)
(should (string-equal
(buffer-string)
(concat "zero line \n"
"first line second line")))
)))
(ert-deftest simple-delete-indentation-inactive-region ()
"delete-indentation ignores inactive region."
;; interactive \r returns non-nil for BEG END args
(unwind-protect
(with-temp-buffer
(insert (concat "zero line \n"
"first line \n"
"second line"))
(push-mark (point-min) t t)
(deactivate-mark)
(delete-indentation)
(should (string-equal
(buffer-string)
(concat "zero line \n"
"first line second line")))
)))
;;; `delete-trailing-whitespace'
(ert-deftest simple-delete-trailing-whitespace--bug-21766 ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment