# Invoked from "scripts.vim" in 'runtimepath'
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
-# Last Change: 2025 Aug 08
+# Last Change: 2025 Aug 09
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
export def DetectFiletype()
# Diff file:
# - "diff" in first line (context diff)
# - "Only in " in first line
+ # - "34,35c34,35" normal diff format output
# - "--- " in first line and "+++ " in second line (unified diff).
# - "*** " in first line and "--- " in second line (context diff).
# - "# It was generated by makepatch " in the second line (makepatch diff).
# - "=== ", "--- ", "+++ " (bzr diff, common case)
# - "=== (removed|added|renamed|modified)" (bzr diff, alternative)
# - "# HG changeset patch" in first line (Mercurial export format)
- elseif line1 =~ '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\>\|# It was generated by makepatch \|Index:\s\+\f\+\r\=$\|===== \f\+ \d\+\.\d\+ vs edited\|==== //\f\+#\d\+\|# HG changeset patch\)'
+ elseif line1 =~ '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\(,\d\+\)\=\>$\|# It was generated by makepatch \|Index:\s\+\f\+\r\=$\|===== \f\+ \d\+\.\d\+ vs edited\|==== //\f\+#\d\+\|# HG changeset patch\)'
|| (line1 =~ '^--- ' && line2 =~ '^+++ ')
|| (line1 =~ '^\* looking for ' && line2 =~ '^\* comparing to ')
|| (line1 =~ '^\*\*\* ' && line2 =~ '^--- ')
func Test_info_file()
filetype on
- call writefile(['File: coreutils.info, Node: Top, Next: Introduction, Up: (dir)', 'D'], 'Xfile', 'D')
+ call writefile(['File: coreutils.info, Node: Top, Next: Introduction, Up: (dir)'], 'Xfile', 'D')
split Xfile
call assert_equal('info', &filetype)
bwipe!
func Test_mail_file()
filetype on
- call writefile(['Return-path: <lgc@debian.home.arpa>', 'D'], 'Xfile', 'D')
+ call writefile(['Return-path: <lgc@debian.home.arpa>'], 'Xfile', 'D')
split Xfile
call assert_equal('mail', &filetype)
bwipe!
func Test_terminfo_file()
filetype on
- call writefile(['# Reconstructed via infocmp from file: /etc/terminfo/x/xterm', 'D'], 'Xfile', 'D')
+ call writefile(['# Reconstructed via infocmp from file: /etc/terminfo/x/xterm'], 'Xfile', 'D')
split Xfile
call assert_equal('terminfo', &filetype)
bwipe!
filetype off
endfunc
+func Test_diff_format()
+ filetype on
+
+ call writefile(['0d555557 1 (John John 2025-01-01 00:00:00 +0000 1) foo'], 'Xdiff', 'D')
+ split Xdiff
+ call assert_true(empty(&filetype))
+ bwipe!
+
+ filetype off
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1615,
/**/
1614,
/**/