From e17a1fff3a12d6ad41d05f7fb56ee6ecbf244f7d Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 26 Aug 2024 12:10:33 -0700 Subject: [PATCH] feat: implement fuzzy filename matching --- aider/coders/editblock_coder.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aider/coders/editblock_coder.py b/aider/coders/editblock_coder.py index 45d38aecb..aad07c204 100644 --- a/aider/coders/editblock_coder.py +++ b/aider/coders/editblock_coder.py @@ -551,11 +551,13 @@ def find_filename(lines, fence, valid_fnames): if fname == vfn.name: return vfn + # Perform fuzzy matching with valid_fnames for fname in filenames: - # todo: do a fuzzt match with the valid_fnames - pass + close_matches = difflib.get_close_matches(fname, valid_fnames, n=1, cutoff=0.6) + if close_matches: + return close_matches[0] - # look for a file w/extension + # If no fuzzy match, look for a file w/extension for fname in filenames: if "." in fname: return fname