From 8afe64183288a1564a82b1ad619b2ebbb04e5a6d Mon Sep 17 00:00:00 2001 From: Arnim Rupp <46819580+ruppde@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:02:42 +0200 Subject: [PATCH] feat(debugger): Normalize the `samples_dir` path (#139) Show absolute path in codelens "Select hash for context" error message to avoid indistinct "Sample abc not found in ." Normalize the path right at the start when we request it through LSP get config. This way we will see the absolute path in the error message and also add support for the path relative to the user (home) directory. --------- Co-authored-by: MatejKastak --- yls/debugger.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yls/debugger.py b/yls/debugger.py index d63cd16..c6edc88 100644 --- a/yls/debugger.py +++ b/yls/debugger.py @@ -105,7 +105,8 @@ def display_py_object(value: Any) -> str: async def get_samples_dir(ls: Any) -> Path | None: samples_dir_config = await utils.get_config_from_editor(ls, "yls.yari.samplesDirectory") log.debug(f"[DEBUGGER] Got {samples_dir_config=}") - samples_dir_path = Path(samples_dir_config) + samples_dir_path = Path(samples_dir_config).expanduser().resolve() + log.debug(f"[DEBUGGER] Resolved {samples_dir_config=}") if not samples_dir_path.is_dir(): log.debug("[DEBUGGER] Samples dir does not exist or is not a directory")