
Constantly bedeviled・Profile picture by @bigbigtruck
- Tweets21.8K
- Following1.1K
- Followers1.1K
- Likes51.3K

ALT *deep breath* The difference between the globalAutocompleteList and the originList & styleList is that the former is a list of every origin & style that appears in the document, *including duplicates and inferred entries*, in the order in which they appear. We build this duplicate-ridden list because counting duplicates is how we determine the sort order or the items in the autocomplete menu, such that more frequently appearing items are closer to the top of the menu. It's part of the global store because Codemirror needs to access it directly, outside of the React component tree. To set it, we use a useEffect to update it 500ms after the last change to the Editor's value (i.e., the user has paused typing and the editor is idle). (Brief aside: Why are we using setTimeout to do this instead of requestIdleCallback, which would be the more correct thing to do? Because of this: https://bugs.webkit.org/show_bug.cgi?id=285049 )








