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

51514RE: g ignores range in diff mode

Expand Messages
  • John Beckett
    Aug 5, 2008
    • 0 Attachment
      Gary Johnson wrote:
      > When vim is in diff mode and a BufWrite autocommand
      > containing a "<range>g" is executed, the g command appears to
      > ignore the range and act on the entire buffer.
      > ...

      I've had a look at this and confirm Gary's results. It looks like a bug.

      I don't follow all the complex interactions, but the following looks as if it is

      In file ex_docmd.c the function do_one_cmd() is invoked by the autocmd.
      Everything is good at entry. The command is:
      "1,100g/50$/s/$/\tchanged here/"

      and it is parsed correctly including:
      ea.line1 = 1
      ea.line2 = 100

      But then the following code is executed:
      if (((ea.argt & WHOLEFOLD) || ea.addr_count >= 2) && !global_busy)
      /* Put the first line at the start of a closed fold, put the last line
      * at the end of a closed fold. */
      (void)hasFolding(ea.line1, &ea.line1, NULL);
      (void)hasFolding(ea.line2, NULL, &ea.line2);

      The last line changes ea.line2 from 100 to 1000 (we previously did ':windo diffthis'
      which folded a lot of lines, ending at line 1000).

      Therefore the 'g' command is applied to the whole file and Gary's bug follows.


      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 6 messages in this topic