From cb975c6183ed1653cc8d7fe5283a9b294bf07bf4 Mon Sep 17 00:00:00 2001 From: kobarity Date: Sun, 16 Oct 2022 11:26:29 +0200 Subject: 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). --- lisp/progmodes/python.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lisp/progmodes/python.el') diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 50f1e6752e4..11195894234 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -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) -- cgit v1.2.1