Skip to content

Commit

Permalink
fix(save): fix save diff preview when path starts with ~/
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Nov 22, 2024
1 parent ebd700b commit 0fbafd0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gptme/tools/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ def execute_save(

# TODO: add check that it doesn't try to write a file with placeholders!

if Path(fn).exists():
current = Path(fn).read_text()
path = Path(fn).expanduser()

if path.exists():
current = path.read_text()
p = Patch(current, code)
# TODO: if inefficient save, replace request with patch (and vice versa), or even append
print_preview(p.diff_minimal(), "diff")
Expand All @@ -69,8 +71,6 @@ def execute_save(
yield Message("system", "Save cancelled.")
return

path = Path(fn).expanduser()

# if the file exists, ask to overwrite
if path.exists():
if not confirm("File exists, overwrite?"):
Expand Down

0 comments on commit 0fbafd0

Please sign in to comment.