File tree Expand file tree Collapse file tree
autoload/editorconfig_core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,23 +60,24 @@ lockvar s:SECTCRE s:OPTCRE s:MAX_SECTION_NAME s:MAX_PROPERTY_NAME s:MAX_PROPERTY
6060" Read \p config_filename and return the options applicable to
6161" \p target_filename. This is the main entry point in this file.
6262function ! editorconfig_core#ini#read_ini_file (config_filename, target_filename)
63- let l: oldenc = &encoding
64-
6563 if ! filereadable (a: config_filename )
6664 return {}
6765 endif
6866
69- try " so &encoding will always be reset
70- let &encoding = ' utf-8' " so readfile() will strip BOM
67+ try
7168 let l: lines = readfile (a: config_filename )
69+ if &encoding !=? ' utf-8'
70+ " strip BOM
71+ if len (l: lines ) > 0 && l: lines [0 ][:2 ] == # " \xEF\xBB\xBF "
72+ let l: lines [0 ] = l: lines [0 ][3 :]
73+ endif
74+ endif
7275 let result = s: parse (a: config_filename , a: target_filename , l: lines )
7376 catch
74- let &encoding = l: oldenc
7577 " rethrow, but with a prefix since throw 'Vim...' fails.
7678 throw ' Could not read editorconfig file at ' . v: throwpoint . ' : ' . string (v: exception )
7779 endtry
7880
79- let &encoding = l: oldenc
8081 return result
8182endfunction
8283
You can’t perform that action at this time.
0 commit comments