Skip to content

Commit

Permalink
[completion] Don't pass :same if context string hasn't changed
Browse files Browse the repository at this point in the history
This has been a quite awkward premature optimization that turned up to be
unnecessary. The support for it has been broken in Compliment 0.5.1.
  • Loading branch information
alexander-yakushev committed Jan 29, 2024
1 parent 60c9cea commit 8d1dfd4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Bugs fixed

- [#3605](https://github.com/clojure-emacs/cider/issues/3605): avoid `cider--error-phase-of-last-exception` recursive loop.
- [#3613](https://github.com/clojure-emacs/cider/issues/3613): Auto completion is not reliable after switching to cider-nrepl 0.45.0

## 1.13.0 (2024-01-14)

Expand Down
28 changes: 11 additions & 17 deletions cider-completion-context.el
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,21 @@ form, with symbol at point replaced by __prefix__."
"__prefix__"
(substring context (- pref-end expr-start)))))))

(defvar cider-completion-last-context nil)

(defun cider-completion-get-context (&optional info)
"Extract context depending (maybe of INFO type).
Output depends on `cider-completion-use-context' and the current major mode."
(let ((context (if cider-completion-use-context
;; We use ignore-errors here since grabbing the context
;; might fail because of unbalanced parens, or other
;; technical reasons, yet we don't want to lose all
;; completions and throw error to user because of that.
(or (ignore-errors
(if info
(cider-completion-get-info-context-at-point)
(cider-completion-get-context-at-point)))
"nil")
"nil")))
(if (string= cider-completion-last-context context)
":same"
(setq cider-completion-last-context context)
context)))
(if cider-completion-use-context
;; We use ignore-errors here since grabbing the context
;; might fail because of unbalanced parens, or other
;; technical reasons, yet we don't want to lose all
;; completions and throw error to user because of that.
(or (ignore-errors
(if info
(cider-completion-get-info-context-at-point)
(cider-completion-get-context-at-point)))
"nil")
"nil"))

(provide 'cider-completion-context)
;;; cider-completion-context.el ends here

0 comments on commit 8d1dfd4

Please sign in to comment.