From 25f52331cff5f8cd72026f6f1bf62752be9800fd Mon Sep 17 00:00:00 2001 From: Michael Panchenko <--get> Date: Sat, 5 Jul 2025 13:29:48 +0200 Subject: [PATCH] LS: in finding references, skip over files outside the repo --- src/solidlsp/ls.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/solidlsp/ls.py b/src/solidlsp/ls.py index 6c141f47..0f18cb55 100644 --- a/src/solidlsp/ls.py +++ b/src/solidlsp/ls.py @@ -108,6 +108,10 @@ class SolidLanguageServer(ABC): ls: SolidLanguageServer if config.code_language == Language.PYTHON: + # We can also use jedi + # from solidlsp.language_servers.jedi_server import JediServer + # + # ls = JediServer(config, logger, repository_root_path) from solidlsp.language_servers.pyright_server import ( PyrightServer, ) @@ -664,6 +668,14 @@ class SolidLanguageServer(ABC): assert LSPConstants.RANGE in item abs_path = PathUtils.uri_to_path(item[LSPConstants.URI]) + if not Path(abs_path).is_relative_to(self.repository_root_path): + self.logger.log( + "Found a reference in a path outside the repository, probably the LS is parsing things in installed packages or in the standardlib! " + f"Path: {abs_path}. This is a bug but we currently simply skip these references.", + logging.WARNING, + ) + continue + rel_path = Path(abs_path).relative_to(self.repository_root_path) if self.is_ignored_path(str(rel_path)): self.logger.log(f"Ignoring reference in {rel_path} since it should be ignored", logging.DEBUG)