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

Paste bug in mswin.vim and menu.vim (plus the fix)

Expand Messages
  • Tony Apuzzo
    I found a bug in mswin.vim and menu.vim relating to the Paste function in gvim 6.4 (also in latest vim7 cvs sources). The special Paste func does not
    Message 1 of 3 , Feb 1, 2006
    • 0 Attachment
      I found a bug in mswin.vim and menu.vim relating to the <SID>Paste function in gvim 6.4 (also in latest vim7 cvs sources).  The special Paste func does not protect itself from remapped normal commands.  For example, if you remap ` in normal, <C-V> and Edit-->Paste will do strange things.
       
      To fix it, replace all instances of "normal" with "normal!" in both files.  Not sure if this is a production-quality fix but it does solve my problem.  Hope it helps someone else too. 
       
      Such a trivial fix that I'm not sure a patch is needed, but here it is.  I don't know if it is safe to include the ESC character in the text of the email, in which case the following patch may not come through cleanly:
       
      The patch:
      --- menu.vim~ Wed Feb 01 13:44:32 2006
      +++ menu.vim Wed Feb 01 13:26:23 2006
      @@ -139,14 +139,14 @@
         func! <SID>Paste()
           let ove = &ve
           set ve=all
      -    normal `^
      +    normal! `^
           if @+ != ''
      -      normal "+gP
      +      normal! "+gP
           endif
           let c = col(".")
      -    normal i
      +    normal! i
           if col(".") < c " compensate for i<ESC> moving the cursor left
      -      normal l
      +      normal! l
           endif
           let &ve = ove
         endfunc
      --- mswin.vim~ Wed Feb 01 13:44:47 2006
      +++ mswin.vim Wed Feb 01 13:26:35 2006
      @@ -42,14 +42,14 @@
         func! <SID>Paste()
           let ove = &ve
           set ve=all
      -    normal `^
      +    normal! `^
           if @+ != ''
      -      normal "+gP
      +      normal! "+gP
           endif
           let c = col(".")
      -    normal i
      +    normal! i
           if col(".") < c " compensate for i<ESC> moving the cursor left
      -      normal l
      +      normal! l
           endif
           let &ve = ove
         endfunc
    • Tony Apuzzo
      I apologize for sending my prior message in HTML mode with an attachment. (Should ve defaulted to plain text.) Quick summary: I found and fixed a clipboard
      Message 2 of 3 , Feb 1, 2006
      • 0 Attachment
        I apologize for sending my prior message in HTML mode with an
        attachment. (Should've defaulted to plain text.)

        Quick summary: I found and fixed a clipboard paste bug in mswin.vim and
        menu.vim that would be triggered if the default functionality for ` (or
        P, or i) in normal mode was overridden. Here is the plain-text copy of
        the patch file in case the original got nuked by a filter:

        --- menu.vim~ Wed Feb 01 13:44:32 2006
        +++ menu.vim Wed Feb 01 13:26:23 2006
        @@ -139,14 +139,14 @@
        func! <SID>Paste()
        let ove = &ve
        set ve=all
        - normal `^
        + normal! `^
        if @+ != ''
        - normal "+gP
        + normal! "+gP
        endif
        let c = col(".")
        - normal i
        + normal! i
        if col(".") < c " compensate for i<ESC> moving the cursor left
        - normal l
        + normal! l
        endif
        let &ve = ove
        endfunc
        --- mswin.vim~ Wed Feb 01 13:44:47 2006
        +++ mswin.vim Wed Feb 01 13:26:35 2006
        @@ -42,14 +42,14 @@
        func! <SID>Paste()
        let ove = &ve
        set ve=all
        - normal `^
        + normal! `^
        if @+ != ''
        - normal "+gP
        + normal! "+gP
        endif
        let c = col(".")
        - normal i
        + normal! i
        if col(".") < c " compensate for i<ESC> moving the cursor left
        - normal l
        + normal! l
        endif
        let &ve = ove
        endfunc
      • Bram Moolenaar
        ... Apparently nobody ran into this problem yet. I ll include the patch, thanks! -- hundred-and-one symptoms of being an internet addict: 231. You sprinkle
        Message 3 of 3 , Feb 2, 2006
        • 0 Attachment
          Tony Apuzzo wrote:

          > I found a bug in mswin.vim and menu.vim relating to the <SID>Paste
          > function in gvim 6.4 (also in latest vim7 cvs sources). The special
          > Paste func does not protect itself from remapped normal commands. For
          > example, if you remap ` in normal, <C-V> and Edit-->Paste will do
          > strange things.
          >
          > To fix it, replace all instances of "normal" with "normal!" in both
          > files. Not sure if this is a production-quality fix but it does solve
          > my problem. Hope it helps someone else too.
          >
          > Such a trivial fix that I'm not sure a patch is needed, but here it is.
          > I don't know if it is safe to include the ESC character in the text of
          > the email, in which case the following patch may not come through
          > cleanly:

          Apparently nobody ran into this problem yet. I'll include the patch,
          thanks!

          --
          hundred-and-one symptoms of being an internet addict:
          231. You sprinkle Carpet Fresh on the rugs and put your vacuum cleaner
          in the front doorway permanently so it always looks like you are
          actually attempting to do something about that mess that has amassed
          since you discovered the Internet.

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