@@ -1553,15 +1553,17 @@ extracted from MESSAGE and converted to the first form.")
15531553 " Return non-nil if a prefetch for PREFIX should be performed.
15541554Looks at `jupyter-completion-cache' to determine if its
15551555candidates can be used for PREFIX."
1556- (not (and jupyter-completion-cache
1557- (if (eq (car jupyter-completion-cache) 'fetched )
1558- (equal (nth 1 jupyter-completion-cache) prefix)
1559- (or (equal (car jupyter-completion-cache) prefix)
1560- (and (not (string= (car jupyter-completion-cache) " " ))
1561- (string-prefix-p (car jupyter-completion-cache) prefix))))
1562- ; ; Invalidate the cache when completing argument lists
1563- (or (string= prefix " " )
1564- (not (eq (aref prefix (1- (length prefix))) ?\( ))))))
1556+ (or
1557+ ; ; Invalidate the cache when completing argument lists
1558+ (and (not (string-empty-p prefix))
1559+ (eq (aref prefix (1- (length prefix))) ?\( ))
1560+ (pcase jupyter-completion-cache
1561+ ((or `(fetched , cached-prefix , _ )
1562+ `(, cached-prefix . , _ ))
1563+ ; ; If the prefix is the same as the cached prefix, no prefetch
1564+ ; ; needed.
1565+ (not (equal prefix cached-prefix)))
1566+ (_ t ))))
15651567
15661568(defun jupyter-completion-prefetch (fun )
15671569 " Get completions for the current completion context.
0 commit comments