Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Code hints are sometimes displayed when they shouldn't be #2258

@joelrbrandt

Description

@joelrbrandt

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:

  1. Install EWF extension and open a CSS file with a font-family rule.
  2. Put cursor at the end of a font name, but before a comma.
  3. Press space.

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:

  1. CodeHintManager could pass context (e.g. editor, mode) to providers when calling "shouldShowHintsOnKey" so they can make a better decision.
  2. CodeHintManager could only call getQueryInfo on providers that said yes to "shouldShowHintsOnKey"
  3. Providers could be registered on a per-mode basis and then shouldShowHintsOnKey would only get called for providers that are registered for the current mode (related to Jason sanjose/js test driver #1 / may lessen the need for Jason sanjose/js test driver #1)
  4. possible that "shouldShowHintsOnKey" should be renamed to something like "wantToProvideHintsOnKey" to make its intent more clear to implementers of providers.

Other suggestions:

  1. Right now, multiple hint providers can say they want to show hints, but only one (first one registered to return query info) ends up providing hints. This means that it's impossible to build extension that override our built in providers. Could fix by making it the case that there's only one (or zero) provider per mode. But then we'd need to merge all of the HTML providers into one.
  2. Division of labor between "getQueryInfo" and "search" seems strange because it seems to be the case that getQueryInfo and search are always called as a pair (once a provider is chosen). Instead, it might make sense to have one function that gets called the first time (i.e. when selecting a provider and displaying the list for the first time) and one function that gets called each time the user types (i.e. updates the query/filters the list).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions