zed icon indicating copy to clipboard operation
zed copied to clipboard

Scroll project search results to the top

Open alygin opened this issue 5 months ago • 4 comments

Scroll project search results to the top after every new search.

Related issues:

  • Fixes #8237

Release Notes:

  • Fixed autoscrolling of the project search results.

alygin avatar Feb 24 '24 08:02 alygin

would appreciate the attempt to make a test

Sure, I'll give it a try. In such a test, I expect difficulties with reproducing the bug first, because it depends on the previous user behaviour. At least I had to do some preliminary steps manually for the bug to manifest itself. But I think it should be doable.

alygin avatar Feb 25 '24 05:02 alygin

For me that was reatively simple: fire a project search, scroll down to the lowest point (can be emulated with SelectPrev action, presumably?) and fire another search in the same window (tests do that already?).

But I agree it might be hard to write such test, so let's merge this PR after you fail to do so and come back with the details of the failure 🙂

SomeoneToIgnore avatar Feb 25 '24 07:02 SomeoneToIgnore

For me that was reatively simple: fire a project search, scroll down to the lowest point (can be emulated with SelectPrev action, presumably?) and fire another search in the same window (tests do that already?).

I don't know why, but sometimes it's not enough to just scroll down, it reproduces very inconsistently. Sometimes it's not happening at all for a long period, and I have to restart Zed to "break" it again.

But I agree it might be hard to write such test, so let's merge this PR after you fail to do so and come back with the details of the failure 🙂

Sounds like a good plan :) I'll be back.

alygin avatar Feb 25 '24 10:02 alygin

@SomeoneToIgnore , I have this test. It passes. But it also passes if I remove that editor.scroll(...) in the main code. The problem is that I can hardly reproduce the problem on my computer (it's 1 in several dozens attempts), and I don't understand if the test is incorrect, or the erroneous behaviour depends on something else that the test doesn't do.

I also don't understand what window size I have in the test, and if it can affect the test.

alygin avatar Feb 29 '24 21:02 alygin

Thank you for coming up with the test nonetheless! It does look good logically (as the change is too) and seems to work for me on the branch, at least.

Now, retesting the latest Preview, the bug also appears quite randomly — so it might be more than the screen size. I would blame the multibuffer events, but do not have a good proof. If you want to look at the screen size more, here's the place: https://github.com/zed-industries/zed/blob/48aba8eb4c147d8644a1fe3c13c39adaffc32773/crates/gpui/src/platform/test/display.rs#L19

But we have everything what we need here thanks to you, so let's merge.

SomeoneToIgnore avatar Mar 01 '24 09:03 SomeoneToIgnore