* lisp/progmodes/python.el (python-hideshow-forward-sexp-function): Move
point to the end of the line.
* test/lisp/progmodes/python-tests.el (python-hideshow-hide-block-2):
New test. (Bug#71170)
(cherry picked from commit
25ab3e7be8b1c71b5939682c5b5fe6810807bcc5)
(defun python-hideshow-forward-sexp-function (_arg)
"Python specific `forward-sexp' function for `hs-minor-mode'.
Argument ARG is ignored."
- (python-nav-end-of-block))
+ (python-nav-end-of-block)
+ (end-of-line))
(defun python-hideshow-find-next-block (regexp maxp comments)
"Python specific `hs-find-next-block' function for `hs-minor-mode'.
"))))
+(ert-deftest python-hideshow-hide-block-2 ()
+ "Should hide the comment at the end of the block."
+ (python-tests-with-temp-buffer
+ "
+def f():
+ a = 1 # Comment
+"
+ (hs-minor-mode 1)
+ (python-tests-look-at "def")
+ (hs-hide-block)
+ (should
+ (string=
+ (python-tests-visible-string)
+ "
+def f():
+"))))
+
+
(ert-deftest python-tests--python-nav-end-of-statement--infloop ()
"Checks that `python-nav-end-of-statement' doesn't infloop in a
buffer with overlapping strings."