Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swiper not scroll on exit #2159

Closed
Ergus opened this issue Jul 22, 2019 · 6 comments
Closed

Swiper not scroll on exit #2159

Ergus opened this issue Jul 22, 2019 · 6 comments

Comments

@Ergus
Copy link
Contributor

Ergus commented Jul 22, 2019

Hi:
Sorry for the bother with such a small detail.

I am just wondering if it is possible somehow to avoid the small scroll that takes places when exiting swiper (ivy-alt-done).

Sometimes when selecting a candidate swiper makes a recenter or scrolls when closing the minibuffer (if the candidate was out of the screen before starting swiper or in the portion of the screen that swiper occupies when opened). This makes that the selected candidate/line moves to the top or down in the screen when swiper closes which is somehow annoying.

I think it is a more comfortable (better user experience) if when selecting a candidate it's line always keep the relative position to the top of the screen (as it happens with the initial visible candidates on the top of the screen). Because the user could keep his eyes in the selected line and does not need to search again with the eyes for the cursor. It will feel like if the minibuffer has closed and will be less distracting.

Does it makes sense? Maybe there is already a method to configure this that is not documented?

Thanks in advance,
Ergus

@abo-abo
Copy link
Owner

abo-abo commented Jul 23, 2019

Please add a reproduction scenario.

@Ergus
Copy link
Contributor Author

Ergus commented Jul 23, 2019

Hi abo-abo:

Thanks for taking care of this.

Suppose that there is a buffer with actual visible lines from 100 -> 150. And the candidates are in lines:
80, 120. 130, 145 and 200. The cursor is on line 101 and ivy-height is 10.

When I start swiper, the minibuffer will hide the lines 142 -> 150 that were visible before, so the candidates in line 145 will be hidden while swiper is on.

there are 3 scenarios on exit swiper as now:

120, 130 : it is fine now, they stay where they are before and after.
145: will need a scroll to be visible again, but on enter it returns to it's initial position on the screen (which I don't actually like, but I can live with it if it is consistent in all cases).
200: was not visible on the beginning, so it needed a scroll to become visible, so probably it is centred or anywhere, but after enter it will go to the button of the screen (or sometimes top). There are times where the candidate in the screen appears in the last visible line over swiper, but on enter it goes to the top.

Probably it is easier to set somehow the second and third case to avoid any scroll on ivy-exit; so they behave like case 1? The interesting thing is that in some cases 3) it already does that, but this happens randomly.

Thanks in advance,
Ergus

@abo-abo
Copy link
Owner

abo-abo commented Jul 24, 2019

Please add a sample file.

@Ergus
Copy link
Contributor Author

Ergus commented Jul 24, 2019

Hi Abo-Abo:

It happens with any file. I just made M-150 M-x lorem-ipsum-insert-list. But to give you a file it will change depending of your screen size, font-size and how many visible lines do you have at the time and what's the ivy-height you have.

For example for case 2) you can try with the *Packages* buffer and search: ack (in my case because it is in line 55 and my last line visible is 56) but there are possible candidates in many other lines far bellow (because matching in background).

For case 3) (and the worst case) If you search: swiper (where candidates are very sparse) and you go to one of the the last candidate and change directio (C-p) to one of the previous candidates (not the initial); you will see that the candidate will appear in the top of the screen (when swiper is on), but when you C-m it will scroll to put the selected one in the bottom of the screen. (same happen in the opoosite direction)

@abo-abo
Copy link
Owner

abo-abo commented Jul 25, 2019

OK, thanks. I can reproduce now. Here's what I would have preferred in an issue report, for future reference.

  1. The issue happens only in emacs -nw. It does not happen in regular Emacs. I use regular Emacs exclusively, so I never happen upon these issues myself. The bug that you reported is a major UX flaw, so it's good that you reported it.
  2. Add a sample-file, say that frame-height should be 52, and point should be on line 100.
  3. Clarify which command you're using: swiper or swiper-isearch. From context, it has to be swiper, but the title is "isearch not scroll on exit".

Your issue should be solved with this:

(defun swiper--recenter-p ()
  t)

This uncovered one more issue that swiper-isearch doesn't yet have the scroll-fixing behavior that swiper has.

@Ergus Ergus changed the title isearch not scroll on exit Swiper not scroll on exit Jul 25, 2019
@Ergus
Copy link
Contributor Author

Ergus commented Jul 25, 2019

Hi Abo_Abo
I'll try it now.
Sorry for the bad report, I'll try to improve that in the future. The title was really a mistake in a hurry and then I forgot to change it.
I didn't know that the issue was terminal specific because I don't use gui emacs (I compile it even without gui support).
Very thanks;
I have not tried it yet, but I'll close the issue as you already know about it.
Best

@Ergus Ergus closed this as completed Jul 25, 2019
astoff pushed a commit to astoff/swiper that referenced this issue Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants