[vim/vim] Returning to help buffer resets scrolloff (Issue #15024)

12 views
Skip to first unread message

Stanislav Asunkin

unread,
Jun 16, 2024, 12:07:05 PM (10 days ago) Jun 16
to vim/vim, Subscribed

Steps to reproduce

Maybe it's not a bug, but it bothers me a long time.

  1. Run vim
  2. Set global scrolloff to 5, local to 0: :set scrolloff=5 | setl scrolloff=0
  3. Open any help: :h
  4. Check current scrolloff in help: :setg so|se so|setl so (global 5, local -1 as expected)
  5. Change buffer in a window with help: :b#, first buffer is selected
  6. Check current scrolloff: :setg so|se so|setl so (global 5, local 0 as was set earlier for this buffer)
  7. Change buffer back to help: :b#
  8. Check current scrolloff: :setg so|se so|setl so (global 5, local 0, not expected)
    Context:
  • I have global scrolloff set to some value
  • I change it to 0 for terminal buffers
  • I switch between terminal buffer and other buffers, it works as expected (scrolloff=0 only for terminal), but when other buffer is help it somehow resets to 0.

Expected behaviour

When changing buffer to alternative help buffer it should have scrolloff set to global value.

Version of Vim

9.1.377

Environment

OS: Debian 11
Terminal: Windows Terminal and tmux
$TERM: tmux-256color

Logs and stack traces

No response


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

Christian Brabandt

unread,
Jun 16, 2024, 12:57:11 PM (10 days ago) Jun 16
to vim/vim, Subscribed

This is a bit complicated. First of all, 'scrolloff' is a window-local option, not buffer-local. And when you do :h you are opening a new window with the default values.

So let's go through your steps:

Set global scrolloff to 5, local to 0: :set scrolloff=5 | setl scrolloff=0

Set's the global/local window option scrolloff

Open any help: :h
Check current scrolloff in help: :setg so|se so|setl so (global 5, local -1 as expected)

opens a new window which is using the global scrolloff value as expected

Change buffer in a window with help: :b#, first buffer is selected
Check current scrolloff: :setg so|se so|setl so (global 5, local 0 as was set earlier for this buffer)

The current buffer is unloaded and a new buffer is loaded in this window.
Vim checks if this buffer is displayed in a different window. If it is, copies the window local options from that window to
the current window. So 'scrolloff' is now 0.

Change buffer back to help: :b#
Check current scrolloff: :setg so|se so|setl so (global 5, local 0, not expected)

Vim continues to use the local window-option value 0 in this case.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/15024/2171769949@github.com>

Stanislav Asunkin

unread,
Jun 16, 2024, 1:39:14 PM (10 days ago) Jun 16
to vim/vim, Subscribed

When reading :h local-options (the part where examples with list option) I thought that even window-local options are also somehow copied to a buffer. For example when I create a new buffer in the window with local 'scrolloff=0' (:e 1234) value is not stayed as is, it resets to global 'scrolloff=5'. After that I can switch between two buffers and scrolloff is changed accordingly. So what's the difference with help buffer than? E.g.

  1. :e 1 (first buffer)
  2. :setg so=5|setl so=0
  3. :e 2 (second buffer, it's scrolloff is 5)
  4. :b#

Even if I unload buffer 2, when I load it back it'll get scrolloff 5:

  1. :b2 Input something in a buffer, save (:w), then :bunload.
  2. :b# (scrolloff 0)
  3. :b# (loads buffer 2 back, it has global scrolloff 5)

So I kind of don't understand what's so special with help buffer, that it doesn't behave like this.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/15024/2171783379@github.com>

Reply all
Reply to author
Forward
0 new messages