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

Tabline function sometimes recalled when highlighting set/changed.

Expand Messages
  • Eric Arnold
    I think I ve found the thing that triggers my problem with TabLineSet.vim where the tabline function get called for every keystroke: I reset the highlighting
    Message 1 of 9 , May 1, 2006
    • 0 Attachment
      I think I've found the thing that triggers my problem with
      TabLineSet.vim where the tabline function get called for every
      keystroke: I reset the highlighting in the tabline function.

      Does it seem reasonable that the highlighting changes are triggering
      the tabline to re-update (and thus creating a loop)?
    • Eric Arnold
      ... Ack. It s not the only trigger. Removing the highlighting init fixed the prob., in one case, but there is still another :-(
      Message 2 of 9 , May 1, 2006
      • 0 Attachment
        On 5/1/06, Eric Arnold <eric.p.arnold@...> wrote:
        > I think I've found the thing that triggers my problem with
        > TabLineSet.vim where the tabline function get called for every
        > keystroke: I reset the highlighting in the tabline function.
        >
        > Does it seem reasonable that the highlighting changes are triggering
        > the tabline to re-update (and thus creating a loop)?
        >

        Ack. It's not the only trigger. Removing the highlighting init fixed
        the prob., in one case, but there is still another :-(
      • Bram Moolenaar
        ... How many times do I need to repeat this: Pleeeeease give a reproducable example. I don t have time to guess what you are doing. -- If you don t get
        Message 3 of 9 , May 1, 2006
        • 0 Attachment
          Eric Arnold wrote:

          > I think I've found the thing that triggers my problem with
          > TabLineSet.vim where the tabline function get called for every
          > keystroke: I reset the highlighting in the tabline function.
          >
          > Does it seem reasonable that the highlighting changes are triggering
          > the tabline to re-update (and thus creating a loop)?

          How many times do I need to repeat this: Pleeeeease give a reproducable
          example. I don't have time to guess what you are doing.

          --
          If you don't get everything you want, think of
          everything you didn't get and don't want.

          /// Bram Moolenaar -- Bram@... -- 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 ///
        • Eric Arnold
          You don t need to repeat yourself. If I could give you a reproducible code fragment, I would. It happens as part of a relatively long script. It s a *data
          Message 4 of 9 , May 1, 2006
          • 0 Attachment
            You don't need to repeat yourself. If I could give you a reproducible
            code fragment, I would. It happens as part of a relatively long
            script.

            It's a *data point*. A piece of information. "Setting highlighting
            from the tabline function causes it to re-trigger on the next
            keystroke". In this case, it's a rather specific piece of
            information.

            Once again, I'm not demanding a fix. I'm not asking you to guess what
            I'm doing, but why not let you know about this? I'm only asking you
            to think about it a little. You might get a sudden idea, since you're
            the one who knows the Vim code.

            You could at least file it away. If you gather pieces of information
            about a project, you eventually get correlations which are useful!

            However, if you can't use partial information for *anything*, then I'm
            nonplussed, would be the word. If you want silence from users are
            unable to give a definitive test case, while trying to *guess* what
            the Vim code is doing, that seems counter-productive.


            On 5/1/06, Bram Moolenaar <Bram@...> wrote:
            >
            > Eric Arnold wrote:
            >
            > > I think I've found the thing that triggers my problem with
            > > TabLineSet.vim where the tabline function get called for every
            > > keystroke: I reset the highlighting in the tabline function.
            > >
            > > Does it seem reasonable that the highlighting changes are triggering
            > > the tabline to re-update (and thus creating a loop)?
            >
            > How many times do I need to repeat this: Pleeeeease give a reproducable
            > example. I don't have time to guess what you are doing.
            >
            > --
            > If you don't get everything you want, think of
            > everything you didn't get and don't want.
            >
            > /// Bram Moolenaar -- Bram@... -- 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 ///
            >
          • Eric Arnold
            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.
            Message 5 of 9 , May 1, 2006
            • 0 Attachment
              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.

              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
            • Bram Moolenaar
              ... I don t see the problem. I have to guess that where you talk about another window you actually mean another tab page, otherwise the tab pages line isn t
              Message 6 of 9 , May 2, 2006
              • 0 Attachment
                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.
                >
                > 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

                I don't see the problem.

                I have to guess that where you talk about another window you actually
                mean another tab page, otherwise the tab pages line isn't displayed at
                all.

                I only see the "Tst#N" displayed when I switch between tab pages with
                "gt".

                I guess your example is missing something essential. Try starting with
                "vim -u NONE".

                --
                "The future's already arrived - it's just not evenly distributed yet."
                -- William Gibson

                /// Bram Moolenaar -- Bram@... -- 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 ///
              • Benji Fisher
                ... 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
                Message 7 of 9 , May 2, 2006
                • 0 Attachment
                  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.

                  HTH --Benji Fisher
                • Bram Moolenaar
                  ... Well, yes, I can see that. What I don t understand is why you expect it not to increase. What happens is that during the redraw of the tabline :hi is
                  Message 8 of 9 , May 2, 2006
                  • 0 Attachment
                    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.

                    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.

                    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.

                    --
                    Your company is doomed if your primary product is overhead transparencies.
                    (Scott Adams - The Dilbert principle)

                    /// Bram Moolenaar -- Bram@... -- 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 ///
                  • 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 9 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.