fix: properly quote filenames with spaces and special characters using shlex.quote()

This commit is contained in:
Paul Gauthier (aider) 2024-09-27 16:52:06 -07:00
parent c4e766a4c4
commit 36bc8f90db

View file

@ -3,6 +3,7 @@ import re
import subprocess
import sys
import tempfile
import shlex
from collections import OrderedDict
from pathlib import Path
@ -575,9 +576,7 @@ class Commands:
self.io.print(diff)
def quote_fname(self, fname):
if " " in fname and '"' not in fname:
fname = f'"{fname}"'
return fname
return shlex.quote(fname)
def completions_raw_read_only(self, document, complete_event):
# Get the text before the cursor and strip leading spaces