runtime(sieve): preserve existing line endings in ftplugin

Commit: 
https://github.com/vim/vim/commit/fc00006777594f969ba8fcff676e6ca1bcb43546
Author: AndrĂ©-Patrick Bubel <[email protected]>
Date:   Fri Jan 9 17:44:04 2026 +0000

    runtime(sieve): preserve existing line endings in ftplugin
    
    Only set fileformat=dos for new files; preserve existing line endings
    when editing. This satisfies RFC 5228 for new files while avoiding
    issues with version control and existing workflows.
    
    The previous change (3cb4148) unconditionally set fileformat=dos, which
    converts existing files with LF line endings to CRLF on save. This
    causes issues with version control (entire file appears changed) and
    breaks workflows where sieve files are stored with unix line endings.
    
    Dovecot Pigeonhole (the main sieve implementation) has explicitly
    accepted LF line endings since 2008 (commit 97b967b5):
      /* Loose LF is allowed (non-standard) and converted to CRLF */
    This behavior has remained unchanged for almost 18 years.
    
    closes: #19144
    
    Co-Authored-By: Claude Opus 4.5 <[email protected]>
    Signed-off-by: AndrĂ©-Patrick Bubel <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/ftplugin/sieve.vim b/runtime/ftplugin/sieve.vim
index 8161fe99a..1ea8eaeb9 100644
--- a/runtime/ftplugin/sieve.vim
+++ b/runtime/ftplugin/sieve.vim
@@ -3,6 +3,7 @@
 " Maintainer:           This runtime file is looking for a new maintainer.
 " Previous Maintainer:  Nikolai Weibull <[email protected]>
 " Latest Revision:      2025 Feb 20
+" 2026 Jan 09 by Vim Project: preserve line endings for existing files #19144
 
 if exists("b:did_ftplugin")
   finish
@@ -16,4 +17,7 @@ setlocal formatoptions-=t formatoptions+=croql
 
 " https://datatracker.ietf.org/doc/html/rfc5228#section-2.2 says
 " "newlines (CRLF, never just CR or LF)"
-setlocal fileformat=dos
+" Use CRLF for new files only; preserve existing line endings
+if expand('%:p') !=# '' && !filereadable(expand('%:p'))
+  setlocal fileformat=dos
+endif

-- 
-- 
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].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1veHFL-004ggJ-5H%40256bit.org.

Raspunde prin e-mail lui