Friday, March 6, 2015

Re: Bug? (was vimscripting problem w/tabs and expanding width w/numbering option)

Hi Linda!

On Fr, 06 Mär 2015, Linda W wrote:

> Christian Brabandt wrote:
> >I haven't followed closely. Can you please provide a clear example that
> >exhibits the wrong behaviour when starting from gvim -u myfile -N
> >and also explain what you expect and what you see instead?
> >Best,
> >Christian
> In "myvimrc" add:
>
> func! SetNumberAndWidth()
> set number
> if (! exists("g:added_numwth")) | let g:added_numwth=0 | endif
> if (g:added_numwth < &numberwidth)
> let g:added_numwth = &numberwidth
> let &columns = 2 + g:added_numwth + &columns
> endif
> endf
> if !exists("g:autocommands_loaded")
> let g:autocommands_loaded =1
> au BufReadPost * let ln = line("'\"") | if
> search("vim=:SetNumberAndWidth",'n') | call SetNumberAndWidth() |
> endif
> endif
> -----------------------
> Then create 2 files (this is in bash script):
>
> for f in xxx.{cc,h};do
> printf "%s\n\n\n\n\n\n\n\n\n\n" "// gvim=:SetNumberAndWidth"
> >"$f" done
>
>
> Then run:
>
> gvim -u myvimrc -p xxx.cc xxx.h
> (the -N doesn't seem necessary.).
>
> Then enter:
> :echo winwidth(0)
>
> Notice it is '86' (well that's what I see).
> click on the 2nd tab and type it again.
>
> Notice the 2nd tab has vertical bars on the right
> and is only 80 columns wide.
>
> quit vim.
> Start again, this time, move the right border of the editor 1
> column right or left, then echo the sizes again for both tabs
> -- you will note they are the **same width** in the 'manual
> resize case'.
>
> I.e. if one sets the columns via the GUI by physically
> dragging the side the current tab and background tabs are
> set to the same width.
>
> If, however, you set the columns in your .gvimrc -- it only resets
> the width of the 1st tab. In the manual resize case, columns stay
> in sync, but if you try the same thing via a script, it doesn't work.
>
> That's why I am thinking it is a bug -- because if you
> change the physical width of the graphical window -- it should
> resize the 'winwidth' of all the tabs, just the same as it
> does when you resize it manually.

That looks strange indeed. I would suggest to postpone the resizing
until Vim has started up completely. Since there are some checks in the
Code that postpone processing, if Vim is starting.

Also you might want to consider to use the BufWinEnter or WinEnter
autocommand, since I think checking the numberwidth option should be
done, when entering the buffer in a window (by which that setting might
be different than when first loading that buffer).

Best,
Christian
--
Vergiß nicht - man benötigt nur wenig, um ein glückliches Leben zu
führen.
-- Mark Aurel (römischer Kaiser, 121-180)

--
--
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: