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

Re: InsertEnter cursor position related

Expand Messages
  • troydm
    ... Wait, isn t check_cursor_col() called only when line number hasn t changed, and that is when cursor s position is resetted to value before event call -- --
    Message 1 of 10 , May 18, 2013
    • 0 Attachment
      On Sunday, May 19, 2013 1:53:16 AM UTC+4, troydm wrote:
      > On Sunday, May 19, 2013 1:23:23 AM UTC+4, Bram Moolenaar wrote:
      > >
      > >
      > > That's a bug. The check for the line is to avoid going outside of the
      > >
      > > available lines when the text has changed.
      > >
      >
      > You mean check_cursor_col() call is to check for the line to avoid going outside of the available lines when text has changed i presume?
      > So what is the proposed fix?
      >
      > commenting/removing this line?
      > curwin->w_cursor = save_cursor;

      Wait, isn't check_cursor_col() called only when line number hasn't changed, and that is when cursor's position is resetted to value before event call

      --
      --
      You received this message from the "vim_dev" 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_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Bram Moolenaar
      ... Well, if text got deleted the saved cursor position may no longer be valid. Hmm, that would be a problem though. If the autocommand removed text and
      Message 2 of 10 , May 19, 2013
      • 0 Attachment
        Troydm wrote:

        > On Sunday, May 19, 2013 1:23:23 AM UTC+4, Bram Moolenaar wrote:
        > >
        > >
        > > That's a bug. The check for the line is to avoid going outside of the
        > >
        > > available lines when the text has changed.
        > >
        >
        > You mean check_cursor_col() call is to check for the line to avoid
        > going outside of the available lines when text has changed i presume?
        > So what is the proposed fix?
        >
        > commenting/removing this line?
        > curwin->w_cursor = save_cursor;

        Well, if text got deleted the saved cursor position may no longer be
        valid.

        Hmm, that would be a problem though. If the autocommand removed text
        and positioned the cursor where it should be it will be restored in the
        wrong position.

        Most InsertEnter autocommands will not change text, restoring the cursor
        is useful then. But we need some way to avoid restoring the cursor.
        We could use the v:char variable perhaps.

        --
        There is no right or wrong, there is only your personal opinion.
        (Bram Moolenaar)

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        --
        You received this message from the "vim_dev" 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_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • troydm
        ... Thanks, works perfectly -- -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text you are replying to.
        Message 3 of 10 , May 19, 2013
        • 0 Attachment
          On Sunday, May 19, 2013 11:04:12 PM UTC+4, Bram Moolenaar wrote:
          > Troydm wrote:
          >
          >
          >
          > > On Sunday, May 19, 2013 1:23:23 AM UTC+4, Bram Moolenaar wrote:
          >
          > > >
          >
          > > >
          >
          > > > That's a bug. The check for the line is to avoid going outside of the
          >
          > > >
          >
          > > > available lines when the text has changed.
          >
          > > >
          >
          > >
          >
          > > You mean check_cursor_col() call is to check for the line to avoid
          >
          > > going outside of the available lines when text has changed i presume?
          >
          > > So what is the proposed fix?
          >
          > >
          >
          > > commenting/removing this line?
          >
          > > curwin->w_cursor = save_cursor;
          >
          >
          >
          > Well, if text got deleted the saved cursor position may no longer be
          >
          > valid.
          >
          >
          >
          > Hmm, that would be a problem though. If the autocommand removed text
          >
          > and positioned the cursor where it should be it will be restored in the
          >
          > wrong position.
          >
          >
          >
          > Most InsertEnter autocommands will not change text, restoring the cursor
          >
          > is useful then. But we need some way to avoid restoring the cursor.
          >
          > We could use the v:char variable perhaps.
          >
          >
          >
          > --
          >
          > There is no right or wrong, there is only your personal opinion.
          >
          > (Bram Moolenaar)
          >
          >
          >
          > /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          >
          > /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          >
          > \\\ an exciting new programming language -- http://www.Zimbu.org ///
          >
          > \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          Thanks, works perfectly

          --
          --
          You received this message from the "vim_dev" 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_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.