MakeEditable: Improve handling of file states and output

This commit is contained in:
Amar Sood (tekacs) 2025-04-12 04:44:20 -04:00
parent bbc16ca60a
commit 9e1900a126

View file

@ -1173,23 +1173,36 @@ Just reply with fixed versions of the {blocks} above that failed to match.
abs_path = self.abs_root_path(file_path) abs_path = self.abs_root_path(file_path)
rel_path = self.get_rel_fname(abs_path) rel_path = self.get_rel_fname(abs_path)
# Check if file is in read-only context # Check if file is already editable
if abs_path not in self.abs_read_only_fnames: if abs_path in self.abs_fnames:
if abs_path in self.abs_fnames: self.io.tool_output(f"📝 File '{file_path}' is already editable")
self.io.tool_output(f"📝 File '{file_path}' is already editable") return f"File is already editable"
return f"File is already editable"
else: # Check if file exists on disk
self.io.tool_output(f"⚠️ File '{file_path}' not in context") if not os.path.isfile(abs_path):
return f"File not in context" self.io.tool_output(f"⚠️ File '{file_path}' not found")
return f"Error: File not found"
# Move from read-only to editable
self.abs_read_only_fnames.remove(abs_path) # File exists, is not editable, might be read-only or not in context yet
was_read_only = False
if abs_path in self.abs_read_only_fnames:
self.abs_read_only_fnames.remove(abs_path)
was_read_only = True
# Add to editable files
self.abs_fnames.add(abs_path) self.abs_fnames.add(abs_path)
self.io.tool_output(f"📝 Made '{file_path}' editable") if was_read_only:
return f"File is now editable" self.io.tool_output(f"📝 Moved '{file_path}' from read-only to editable")
return f"File is now editable (moved from read-only)"
else:
# File was not previously in context at all
self.io.tool_output(f"📝 Added '{file_path}' directly to editable context")
# Track if added during exploration? Maybe not needed for direct MakeEditable.
# self.files_added_in_exploration.add(rel_path) # Consider if needed
return f"File is now editable (added directly)"
except Exception as e: except Exception as e:
self.io.tool_error(f"Error making file editable: {str(e)}") self.io.tool_error(f"Error in MakeEditable for '{file_path}': {str(e)}")
return f"Error: {str(e)}" return f"Error: {str(e)}"
def _execute_make_readonly(self, file_path): def _execute_make_readonly(self, file_path):