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

Re: Key after Press ENTER prompt recorded double

Expand Messages
  • Christian Brabandt
    ... Hmm, the problem is, that wait_return pushes the entered character back into the input queue. I think, this patches fixes it. diff --git a/src/message.c
    Message 1 of 6 , Oct 8, 2013
      On Di, 08 Okt 2013, Urtica dioica wrote:

      > Open a blank Vim (I'm using 7.4.52), and type this:
      >
      > 3graqqY:s/a/b/g|s/b/c/g<CR>pq@q
      >
      > (Since there are 3 "a"s, and the 'report' default is 2, both :s commands report the number of changes, which triggers a Press ENTER prompt. But the bug applies to any Press ENTER prompt.)
      >
      > When "p" is run straight after the prompt, it runs once (as it should). In the "q register however, the "p" is recorded twice. You can confirm this with ":display q". When you run "@q", "p" runs both times, as it's recorded in the macro.
      >
      > The same problem exists when recording keystrokes to a file with "vim -w".
      >
      > If you actually hit Enter to dismiss the prompt, that will also be recorded. If you put it in a macro, for instance, the extra Enter will run and try to move the cursor.

      Hmm, the problem is, that wait_return pushes the entered character back
      into the input queue.

      I think, this patches fixes it.

      diff --git a/src/message.c b/src/message.c
      --- a/src/message.c
      +++ b/src/message.c
      @@ -887,6 +887,7 @@
      int oldState;
      int tmpState;
      int had_got_int;
      + int had_Recording = Recording;

      if (redraw == TRUE)
      must_redraw = CLEAR;
      @@ -957,11 +958,16 @@
      * typeahead buffer. */
      ++no_mapping;
      ++allow_keys;
      + /* temporarily disable Recording. If Recording is active, the char
      + * will be recorded later, since the character will be added to the
      + * typebuf after the loop */
      + Recording = FALSE;
      c = safe_vgetc();
      if (had_got_int && !global_busy)
      got_int = FALSE;
      --no_mapping;
      --allow_keys;
      + Recording = had_Recording;

      #ifdef FEAT_CLIPBOARD
      /* Strange way to allow copying (yanking) a modeless selection at


      regards,
      Christian
      --
      Das Zuhause ist keineswegs der einzige zivilisierte Ort in einer
      abenteuerlichen Welt, sondern der einzige unzivilisierte in einer Welt
      der Zwänge und Pflichten.
      -- Gilbert Keith Chesterton

      --
      --
      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.
    • Urtica dioica
      ... I tried your patch. It seems to stop duplication when recording a macro with q, but not when recording keystrokes to a file with vim -w. -- -- You received
      Message 2 of 6 , Oct 8, 2013
        вторник, 8 октября 2013 г., 11:49:19 UTC-6 пользователь Christian Brabandt написал:
        > On Di, 08 Okt 2013, Urtica dioica wrote:
        >
        >
        >
        > > Open a blank Vim (I'm using 7.4.52), and type this:
        >
        > >
        >
        > > 3graqqY:s/a/b/g|s/b/c/g<CR>pq@q
        >
        > >
        >
        > > (Since there are 3 "a"s, and the 'report' default is 2, both :s commands report the number of changes, which triggers a Press ENTER prompt. But the bug applies to any Press ENTER prompt.)
        >
        > >
        >
        > > When "p" is run straight after the prompt, it runs once (as it should). In the "q register however, the "p" is recorded twice. You can confirm this with ":display q". When you run "@q", "p" runs both times, as it's recorded in the macro.
        >
        > >
        >
        > > The same problem exists when recording keystrokes to a file with "vim -w".
        >
        > >
        >
        > > If you actually hit Enter to dismiss the prompt, that will also be recorded. If you put it in a macro, for instance, the extra Enter will run and try to move the cursor.
        >
        >
        >
        > Hmm, the problem is, that wait_return pushes the entered character back
        >
        > into the input queue.
        >
        >
        >
        > I think, this patches fixes it.
        >
        >
        >
        > diff --git a/src/message.c b/src/message.c
        >
        > --- a/src/message.c
        >
        > +++ b/src/message.c
        >
        > @@ -887,6 +887,7 @@
        >
        > int oldState;
        >
        > int tmpState;
        >
        > int had_got_int;
        >
        > + int had_Recording = Recording;
        >
        >
        >
        > if (redraw == TRUE)
        >
        > must_redraw = CLEAR;
        >
        > @@ -957,11 +958,16 @@
        >
        > * typeahead buffer. */
        >
        > ++no_mapping;
        >
        > ++allow_keys;
        >
        > + /* temporarily disable Recording. If Recording is active, the char
        >
        > + * will be recorded later, since the character will be added to the
        >
        > + * typebuf after the loop */
        >
        > + Recording = FALSE;
        >
        > c = safe_vgetc();
        >
        > if (had_got_int && !global_busy)
        >
        > got_int = FALSE;
        >
        > --no_mapping;
        >
        > --allow_keys;
        >
        > + Recording = had_Recording;
        >
        >
        >
        > #ifdef FEAT_CLIPBOARD
        >
        > /* Strange way to allow copying (yanking) a modeless selection at
        >
        >
        >
        >
        >
        > regards,
        >
        > Christian
        >
        > --
        >
        > Das Zuhause ist keineswegs der einzige zivilisierte Ort in einer
        >
        > abenteuerlichen Welt, sondern der einzige unzivilisierte in einer Welt
        >
        > der Zw�nge und Pflichten.
        >
        > -- Gilbert Keith Chesterton

        I tried your patch. It seems to stop duplication when recording a macro with q, but not when recording keystrokes to a file with vim -w.

        --
        --
        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.
      • Christian Brabandt
        ... Try this updated patch. regards, Christian -- Entweder das Neueste oder das Älteste (aus der Jugend) gefällt auf Reisen. Am Ende gibts kein Neuestes
        Message 3 of 6 , Oct 8, 2013
          On Di, 08 Okt 2013, Urtica dioica wrote:
          > I tried your patch. It seems to stop duplication when recording a
          > macro with q, but not when recording keystrokes to a file with vim -w.

          Try this updated patch.


          regards,
          Christian

          --
          Entweder das Neueste oder das Älteste (aus der Jugend) gefällt auf
          Reisen. Am Ende gibts kein Neuestes mehr, aber das Älteste wird älter.
          -- Jean Paul

          --
          --
          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.
        • Urtica dioica
          ... Cool. That covers all the problems I m aware of. Just hope there s not a third stroke-recording mechanism I haven t thought of. ;) -- -- You received this
          Message 4 of 6 , Oct 8, 2013
            On Tuesday, October 8, 2013 1:13:42 PM UTC-6, Christian Brabandt wrote:
            > Try this updated patch.

            Cool. That covers all the problems I'm aware of. Just hope there's not a third stroke-recording mechanism I haven't thought of. ;)

            --
            --
            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
            ... Thanks! -- CUSTOMER: Well, can you hang around a couple of minutes? He won t be long. MORTICIAN: Naaah, I got to go on to Robinson s -- they ve
            Message 5 of 6 , Oct 8, 2013
              Christian Brabandt wrote:

              > On Di, 08 Okt 2013, Urtica dioica wrote:
              > > I tried your patch. It seems to stop duplication when recording a
              > > macro with q, but not when recording keystrokes to a file with vim -w.
              >
              > Try this updated patch.

              Thanks!


              --
              CUSTOMER: Well, can you hang around a couple of minutes? He won't be
              long.
              MORTICIAN: Naaah, I got to go on to Robinson's -- they've lost nine today.
              CUSTOMER: Well, when is your next round?
              MORTICIAN: Thursday.
              DEAD PERSON: I think I'll go for a walk.
              The Quest for the Holy Grail (Monty Python)

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