@@ -262,15 +262,16 @@ function! s:DetectEditorConfig(absolute_path, ...) abort
262
262
return [{}, ' ' ]
263
263
endif
264
264
let root = ' '
265
- let tail = a: 0 ? ' / ' . a: 1 : ' / .editorconfig'
265
+ let tail = a: 0 ? a: 1 : ' .editorconfig'
266
266
let dir = fnamemodify (a: absolute_path , ' :h' )
267
267
let previous_dir = ' '
268
268
let sections = []
269
269
let overrides = get (g: , ' sleuth_editorconfig_overrides' , {})
270
270
while dir !=# previous_dir && dir !~# ' ^//\%([^/]\+/\=\)\=$'
271
- let read_from = get (overrides, dir . tail, get (overrides, dir , dir . tail))
272
- if type (read_from) == type (' ' ) && read_from !=# dir . tail && read_from !~# ' ^/\|^\a\+:\|^$'
273
- let read_from = simplify (dir . ' /' . read_from)
271
+ let head = substitute (dir , ' /\=$' , ' /' , ' ' )
272
+ let read_from = get (overrides, head . tail, get (overrides, head, head . tail))
273
+ if type (read_from) == type (' ' ) && read_from !=# head . tail && read_from !~# ' ^/\|^\a\+:\|^$'
274
+ let read_from = simplify (head . read_from)
274
275
endif
275
276
let ftime = type (read_from) == type (' ' ) ? getftime (read_from) : -1
276
277
let [cachetime; econfig] = get (s: editorconfig_cache , read_from, [-1 , {}, []])
@@ -282,7 +283,7 @@ function! s:DetectEditorConfig(absolute_path, ...) abort
282
283
endif
283
284
call extend (sections , econfig[1 ], ' keep' )
284
285
if get (econfig[0 ], ' root' , [' ' ])[0 ] == ? ' true'
285
- let root = dir
286
+ let root = head
286
287
break
287
288
endif
288
289
let previous_dir = dir
@@ -516,7 +517,7 @@ function! s:DetectHeuristics(into) abort
516
517
return detected
517
518
endif
518
519
let dir = len (detected.path ) ? fnamemodify (detected.path , ' :h' ) : ' '
519
- let root = len (detected.root) ? detected.root : dir == # s: Slash (expand (' ~' )) ? dir : fnamemodify (dir , ' :h' )
520
+ let root = len (detected.root) ? fnamemodify ( detected.root, ' :h ' ) : dir == # s: Slash (expand (' ~' )) ? dir : fnamemodify (dir , ' :h' )
520
521
if detected.bufname = ~# ' ^\a\a\+:' || root == # ' .' || ! isdirectory (root)
521
522
let dir = ' '
522
523
endif
0 commit comments