Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Keep collapsed items in sync with search results #1000
Description of the Change
When searching across projects, if some items are collapsed in the search results view and new results are added, the collapsed items do not stay in sync with the results. Instead, collapsed items are "sliding" up and down as results are added/removed. This is due to the collapsed state being represented by an array of booleans that does not get updated when search results change. This commit introduces a fix to that issue by making sure that we update the aforementioned array as needed.
An alternative to this design would have been to store the collapsed state directly on the element representing a "matched file" but it would entail a pretty big refactoring of the code which I don't feel I am familiar enough to start modifying in such length.
Whenever search results are updated, if some results were collapsed, these results will stay collapsed as expected. Previously, this "collapsed state" would be transferred to the search result above/below a collapsed item depending of the index where a search result would get inserted/removed.
This might introduce some performance issues on very big sets of results as the array representing the collapsed items gets updated every time search results get updated.