diff --git a/jupyter-repl.el b/jupyter-repl.el index 5c65f0f..5cc8d50 100644 --- a/jupyter-repl.el +++ b/jupyter-repl.el @@ -1550,12 +1550,13 @@ begiining of the symbol at point to look for a match of RE." (cons symbol t) symbol))))) -(defun jupyter-completion-floating-point-p () - "Return non-nil if the text before `point' may be a floating point number. -If the preceeding two characters before point are \"[0-9].\" -return non-nil, otherwise return nil." - (and (= (char-before (point)) ?.) - (<= ?0 (char-before (1- (point))) ?9))) +(defun jupyter-completion-number-p () + "Return non-nil if the text before `point' may be a floating point number." + (and (or (<= ?0 (char-before (point)) ?9) + (eq (char-before (point)) ?.)) + (save-excursion + (skip-syntax-backward "w.") + (looking-at-p "[0-9]+\\.?[0-9]*")))) ;;; Extracting arguments from argument strings diff --git a/jupyter-tests.el b/jupyter-tests.el index 8413bb4..3c613a2 100644 --- a/jupyter-tests.el +++ b/jupyter-tests.el @@ -493,6 +493,24 @@ running BODY." (should (json-plist-p res)) (should (eq (jupyter-message-type res) :shutdown-reply)))))) +(ert-deftest jupyter-completion () + (ert-info ("`jupyter-completion-number-p'") + (with-temp-buffer + (insert "0.311") + (should (jupyter-completion-number-p)) + (erase-buffer) + (insert "0311") + (should (jupyter-completion-number-p)) + (erase-buffer) + (insert "0311.") + (should (jupyter-completion-number-p)) + (erase-buffer) + (insert "100foo") + (should-not (jupyter-completion-number-p)) + (erase-buffer) + (insert "foo100") + (should-not (jupyter-completion-number-p))))) + (ert-deftest jupyter-repl () (jupyter-with-python-repl client (should (jupyter-repl-client-has-manager-p))