-
-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
cider-eval-toplevel-inside-comment-form
breaks autocomplete inside comment
form
#2375
Comments
That's a bit more nuanced than this:
Overall that's just another manifestation of the big (and old) problem that |
@bbatsov thanks for the thoughts. if this notion of top level defun inside of a comment form should live on it should definitely go inside clojure mode. But holding onto this feature kinda obligates it. I wasn't sure of your thoughts on whether this more complicated notion of top-level defun was something you wanted to take on. Alternatively, we could wait and see where these issues crop up. This one is easily solves as well as just dynamically binding the var to nil so the completion context is the entire comment form which should be fine. |
Btw, turns out there's a much simpler fix. I just remembered that major modes can override this the internal of the See the definition of |
Great insight! I'll get to that early next week unless someone wants to tackle it before then. |
Example:
if point is at
|
you would expect the autocompletion to suggestthing
. And it does ifcider-eval-toplevel-inside-comment-form
is nil. But if this is truthy you are greeted with the following message:The problem is in
cider-completion-get-context-at-point
which gets the context for the completion which includes in relevant part:The problem is that it uses
cider-defun-at-point
and thenbeginning-of-defun
. The former is aware that top level may be one level deep inside of acomment
form, the later goes to the top level open parens no questions asked. This breaks assumptions about the substring it will get.A simple fix is to only use "beginning of defun" aware functions:
But if we wish to keep the top-level-defun inside of comment forms feature, we need to eradicate all usages of
beginning-of-defun
in the codebase since it is not aware that top level has a bit more logic to it. I count 11 non-comment usages of this. It should be mechanical but I didn't realize this feature had this price originally.I think it is fine and we should change
(beginning-of-defun)
to some type ofcider-beginning-of-defun
but I just wanted to make sure this was acceptable beforehand.The text was updated successfully, but these errors were encountered: