If HANDLE is nil return nil."
(when handle
- (let ((hash (make-hash-table))
- (file (file-relative-name file (editorconfig-core-handle-path
- handle))))
+ (let* ((hash (make-hash-table))
+ (dir (file-name-directory (editorconfig-core-handle-path handle)))
+ (file (file-relative-name file dir)))
(dolist (section (editorconfig-core-handle-sections handle))
(cl-loop for (key . value) in (editorconfig-core-handle-section-get-properties section file)
do (puthash (intern key) value hash)))
(if (string-match-p "/" pattern)
(let ((pattern (replace-regexp-in-string "\\`/" "" pattern)))
(editorconfig-fnmatch-p name pattern))
- (editorconfig-fnmatch-p (file-name-nondirectory name) pattern)))
+ ;; The match is not "anchored" so it can be either in the current dir or
+ ;; in a subdir. Contrary to Zsh patterns, editorconfig's `**/foo' does
+ ;; not match `foo', so we need to split the problem into two matches.
+ (or (editorconfig-fnmatch-p name pattern)
+ (editorconfig-fnmatch-p name (concat "**/" pattern)))))
(defun editorconfig-core-handle--parse-file (conf)
"Parse EditorConfig file CONF.