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

Fix code hint provider selection #3208

Merged
merged 2 commits into from
Mar 22, 2013
Merged

Conversation

iwehrman
Copy link
Contributor

Commit 5878608 replaced a number of instances of $.each with Array.forEach. But those functions are not interchangeable: only the former supports early break-out. Both the CodeHintManager and the CodeHintList relied on this feature. In particular, that commit broke:

  1. CodeHintManager provider selection, by always choosing the last provider instead of stopping at the first, highest-priority provider

  2. the CodeHintList, by adding all the available hints instead of of just the first maxResults hints.

The first issue also breaks Edge Web Fonts in particular.

This pull reverts just those two changes. I haven't checked all the other replacements from that commit to see if there are other related problems. (Want to have a look, @TomMalbran?)

Ian Wehrman added 2 commits March 21, 2013 15:51
…e latter does not support breaking out of the loop early, and hence breaks provider selection. In particular, Edge Web Fonts was broken by this.
…commit broke limiting the CodeHintList to displaying at most maxResults hints.
@TomMalbran
Copy link
Contributor

Oh, I didn't checked the break in the $.each, sorry. You could still use Array.some instead of Array.forEach and break the loop returning true instead of false as with $.each.

There is another $.each that was broken in PreferenceManager, but that one doesn't really needs the break and is using CollectionUtils.forEach. I could fix it in #3117 using CollectionUtils.some.

@jbalsas
Copy link
Contributor

jbalsas commented Mar 22, 2013

@TomMalbran Don't worry, I also missed this on review :(

An important issue here, then, is that we don't have this covered with any test. It would be nice to add one now, so this doesn't slip again.

@ghost ghost assigned redmunds Mar 22, 2013
@redmunds
Copy link
Contributor

I verified this fixed Edge Web Fonts. Merging.

redmunds added a commit that referenced this pull request Mar 22, 2013
@redmunds redmunds merged commit e110b2c into master Mar 22, 2013
@redmunds redmunds deleted the iwehrman/fix-chm-provider-selection branch March 22, 2013 18:04
@peterflynn
Copy link
Member

@iwehrman I think it's worth filing a spinoff bug to wrap up the loose ends mentioned above: switching this to Array.some() (achieving the goals of the cleanup #3087); and adding a unit test (especially since it breaks a prominent extension and isn't something we'd be able to spot with pure Brackets scenario testing).

@iwehrman
Copy link
Contributor Author

See #3223 regarding unit tests for the CodeHintManager. I'm not sure replacing $.each() with Array.some() is worth spending any time on. What's so bad about $.each()?

@peterflynn
Copy link
Member

We've standardized on using Array.forEach()/.some() instead, and it's what all other code in the product uses (in general we prefer to use modern browser APIs where available). $.each() uses args in the opposite order those other APIs, making it bug-prone to mix them. $.each() is also buggy for iterating object keys, so I'd worry a bit that continuing to use it for (some) arrays would encourage people to erroneously use it for objects too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants