Skip to content

Commit 37314cc

Browse files
committed
Check exclude patterns before .editorconfig-file existence
A micro-optimization. Check the exclude patterns first since those can be done on-CPU. Then, if the file isn't pattern-excluded, check for files on disk.
1 parent 3dcc256 commit 37314cc

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

plugin/editorconfig.vim

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,17 @@ function! s:UseConfigFiles() abort " Apply config to the current buffer {{{1
233233
return
234234
endif
235235

236+
" Ignore specific patterns
237+
for pattern in g:EditorConfig_exclude_patterns
238+
if l:buffer_name =~ pattern
239+
if g:EditorConfig_verbose
240+
echo 'Skipping EditorConfig for buffer "' . l:buffer_name .
241+
\ '" based on pattern "' . pattern . '"'
242+
endif
243+
return
244+
endif
245+
endfor
246+
236247
" Check if any .editorconfig does exist
237248
let l:conf_files = s:GetFilenames(expand('%:p:h'), '.editorconfig')
238249
let l:conf_found = 0
@@ -252,17 +263,6 @@ function! s:UseConfigFiles() abort " Apply config to the current buffer {{{1
252263
endif
253264
endif
254265

255-
" Ignore specific patterns
256-
for pattern in g:EditorConfig_exclude_patterns
257-
if l:buffer_name =~ pattern
258-
if g:EditorConfig_verbose
259-
echo 'Skipping EditorConfig for buffer "' . l:buffer_name .
260-
\ '" based on pattern "' . pattern . '"'
261-
endif
262-
return
263-
endif
264-
endfor
265-
266266
if g:EditorConfig_verbose
267267
echo 'Applying EditorConfig ' . s:editorconfig_core_mode .
268268
\ ' on file "' . l:buffer_name . '"'

0 commit comments

Comments
 (0)