-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not display duplicate completions. As well as checking that the av… #503
Conversation
…ailability of the candidate is in the user's allowed availability filtered list - only add the element if it is unique. The current key used is a tuple of typed-text, annotation and return type.
Do you have an exemple of what is deduplicated with your code? For example, does this deduplicate const and non-const getters? const std::string & name() const;
std::string & name(); |
Currently I am testing with:
(notice that I think it would be safest to make this an optional thing. |
Do you have a concrete example of this? I'm still not sure what is duplicated. Did any candidate was removed in the example you just showed? If yes, which one(s)? |
@Sarcasm And, at work with my huge code base including third party libraries there are many more duplicates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for the explanation, make sense to me now.
Would be nice to explain this situation in the filtering code.
(memq (irony-completion-availability candidate) | ||
irony-completion-availability-filter)) | ||
candidates)) | ||
(let (unique-candidates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe (cons 1 (cons 2 (cons 3 nil)))
is the same as (list 1 2 3)
.
I think the first when
is useless now, as it is no longer the final statement.
Maybe you should use (and (memq ...) (push unique-key ...)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, I meant to rewrite the code like this:
(and (memq (irony-completion-availability candidate)
irony-completion-availability-filter))
(let ((unique-key (list (irony-completion-typed-text candidate)
(irony-completion-annotation candidate)
(irony-completion-type candidate))))
(and (not (member unique-key unique-candidates))
(push unique-key unique-candidates)))))
2 when
, makes the first useless:
(defun (a b)
(when a t)
(when b t))
Here, whatever the value of a
, t
will be returned only if b
is non-nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, just got back from work.
Yes, that makes sense.
I am just leaving from work now and made some quick changes as per your comment. Can you let me know why we should remove the first when - I only want to bother duplicates if the candidate passes the availability filter. Also, I have to use member since we have to compare string values - memq tests whether the actual objects are the same. Apart from the above comments, we should consider whether we want this to be an option or not: I would vote for yes. Thanks. |
Agreed for the option. |
…so adds the customizable option
So I have added a customizable bool option for this. Just to let you know that given the following:
This means that the brief/doxygen is arbitrarily the first one it comes across - the message in the minibuffer. Cheers. |
I have to admit that I'm a bit lost with all the Thanks for the PR! |
…ailability of the candidate is in the user's allowed availability filtered list - only add the element if it is unique. The current key used is a tuple of typed-text, annotation and return type.
====
@Sarcasm , I just wanted to get the ball rolling on duplicate completions. All the completions are strictly unique, but - at least for company-irony - the things that are displayed are the typed text, signature and return type. I use irony-mode at work on a large code base and see a lot of third party library duplicates.
Can you have a look at this pull-request so we can discuss how to remove duplicates. One issue I can think of even now is that we may be removing a duplicate that has useful brief documentation.
On a side/slightly related note: the new version of clan tools (cfe) has a recent fix to the protected member issue (if you remember it); this means we can soon remove the availability filtering - though we may want to cater for people using older version of clang. Furthermore, I may be the only one actually using/modifying `irony-completion-availability-filter' from its default value anyway!
Cheers.