Skip to content

"No results found" shows up on every empty line and on every token including keywords

Created by: macraig

@mrnugget's findings:

  1. We only show the spinner after 600ms. That can lead to some rather tricky behaviour: if the first request is slow and doesn't find results, you'll see a spinner and then the hover disappears. If you then hover over the token again, the response from the previous request is cached, which means it'll not cross the 600ms, which means you won't see the spinner or a hover tooltip again. https://github.com/sourcegraph/sourcegraph/blob/93eebb8b847a92675b181fd34cef8501f0b2ea06/client/codeintellify/src/hoverifier.ts#L345-L346
  2. Our code contains some (really old) logic to display "nothing found" when there is no result: https://github.com/sourcegraph/sourcegraph/blob/93eebb8b847a92675b181fd34cef8501f0b2ea06/client%2Fshared%2Fsrc%2Fhover%2FHoverOverlayContents%2FHoverOverlayContents.tsx#L54-L59
  3. That code is never triggered, because the hover overlay hides the hover if there is no cursor position provided: https://github.com/sourcegraph/sourcegraph/blob/93eebb8b847a92675b181fd34cef8501f0b2ea06/client%2Fshared%2Fsrc%2Fhover%2FHoverOverlay.tsx#L63-L74
  4. On the other end of things we have some code that also decides when to render a hover tooltip and when not. And if it doesn't have content for the hover (but maybe actions?) then it doesn't return anything, which means it doesn't return a position, which leads to code in (2) not being shown, due to (3). https://github.com/sourcegraph/sourcegraph/blob/93eebb8b847a92675b181fd34cef8501f0b2ea06/client%2Fcodeintellify%2Fsrc%2Fhoverifier.ts#L308-L319
  5. I changed the logic in (4) to always return the position, even if there is no hover content and now we can see the "No results found" content:

https://user-images.githubusercontent.com/1185253/157459009-0211fb15-1337-4bd2-bd2e-4ed6100edda6.mp4

  1. The problem: we don't distinguish between "no result found and we'll never find a result for a token like this (whitespace, parentheses, ...)" and "no result found, but maybe with precise", which leads to the "no results found" showing up on every empty line and on every token, including keywords.