Fix 'python-shell-buffer-substring' when START is in middle of 1st line
* lisp/progmodes/python.el (python-shell-buffer-substring): Instead of checking whether START is point-min, check whether START is in the first line. (Bug#60466) * test/lisp/progmodes/python-tests.el (python-shell-buffer-substring-18): New test.
This commit is contained in:
parent
7f9588685a
commit
f58452e3ae
2 changed files with 15 additions and 4 deletions
|
@ -3766,15 +3766,16 @@ the python shell:
|
||||||
(line-beginning-position)
|
(line-beginning-position)
|
||||||
start))))
|
start))))
|
||||||
(substring (buffer-substring-no-properties start end))
|
(substring (buffer-substring-no-properties start end))
|
||||||
(starts-at-point-min-p (save-restriction
|
(starts-at-first-line-p (save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
(= (point-min) start)))
|
(goto-char start)
|
||||||
|
(= (line-number-at-pos) 1)))
|
||||||
(encoding (python-info-encoding))
|
(encoding (python-info-encoding))
|
||||||
(toplevel-p (zerop (save-excursion
|
(toplevel-p (zerop (save-excursion
|
||||||
(goto-char start)
|
(goto-char start)
|
||||||
(python-util-forward-comment 1)
|
(python-util-forward-comment 1)
|
||||||
(current-indentation))))
|
(current-indentation))))
|
||||||
(fillstr (cond (starts-at-point-min-p
|
(fillstr (cond (starts-at-first-line-p
|
||||||
nil)
|
nil)
|
||||||
((not no-cookie)
|
((not no-cookie)
|
||||||
(concat
|
(concat
|
||||||
|
|
|
@ -4520,6 +4520,16 @@ def foo():
|
||||||
(python-tests-look-at "\"\"\""))
|
(python-tests-look-at "\"\"\""))
|
||||||
"# -*- coding: utf-8 -*-\n\nif True:\n a = 1\n b = 2\n\n"))))
|
"# -*- coding: utf-8 -*-\n\nif True:\n a = 1\n b = 2\n\n"))))
|
||||||
|
|
||||||
|
(ert-deftest python-shell-buffer-substring-18 ()
|
||||||
|
"Check substring from the part of the first line."
|
||||||
|
(python-tests-with-temp-buffer
|
||||||
|
"s = 'test'
|
||||||
|
"
|
||||||
|
(should (string= (python-shell-buffer-substring
|
||||||
|
(python-tests-look-at "'test'")
|
||||||
|
(pos-eol))
|
||||||
|
"'test'"))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; Shell completion
|
;;; Shell completion
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue