diff --git a/spyder/plugins/editor/plugin.py b/spyder/plugins/editor/plugin.py index 392a9b38ea1..519594c288b 100644 --- a/spyder/plugins/editor/plugin.py +++ b/spyder/plugins/editor/plugin.py @@ -2745,7 +2745,9 @@ def renamed_tree(self, source, dest): tofile = to_text_string(dest) for fname in self.get_filenames(): if osp.abspath(fname).startswith(dirname): - new_filename = fname.replace(dirname, tofile) + source_re = "^" + re.escape(source) + dest_quoted = dest.replace("\\", r"\\") + new_filename = re.sub(source_re, dest_quoted, fname) self.renamed(source=fname, dest=new_filename) #------ Source code