1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 12:21:25 -08:00

Fix invalid search bound error in python-shell-completion-at-point

* lisp/progmodes/python.el (python-shell-completion-at-point): Add
check if point is before line-start.
* test/lisp/progmodes/python-tests.el (python-shell-completion-shell-buffer-1)
(python-shell-completion-shell-buffer-native-1): New tests
(bug#58548).
This commit is contained in:
kobarity 2022-10-16 11:26:29 +02:00 committed by Lars Ingebrigtsen
parent f9726408f6
commit cb975c6183
2 changed files with 39 additions and 9 deletions

View file

@ -4080,15 +4080,18 @@ using that one instead of current buffer's process."
(buffer-substring-no-properties line-start (point)))
(buffer-substring-no-properties line-start (point))))
(start
(save-excursion
(if (not (re-search-backward
(python-rx
(or whitespace open-paren close-paren string-delimiter simple-operator))
line-start
t 1))
line-start
(forward-char (length (match-string-no-properties 0)))
(point))))
(if (< (point) line-start)
(point)
(save-excursion
(if (not (re-search-backward
(python-rx
(or whitespace open-paren close-paren
string-delimiter simple-operator))
line-start
t 1))
line-start
(forward-char (length (match-string-no-properties 0)))
(point)))))
(end (point))
(prompt-boundaries
(with-current-buffer (process-buffer process)

View file

@ -4509,6 +4509,33 @@ import abc
(python-eldoc-function)
(should (completion-at-point)))))
(ert-deftest python-shell-completion-shell-buffer-1 ()
(skip-unless (executable-find python-tests-shell-interpreter))
(python-tests-with-temp-buffer-with-shell
""
(python-shell-with-shell-buffer
(insert "import abc")
(comint-send-input)
(python-tests-shell-wait-for-prompt)
(insert "abc.")
(should (nth 2 (python-shell-completion-at-point)))
(end-of-line 0)
(should-not (nth 2 (python-shell-completion-at-point))))))
(ert-deftest python-shell-completion-shell-buffer-native-1 ()
(skip-unless (executable-find python-tests-shell-interpreter))
(python-tests-with-temp-buffer-with-shell
""
(python-shell-completion-native-turn-on)
(python-shell-with-shell-buffer
(insert "import abc")
(comint-send-input)
(python-tests-shell-wait-for-prompt)
(insert "abc.")
(should (nth 2 (python-shell-completion-at-point)))
(end-of-line 0)
(should-not (nth 2 (python-shell-completion-at-point))))))
;;; PDB Track integration