[vim/vim] Fix 'scrollbind' not working when scrolling inactive window (PR #13189)

17 views
Skip to first unread message

zeertzjq

unread,
Sep 25, 2023, 11:19:40 PM9/25/23
to vim/vim, Subscribed

Problem: 'scrollbind' doesn't work when scrolling inactive window.
Solution: Call do_check_scrollbind() after scrolling inactive window.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/13189

Commit Summary

  • 671412f Fix 'scrollbind' not working when scrolling inactive window

File Changes

(3 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13189@github.com>

codecov[bot]

unread,
Sep 25, 2023, 11:30:48 PM9/25/23
to vim/vim, Subscribed

Codecov Report

Merging #13189 (671412f) into master (f109bf9) will increase coverage by 4.45%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #13189      +/-   ##
==========================================
+ Coverage   78.30%   82.75%   +4.45%     
==========================================
  Files         150      150              
  Lines      152791   182132   +29341     
  Branches    39409    40932    +1523     
==========================================
+ Hits       119644   150726   +31082     
+ Misses      20901    18470    -2431     
- Partials    12246    12936     +690     
Flag Coverage Δ
huge-clang-Array 82.75% <100.00%> (?)
linux 82.75% <100.00%> (?)
mingw-x64-HUGE ?
mingw-x86-HUGE ?
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/mouse.c 80.32% <100.00%> (+22.48%) ⬆️
src/move.c 91.41% <ø> (+8.81%) ⬆️

... and 157 files with indirect coverage changes


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13189/c1734770754@github.com>

zeertzjq

unread,
Sep 25, 2023, 11:40:35 PM9/25/23
to vim/vim, Push

@zeertzjq pushed 1 commit.

  • f7cf5b7 Fix 'scrollbind' not working when scrolling inactive window


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13189/push/15179411694@github.com>

Gary Johnson

unread,
Sep 26, 2023, 1:37:41 AM9/26/23
to reply+ACY5DGCCGU3BC4CNTL...@reply.github.com, vim...@googlegroups.com
On 2023-09-25, zeertzjq wrote:
> Problem: 'scrollbind' doesn't work when scrolling inactive window.
> Solution: Call do_check_scrollbind() after scrolling inactive window.

I thought it was supposed to work that way. It _is_ handy to be
able to scroll the two windows independently by just clicking and
moving the mouse.

Regards,
Gary

vim-dev ML

unread,
Sep 26, 2023, 1:38:02 AM9/26/23
to vim/vim, vim-dev ML, Your activity

On 2023-09-25, zeertzjq wrote:
> Problem: 'scrollbind' doesn't work when scrolling inactive window.
> Solution: Call do_check_scrollbind() after scrolling inactive window.

I thought it was supposed to work that way. It _is_ handy to be
able to scroll the two windows independently by just clicking and
moving the mouse.

Regards,
Gary


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13189/c1734861048@github.com>

errael

unread,
Sep 26, 2023, 1:44:22 AM9/26/23
to vim/vim, vim-dev ML, Comment

I thought it was supposed to work that way. It is handy to be able to scroll the two windows independently by just clicking and moving the mouse.

I actually was using that feature today. I'd never know explicitly about it, and was surprised, but it was very handy.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13189/c1734866044@github.com>

zeertzjq

unread,
Sep 26, 2023, 1:49:00 AM9/26/23
to vim/vim, vim-dev ML, Comment

Oh right, I just noticed this:

							*scrollbind-quickadj*
The 'scrollbind' flag is meaningful when using keyboard commands to vertically
scroll a window, and also meaningful when using the vertical scrollbar of the
window which has the cursor focus.  However, when using the vertical scrollbar
of a window which doesn't have the cursor focus, 'scrollbind' is ignored.
This allows quick adjustment of the relative offset of 'scrollbind' windows.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13189/c1734869624@github.com>

zeertzjq

unread,
Sep 26, 2023, 1:49:16 AM9/26/23
to vim/vim, vim-dev ML, Comment

Closed #13189.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13189/issue_event/10470253758@github.com>

Gary Johnson

unread,
Sep 26, 2023, 1:55:08 AM9/26/23
to reply+ACY5DGCEVIDOBVF45Y...@reply.github.com, vim...@googlegroups.com
On 2023-09-25, errael wrote:
> I thought it was supposed to work that way. It is handy to be able to
> scroll the two windows independently by just clicking and moving the mouse.
>
> I actually was using that feature today. I'd never know explicitly about it,
> and was surprised, but it was very handy.

I did a little looking. The current behavior is described in ":help
scroll-binding".

When using the scrollbars, the binding only happens when
scrolling the window with focus (where the cursor is). You can
use this to avoid scroll-binding for a moment without resetting
options.

Therefore, this proposed "fix" should not be accepted.

Regards,
Gary

vim-dev ML

unread,
Sep 26, 2023, 1:55:25 AM9/26/23
to vim/vim, vim-dev ML, Your activity


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13189/c1734874855@github.com>

Shane-XB-Qian

unread,
Sep 26, 2023, 2:06:44 AM9/26/23
to vim/vim, vim-dev ML, Comment

looks generally it worked in vimdiff mode which natively enabled this option for it.
// BTW: somehow sometime i faced that maybe one window off (not scrolling with another),
// i cannot and didnot dig to repro solidly, but if someone faced same situation, may look into further.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13189/c1734884861@github.com>

zeertzjq

unread,
Sep 27, 2023, 7:56:12 PM9/27/23
to vim/vim, vim-dev ML, Comment

Actually this seems achievable using WinScrolled autocommand and :windo. An autocommand for diff mode:

func ScrollBind()
  let oldwin = win_getid()
  for [win, delta] in items(v:event)
    let id = str2nr(win)
    if id == 0
      continue
    endif
    if delta.topline == 0 && delta.topfill == 0
      continue
    endif
    let nr = win_id2win(id)
    if getwinvar(nr, '&scrollbind') && getwinvar(nr, '&diff')
      exe nr .. 'windo :'
      break
    endif
  endfor
  call win_gotoid(oldwin)
endfunc

autocmd WinScrolled * call ScrollBind()

It's mainly useful in diff mode, where diff_set_topline() is used for 'scrollbind'.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13189/c1738255031@github.com>

Shane-XB-Qian

unread,
Sep 28, 2023, 12:14:02 AM9/28/23
to vim/vim, vim-dev ML, Comment

i was saying this 'scrollbind' was mainly used and default enabled in vimdiff,
but sometime it didnot sync scrolling in between (those windows),
i cannot solidly repro what happened, so deleted comment.

but the problem seems was the status of fold, if it was open/close, and there one there or not, and related lines range....
so it should be not just about delta.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13189/c1738406067@github.com>

Tony Mechelynck

unread,
Sep 28, 2023, 3:18:22 PM9/28/23
to vim/vim, vim-dev ML, Comment

IIUC, this is intentional (and documented):

			*'scrollbind'* *'scb'* *'noscrollbind'* *'noscb'*
'scrollbind' 'scb'	boolean  (default off)
			local to window
	See also |scroll-binding|.  When this option is set, scrolling the
	current window also scrolls other scrollbind windows (windows that
	also have this option set).  This option is useful for viewing the
	differences between two versions of a file, see 'diff'.
  • Scrolling the active window scrolls all scrollbound windows to keep them synchronized.
  • Scrolling an inactive window scrolls only that window, to resynchronize it in case it had become unsynchronized for some reason.

Best regards,
Tony.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/13189/c1739876132@github.com>

Reply all
Reply to author
Forward
0 new messages