Wednesday, October 11, 2017

Re: scrolloff side effects are bothersome

Stucki wrote:

> On 10/11/17 um 04:58 Ben Fritz wrote:
> > On Tuesday, October 10, 2017 at 1:57:38 PM UTC-5, Eli the Bearded wrote:
> >> I've long used scrolloff intermittantly, but recently I tried adding it
> >> to my vimrc. I'm finding myself unhappy now.
> ...
> >> What I would *expect* and what I would like is if H and L movements were
> >> not affected by scrolloff, and yanks, deletes, etc worked again to top
> >> and bottom of the screen. And if actually moving to top or bottom with a
> >> bare H or L, I'd expect the cursor to move, *and* the screen to scroll
> >> according to scrolloff.
> >>
> >> Doesn't this bother other people? Or does no one use scrolloff?
> >>
> >> Elijah
> >
> > It doesn't bother me, but I never use H/M/L commands with an operation. I only ever use them for imprecise "big jump" navigation. If I did, it would probably bother me.
> >
>
> Well, that really is important to know! Else I'd unknowingly ignore
> lines if I'd 'yL'. And I'd expect the same behavior as Elija. The
> 'first', 'middle', and 'last' line should keep their meaning according
> to the real screen, and only 'moving the pointer' should scroll AFTER
> the move into the screen.

Hmm, it's possible to make these commands not use 'scrolloff' when an
operator is pending. It won't be consistent with other operations
though. But it does make sense when 'scrolloff' is a large number,
since it's then hard to estimate what text will be covered. While the
first visible line or last visible line are easy to spot.

With this change no tests fails, so perhaps no user will have a problem
with it? Still I worry about the inconsistency. Als, "yH" will scroll
the text.

This change is all that's needed:

--- old/normal.c 2017-09-23 15:08:13.200518795 +0200
+++ normal.c 2017-10-11 22:16:58.927151726 +0200
@@ -5954,7 +5954,9 @@
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
}

- cursor_correct(); /* correct for 'so' */
+ /* Correct for 'so', except when an operator is pending. */
+ if (cap->oap->op_type == OP_NOP)
+ cursor_correct();
beginline(BL_SOL | BL_FIX);
}



--
### Hiroshima 45, Chernobyl 86, Windows 95 ###

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: