aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkobarity2022-10-16 11:26:29 +0200
committerLars Ingebrigtsen2022-10-16 11:26:29 +0200
commitcb975c6183ed1653cc8d7fe5283a9b294bf07bf4 (patch)
tree94ff57522638d9aefafbb76eee7448f4fbef4390
parentf9726408f6cb56b3a97a9e76be166a5156faec0b (diff)
downloademacs-cb975c6183ed1653cc8d7fe5283a9b294bf07bf4.tar.gz
emacs-cb975c6183ed1653cc8d7fe5283a9b294bf07bf4.zip
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).
-rw-r--r--lisp/progmodes/python.el21
-rw-r--r--test/lisp/progmodes/python-tests.el27
2 files changed, 39 insertions, 9 deletions
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."
4080 (buffer-substring-no-properties line-start (point))) 4080 (buffer-substring-no-properties line-start (point)))
4081 (buffer-substring-no-properties line-start (point)))) 4081 (buffer-substring-no-properties line-start (point))))
4082 (start 4082 (start
4083 (save-excursion 4083 (if (< (point) line-start)
4084 (if (not (re-search-backward 4084 (point)
4085 (python-rx 4085 (save-excursion
4086 (or whitespace open-paren close-paren string-delimiter simple-operator)) 4086 (if (not (re-search-backward
4087 line-start 4087 (python-rx
4088 t 1)) 4088 (or whitespace open-paren close-paren
4089 line-start 4089 string-delimiter simple-operator))
4090 (forward-char (length (match-string-no-properties 0))) 4090 line-start
4091 (point)))) 4091 t 1))
4092 line-start
4093 (forward-char (length (match-string-no-properties 0)))
4094 (point)))))
4092 (end (point)) 4095 (end (point))
4093 (prompt-boundaries 4096 (prompt-boundaries
4094 (with-current-buffer (process-buffer process) 4097 (with-current-buffer (process-buffer process)
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 97dc17ce293..71bd0e0d682 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -4509,6 +4509,33 @@ import abc
4509 (python-eldoc-function) 4509 (python-eldoc-function)
4510 (should (completion-at-point))))) 4510 (should (completion-at-point)))))
4511 4511
4512(ert-deftest python-shell-completion-shell-buffer-1 ()
4513 (skip-unless (executable-find python-tests-shell-interpreter))
4514 (python-tests-with-temp-buffer-with-shell
4515 ""
4516 (python-shell-with-shell-buffer
4517 (insert "import abc")
4518 (comint-send-input)
4519 (python-tests-shell-wait-for-prompt)
4520 (insert "abc.")
4521 (should (nth 2 (python-shell-completion-at-point)))
4522 (end-of-line 0)
4523 (should-not (nth 2 (python-shell-completion-at-point))))))
4524
4525(ert-deftest python-shell-completion-shell-buffer-native-1 ()
4526 (skip-unless (executable-find python-tests-shell-interpreter))
4527 (python-tests-with-temp-buffer-with-shell
4528 ""
4529 (python-shell-completion-native-turn-on)
4530 (python-shell-with-shell-buffer
4531 (insert "import abc")
4532 (comint-send-input)
4533 (python-tests-shell-wait-for-prompt)
4534 (insert "abc.")
4535 (should (nth 2 (python-shell-completion-at-point)))
4536 (end-of-line 0)
4537 (should-not (nth 2 (python-shell-completion-at-point))))))
4538
4512 4539
4513 4540
4514;;; PDB Track integration 4541;;; PDB Track integration