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

Inconsistent fold opening behaviour after jump to mark within that fold

Expand Messages
  • Wiktor Ruben
    Hello Vimmers, Let s create sample fold: vim -u NONE -N ... i {{{1 foo bar zaz foo bar zaz bmm0za OK, now we have mark m set at the beginning of
    Message 1 of 6 , Jan 9, 2013
    • 0 Attachment
      Hello Vimmers,

      Let's create sample fold:

      vim -u NONE -N

      :set foldmethod=marker
      i
      {{{1<CR>
      foo bar zaz<CR>
      foo bar zaz<Esc>bmm0za

      OK, now we have mark 'm' set at the beginning of second 'zaz' within
      closed fold and cursor placed at the beginning of the last line. The
      problem is: when we jump to the mark with '`m' our fold stays closed.

      I guess that fold isn't opened because cursor is already at mark line
      (but in different column). I find this bahaviour annoying e.g. opening
      file edited a while ago and executing '`^' or '`.' makes me confused
      because I have to additionally execute 'zv' to get where I want.

      There is no need for 'zv' after jump from line different from mark
      line. Is there a way to force Vim to open fold even if cursor is
      already at destination line?

      --
      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
    • Andy Wokula
      ... You can also hit zero `0 to open the fold, that is only one keypress. And when something is annoying, a brute force method seem just right: nn `a `azv nn
      Message 2 of 6 , Jan 9, 2013
      • 0 Attachment
        Am 09.01.2013 18:35, schrieb Wiktor Ruben:
        > Hello Vimmers,
        >
        > Let's create sample fold:
        >
        > vim -u NONE -N
        >
        > :set foldmethod=marker
        > i
        > {{{1<CR>
        > foo bar zaz<CR>
        > foo bar zaz<Esc>bmm0za
        >
        > OK, now we have mark 'm' set at the beginning of second 'zaz' within
        > closed fold and cursor placed at the beginning of the last line. The
        > problem is: when we jump to the mark with '`m' our fold stays closed.
        >
        > I guess that fold isn't opened because cursor is already at mark line
        > (but in different column). I find this bahaviour annoying e.g. opening
        > file edited a while ago and executing '`^' or '`.' makes me confused
        > because I have to additionally execute 'zv' to get where I want.
        >
        > There is no need for 'zv' after jump from line different from mark
        > line. Is there a way to force Vim to open fold even if cursor is
        > already at destination line?

        You can also hit zero `0' to open the fold, that is only one keypress.

        And when something is annoying, a brute force method seem just right:

        nn `a `azv
        nn `b `bzv
        nn `c `czv
        nn `d `dzv
        nn `e `ezv
        nn `f `fzv
        nn `g `gzv
        nn `h `hzv
        nn `i `izv
        nn `j `jzv
        nn `k `kzv
        nn `l `lzv
        nn `m `mzv
        nn `n `nzv
        nn `o `ozv
        nn `p `pzv
        nn `q `qzv
        nn `r `rzv
        nn `s `szv
        nn `t `tzv
        nn `u `uzv
        nn `v `vzv
        nn `w `wzv
        nn `x `xzv
        nn `y `yzv
        nn `z `zzv

        --
        Andy

        --
        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
      • Christian Brabandt
        Hi Wiktor! ... Bram, this patch fixes it. The problem is, in nv_gomark() we only checked, whether the line position changed, and since it didn t change, the
        Message 3 of 6 , Jan 9, 2013
        • 0 Attachment
          Hi Wiktor!

          On Mi, 09 Jan 2013, Wiktor Ruben wrote:

          > Hello Vimmers,
          >
          > Let's create sample fold:
          >
          > vim -u NONE -N
          >
          > :set foldmethod=marker
          > i
          > {{{1<CR>
          > foo bar zaz<CR>
          > foo bar zaz<Esc>bmm0za
          >
          > OK, now we have mark 'm' set at the beginning of second 'zaz' within
          > closed fold and cursor placed at the beginning of the last line. The
          > problem is: when we jump to the mark with '`m' our fold stays closed.
          >
          > I guess that fold isn't opened because cursor is already at mark line
          > (but in different column). I find this bahaviour annoying e.g. opening
          > file edited a while ago and executing '`^' or '`.' makes me confused
          > because I have to additionally execute 'zv' to get where I want.
          >
          > There is no need for 'zv' after jump from line different from mark
          > line. Is there a way to force Vim to open fold even if cursor is
          > already at destination line?

          Bram,
          this patch fixes it. The problem is, in nv_gomark() we only checked,
          whether the line position changed, and since it didn't change, the fold
          isn't opened.

          diff --git a/src/normal.c b/src/normal.c
          --- a/src/normal.c
          +++ b/src/normal.c
          @@ -7523,7 +7523,7 @@
          pos_T *pos;
          int c;
          #ifdef FEAT_FOLDING
          - linenr_T lnum = curwin->w_cursor.lnum;
          + pos_T old_cursor = curwin->w_cursor;
          int old_KeyTyped = KeyTyped; /* getting file may reset it */
          #endif

          @@ -7552,7 +7552,7 @@
          #endif
          #ifdef FEAT_FOLDING
          if (cap->oap->op_type == OP_NOP
          - && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum)
          + && (pos == (pos_T *)-1 || !equalpos(old_cursor, *pos))
          && (fdo_flags & FDO_MARK)
          && old_KeyTyped)
          foldOpenCursor();



          Mit freundlichen Grüßen
          Christian
          --

          --
          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
        • Bram Moolenaar
          ... Thanks for the patch! -- hundred-and-one symptoms of being an internet addict: 254. You wake up daily with your keyboard printed on your forehead. /// Bram
          Message 4 of 6 , Jan 11, 2013
          • 0 Attachment
            Christian Brabandt wrote:

            > On Mi, 09 Jan 2013, Wiktor Ruben wrote:
            >
            > > Hello Vimmers,
            > >
            > > Let's create sample fold:
            > >
            > > vim -u NONE -N
            > >
            > > :set foldmethod=marker
            > > i
            > > {{{1<CR>
            > > foo bar zaz<CR>
            > > foo bar zaz<Esc>bmm0za
            > >
            > > OK, now we have mark 'm' set at the beginning of second 'zaz' within
            > > closed fold and cursor placed at the beginning of the last line. The
            > > problem is: when we jump to the mark with '`m' our fold stays closed.
            > >
            > > I guess that fold isn't opened because cursor is already at mark line
            > > (but in different column). I find this bahaviour annoying e.g. opening
            > > file edited a while ago and executing '`^' or '`.' makes me confused
            > > because I have to additionally execute 'zv' to get where I want.
            > >
            > > There is no need for 'zv' after jump from line different from mark
            > > line. Is there a way to force Vim to open fold even if cursor is
            > > already at destination line?
            >
            > Bram,
            > this patch fixes it. The problem is, in nv_gomark() we only checked,
            > whether the line position changed, and since it didn't change, the fold
            > isn't opened.

            Thanks for the patch!


            --
            hundred-and-one symptoms of being an internet addict:
            254. You wake up daily with your keyboard printed on your forehead.

            /// 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_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
          • Wiktor Ruben
            ... Thank you for the patch but if I understand correctly now fold will stay closed when cursor is already at mark s position i.e. in the same line and column.
            Message 5 of 6 , Jan 12, 2013
            • 0 Attachment
              On 9 Sty, 20:07, Christian Brabandt <cbli...@...> wrote:
              > Hi Wiktor!
              >
              > On Mi, 09 Jan 2013, Wiktor Ruben wrote:
              >
              >
              >
              >
              >
              >
              >
              >
              >
              > > Hello Vimmers,
              >
              > > Let's create sample fold:
              >
              > > vim -u NONE -N
              >
              > > :set foldmethod=marker
              > > i
              > > {{{1<CR>
              > > foo bar zaz<CR>
              > > foo bar zaz<Esc>bmm0za
              >
              > > OK, now we have mark 'm' set at the beginning of second 'zaz' within
              > > closed fold and cursor placed at the beginning of the last line.  The
              > > problem is: when we jump to the mark with '`m' our fold stays closed.
              >
              > > I guess that fold isn't opened because cursor is already at mark line
              > > (but in different column). I find this bahaviour annoying e.g. opening
              > > file edited a while ago and executing '`^' or '`.' makes me confused
              > > because I have to additionally execute 'zv' to get where I want.
              >
              > > There is no need for 'zv' after jump from line different from mark
              > > line. Is there a way to force Vim to open fold even if cursor is
              > > already at destination line?
              >
              > Bram,
              > this patch fixes it. The problem is, in nv_gomark() we only checked,
              > whether the line position changed, and since it didn't change, the fold
              > isn't opened.
              >
              > diff --git a/src/normal.c b/src/normal.c
              > --- a/src/normal.c
              > +++ b/src/normal.c
              > @@ -7523,7 +7523,7 @@
              >      pos_T      *pos;
              >      int                c;
              >  #ifdef FEAT_FOLDING
              > -    linenr_T   lnum = curwin->w_cursor.lnum;
              > +    pos_T      old_cursor = curwin->w_cursor;
              >      int                old_KeyTyped = KeyTyped;    /* getting file may reset it */
              >  #endif
              >
              > @@ -7552,7 +7552,7 @@
              >  #endif
              >  #ifdef FEAT_FOLDING
              >      if (cap->oap->op_type == OP_NOP
              > -           && (pos == (pos_T *)-1 || lnum != curwin->w_cursor.lnum)
              > +           && (pos == (pos_T *)-1 || !equalpos(old_cursor, *pos))
              >             && (fdo_flags & FDO_MARK)
              >             && old_KeyTyped)
              >         foldOpenCursor();
              >
              > Mit freundlichen Gr en
              > Christian
              > --

              Thank you for the patch but if I understand correctly now fold will
              stay closed when cursor is already at mark's position i.e. in the same
              line and column. But why not to open fold every time we jump to a mark
              within it? No matter whether cursor is already at mark's position or
              not.

              --
              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
            • Christian Brabandt
              Hi Wiktor! ... Yes. This is basically how folds work. If the cursor doesn t move, the fold does not open. I stumbled over this behaviour some time ago, when I
              Message 6 of 6 , Jan 12, 2013
              • 0 Attachment
                Hi Wiktor!

                On Sa, 12 Jan 2013, Wiktor Ruben wrote:

                > Thank you for the patch but if I understand correctly now fold will
                > stay closed when cursor is already at mark's position i.e. in the same
                > line and column. But why not to open fold every time we jump to a mark
                > within it? No matter whether cursor is already at mark's position or
                > not.

                Yes. This is basically how folds work. If the cursor doesn't move, the
                fold does not open.

                I stumbled over this behaviour some time ago, when I wondered why 'l'
                didn't open the fold at the cursors position. The reason was simple: The
                cursor was already at the end of line so 'l' didn't make it move and
                therefore the fold isn't opened. I even made a patch for this, but Bram
                said this was on purpose and is not going to change it.

                regards,
                Christian
                --
                Viren machen auch etwas sinnvolles: z.B. Windows löschen.

                --
                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
              Your message has been successfully submitted and would be delivered to recipients shortly.