-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Code hints are sometimes displayed when they shouldn't be #2258
Comments
Yes, I've definitely run into this before--the way our API works right now is confusing. |
@joelrbrandt I would say we should have solution 4 to rename "shouldShowHintsOnKey" which is misunderstood by most extension developers. You're not alone to bring this up. See Andre's questions in CSS hinting. Note that your solution 4 does not fix this issue. It just tries to solve the confusion of this api. "shouldShowHintsOnKey" is intended to let code hints providers to auto trigger hint list on a specific key rather than having users to explicitly press Ctrl-Space to show code hints. So it's not the real culprit of this specific issue except its name is a misnomer and misunderstood by most. It is not intended to claim as exclusive hint provider after a specific key is hit by the user. Assuming we don't have this api and users always have to press Ctrl-Space to show hints, the issue you described here still shows up because your getQueryInfo is providing a queryStr (instead of a null queryStr) to CodeHintManger to show the relevant hint list. You may think it is the responsibility of CodeHintManager to provide the context of the current selection or cursor position. Actually, it is not. For tag hints and attribute hints we have HTMLUtils.js to provide the html context with getTagInfo api, but we don't have a similar one for css context. So the correct solution for this issue is to create an general api in CSSUtils.js that provides the CSS context info to EWF and CSS Hints provider. Once we have that API, then it is the responsibility of individual hint provider to return the correct queryStr based on the context. And here you should not make the decision of showing your code hints based on the last character user just typed. In your case, you would like to show hints only if you have Current implementation of EWF and Andre's CSS hinting both provide a non-null query string when a specific css property name is found. This is not the right solution and if you put both extensions in Brackets, the second one won't work anymore depending on which one gets registered first. So both extensions need to be updated to use the new general api that I'm proposing so that only one provider can claim to show code hints at a time, but not both at the same time. |
@RaymondLim Thanks for the thoughtful reply. @iwehrman and I submitted pull #2261 because we found a related and slightly more nuanced bug. It's a bit difficult to explain, so if the next few paragraphs below doesn't make sense, let me know. :-) We're working on building code autocomplete for JavaScript. The bug we're experiencing is that the code hint dialog does not close if the user decides not to autocomplete, and instead types the whole (possibly new) identifier and then hits space. Consider a JavaScript file that already contains the identifier Right now, before closing, the CodeHintManager calls In short, it seems to me that code hint providers need a way of knowing what recent action a user took in order to decide if they should return query results. Right now, the only place that the user action is passed to the provider is in
Thoughts? On a related note, I'm aware that there's a bug in the EWF extension. If this request is merged, we'll need a more intelligent |
@joelrbrandt Thanks for your further explanations! Yes, there is an unintented side effect of And I'll be logging separate issues in EWF for those I mentioned in the previous comments. |
Marking sprint 18 since we're working on this now anyway--maybe this is how we can track the work item of revamping the code hint API? |
Reviewed, in sprint already.. |
Confirming fixed after pull #2387. Closing. EWF still needs to be updated to fix the particular issue, but we now have the API we need in order to be able to fix it. I've filed a bug (assigned to me) for this: adobe/brackets-edge-web-fonts#56 |
Big thanks to @iwehrman for helping understand and suggest solutions for this bug.
Code hints are sometimes displayed when they shouldn't be. For example, with the EWF extension installed, FontHints are sometimes displayed in CSS files when the extension doesn't intend for this to happen.
Steps to reproduce:
Expected:
List doesn't show up
Actual:
List shows up.
Cause:
The problem seems to be related to the decoupling of all steps in the code hint process (shouldShowHintsOnKey, getQueryInfo, and search functions that providers implement)
In this case, the AttrHints provider (which is supposed to provide attribute hints for HTML) says it will provide hints on a "space" key. Then, CodeHintManager asks every single provider for query info. AttrHints returns nothing (which is correct) but FontHint can offer hints (and doesn't know space was typed) so it does. This causes the hint list to appear.
Possible solutions:
Other suggestions:
The text was updated successfully, but these errors were encountered: