Dasn wrote:
> Commands like 'wincmd K', 'wincmd J', 'wincmd L' and 'wincmd H' can
> be used to change the window layout, but sometimes they have strange
> effects on the view of the other windows even if the whole windows
> layout are not get changed.
>
> To make this problem reproduce-able, I wrote a test script for it. But
> first, let me describe the script a little:
>
> The script simply creates 2 windows in Vim. One is called 'Main'(on
> top) and the other is called 'Log'(on bottom). First, I append 100 lines
> to 'Main', then goto 50th line and make this line displayed on the
> bottom of the window by using 'zb'. Next, I switch to the 'Log' window,
> move the window to bottom (although it's been already on the bottom) by
> 'wincmd J' and write a line into it. I noticed the problem: After
> 'wincmd J', the view of 'Main' window got changed (that is the 50th line
> was moved to the top of 'Main'). I suppose it's a bug.
>
> The following script was tested with: VIM - Vi IMproved 7.2-1-148, by
> using command:
> $ vim -u NONE -S test.vim
>
> fun! BuildLines(prefix)
> let a = []
> for i in range(1, 100)
> call add(a, a:prefix . ": This is line " . i)
> endfor
> return a
> endfun
>
> fun! Test()
> set equalalways
> set scrolloff=0
>
> " Create a Log window
> new Log
> set bt=nofile
> only!
>
> " Create Main Window, then write some lines into it and
> " display the 50th line in the bottom of the window
> top new Main
> set bt=nofile
>
> let a=BuildLines("Main")
> call append(0, a)
> normal 50G
> normal zb
> "normal zz
> " let win_save = winsaveview()
> " call winrestview(win_save)
>
> " Add some lines to another window (that is, the Log window)
> let win_no = bufwinnr("Log")
> if win_no != -1
> " Found the Log window
> exe win_no . "wincmd w"
> wincmd J " NOTE: This command will triger the problem
> call append('$', "Log: Where is the 50th line? ")
> exe "normal G"
> endif
> endfun
>
> call Test()
> redraw!
In your Test() function there is no redraw. So even though you use "zb"
it doesn't take effect. If you then later change something that
triggers a redraw, the relative cursor position hasn't been set yet.
Try the same operation by hand, I didn't see this problem then.
--
Eight Megabytes And Continually Swapping.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---