Patch 8.0.0224
Problem:    When 'fileformats' is changed in a BufReadPre auto command, it
            does not take effect in readfile(). (Gary Johnson)
Solution:   Check the value of 'fileformats' after executing auto commands.
            (Christian Brabandt)
Files:      src/fileio.c, src/testdir/test_fileformat.vim


*** ../vim-8.0.0223/src/fileio.c        2017-01-13 21:59:59.327172086 +0100
--- src/fileio.c        2017-01-23 21:24:28.482126938 +0100
***************
*** 274,282 ****
      int               msg_save = msg_scroll;
      linenr_T  read_no_eol_lnum = 0;   /* non-zero lnum when last line of
                                         * last read was missing the eol */
!     int               try_mac = (vim_strchr(p_ffs, 'm') != NULL);
!     int               try_dos = (vim_strchr(p_ffs, 'd') != NULL);
!     int               try_unix = (vim_strchr(p_ffs, 'x') != NULL);
      int               file_rewind = FALSE;
  #ifdef FEAT_MBYTE
      int               can_retry;
--- 274,282 ----
      int               msg_save = msg_scroll;
      linenr_T  read_no_eol_lnum = 0;   /* non-zero lnum when last line of
                                         * last read was missing the eol */
!     int               try_mac;
!     int               try_dos;
!     int               try_unix;
      int               file_rewind = FALSE;
  #ifdef FEAT_MBYTE
      int               can_retry;
***************
*** 738,743 ****
--- 738,747 ----
      curbuf->b_op_start.lnum = ((from == 0) ? 1 : from);
      curbuf->b_op_start.col = 0;
  
+     try_mac = (vim_strchr(p_ffs, 'm') != NULL);
+     try_dos = (vim_strchr(p_ffs, 'd') != NULL);
+     try_unix = (vim_strchr(p_ffs, 'x') != NULL);
+ 
  #ifdef FEAT_AUTOCMD
      if (!read_buffer)
      {
***************
*** 769,774 ****
--- 773,783 ----
        else
            apply_autocmds_exarg(EVENT_FILEREADPRE, sfname, sfname,
                                                            FALSE, NULL, eap);
+       /* autocommands may have changed it */
+       try_mac = (vim_strchr(p_ffs, 'm') != NULL);
+       try_dos = (vim_strchr(p_ffs, 'd') != NULL);
+       try_unix = (vim_strchr(p_ffs, 'x') != NULL);
+ 
        if (msg_scrolled == n)
            msg_scroll = m;
  
*** ../vim-8.0.0223/src/testdir/test_fileformat.vim     2016-10-12 
17:45:13.642857417 +0200
--- src/testdir/test_fileformat.vim     2017-01-23 21:24:08.074263064 +0100
***************
*** 15,17 ****
--- 15,31 ----
    call assert_equal(test_fileformats, &fileformat)
    set fileformats&
  endfunc
+ 
+ func Test_fileformat_autocommand()
+       let filecnt=['', 'foobar', 'eins', '', 'zwei', 'drei', 'vier', 'fünf', 
'']
+       let ffs=&ffs
+       call writefile(filecnt, 'Xfile', 'b')
+       au BufReadPre Xfile set ffs=dos ff=dos
+       new Xfile
+       call assert_equal('dos', &l:ff)
+       call assert_equal('dos', &ffs)
+       " cleanup
+       let &ffs=ffs
+       au! BufReadPre Xfile
+       bw!
+ endfunc
*** ../vim-8.0.0223/src/version.c       2017-01-23 20:47:09.037078522 +0100
--- src/version.c       2017-01-23 21:26:24.265354675 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     224,
  /**/

-- 
Overflow on /dev/null, please empty the bit bucket.

 /// Bram Moolenaar -- [email protected] -- 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui