diff --git a/CHANGELOG.md b/CHANGELOG.md index ef8e53e4..4b9ef8ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Status of the `main` branch. Changes prior to the next official version change w - Allow external files from dependencies (specified via references like "") to be - read via `ReadFileTool` - searched via `SearchForPatternTool` + - used in `JetBrainsFindDeclarationTool` when using plugin version 2023.3.3+ # v1.6.0 (2026-07-16) diff --git a/src/serena/code_editor.py b/src/serena/code_editor.py index fed0297f..c4894a08 100644 --- a/src/serena/code_editor.py +++ b/src/serena/code_editor.py @@ -13,6 +13,7 @@ from solidlsp.ls import LSPFileBuffer from solidlsp.ls_utils import PathUtils, TextUtils from .project import Project +from .util.file_proxy import FileProxy log = logging.getLogger(__name__) TSymbol = TypeVar("TSymbol", bound=Symbol) @@ -78,6 +79,8 @@ class CodeEditor(Generic[TSymbol], ABC): """ Context manager for editing a file. """ + if FileProxy.is_external_path(relative_path): + raise ValueError(f"Cannot edit external file: {relative_path}") with self._open_file_context(relative_path) as edited_file: yield edited_file # save the file @@ -400,8 +403,7 @@ class JetBrainsCodeEditor(CodeEditor[JetBrainsSymbol]): super().__init__(relative_path) path = os.path.join(project.project_root, relative_path) log.info("Editing file: %s", path) - with open(path, encoding=project.project_config.encoding) as f: - self._content = f.read() + self._content = FileProxy.from_project_relative_path(project, relative_path).get_contents() def get_contents(self) -> str: return self._content