Loading ...
Sorry, an error occurred while loading the content.

Re: Tabline function sometimes recalled when highlighting set/changed.

Expand Messages
  • Eric Arnold
    ... Two reasons: 1) it doesn t happen in most cases, and 2) because the conditions for the redrawing of the tabline are implicit rather than explicit. It
    Message 1 of 9 , May 2, 2006
    • 0 Attachment
      On 5/2/06, Bram Moolenaar <Bram@...> wrote:
      >
      > Benji Fisher wrote:
      >
      > > On Tue, May 02, 2006 at 02:17:58PM +0200, Bram Moolenaar wrote:
      > > >
      > > > Eric Arnold wrote:
      > > >
      > > > > I haven't been idle on this. I was unable to get my test case working
      > > > > for a simple but un-obvious reason. It requires that at least one
      > > > > other window be open.
      > > > >
      > > > > Run the following, and open two windows. Edit a file in one. Open a
      > > > > new line, which I assume triggers the tabline to trigger as the buffer
      > > > > becomes modified. Then as you move the cursor around, you should see
      > > > > the "Tst#" prompt incrementing with each keystroke.
      > >
      > > > I don't see the problem.
      > >
      > > I can reproduce this. As Eric says, it is a little tricky. I
      > > wrote the following to test.vim:
      > >
      > > let s:counter = 0
      > > function! Tst()
      > > call Tst_set_hl()
      > > let s:counter += 1
      > > echo 'Tst#'.s:counter
      > > return 'A test string'
      > > endfunction
      > >
      > > set tabline=%!Tst()
      > >
      > > if &showtabline < 1
      > > set showtabline=1 " 2=always
      > > endif
      > >
      > >
      > > function! Tst_set_hl()
      > > hi! Tst_hl term=bold
      > > endfunction
      > >
      > > Then I started vim with
      > >
      > > $ vim -u test.vim --noplugin test.vim
      > >
      > > (almost as good as -u NONE, right?) It seems that the problem comes up
      > > (sometimes) when there are two tabs and two windows in one of them:
      > >
      > > :tabnew
      > > gt
      > > :sp
      > >
      > > Now, starting from Normal mode, I open a new line and type some
      > > characters:
      > >
      > > oxxxx
      > >
      > > The message shows up, and the number increases by 2 each time I add a
      > > character.
      >
      > Well, yes, I can see that. What I don't understand is why you expect it
      > not to increase.


      Two reasons: 1) it doesn't happen in most cases, and 2) because the
      conditions for the redrawing of the tabline are implicit rather than
      explicit. It makes sense this would include updating of tabs, etc.
      That highlight commands should cause a redraw which would re-trigger
      the tabline function is not as clear, though in hindsight it does seem
      so.


      > What happens is that during the redraw of the tabline ":hi" is used,
      > which causes a redraw. So 'tabline' is evaluated again and again. You
      > must actually be lucky that Vim doesn't hang.


      Part of what made this so hard to track down was that when I added the
      highlighting call, everything went just fine for a while, and by the
      time I encountered the problem, many other changes had been made to
      the script.

      For reasons I don't understand yet, it requires a very specific set of
      conditions for it to be a problem, which suggests that the loop
      doesn't have to occur at all.


      > Just make sure that drawing the tabline doesn't cause Vim to redraw the
      > display. In this example you could check if the Tst_hl highlight was
      > already set.


      Actually, I must have a recurring highlight reset call in the tabline
      function. It turns out that most anything that resets highlighting
      for a window also clears the highlighting for the tabline, and the
      tabline has no special trigger (i.e. filetype) to tell it to reset its
      highlighting again. I don't see a good way to deal with this other
      than to have a recurring highlighting call in the tabline function.

      As a workaround, I've set a timer which will only allow a highlighting
      reset inside the tabline function every 5 seconds. This works well
      enough, but it does allow a window of failure.
    Your message has been successfully submitted and would be delivered to recipients shortly.