Skip to content

Commit

Permalink
feat(debugger): Normalize the samples_dir path
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MatejKastak committed Oct 23, 2023
1 parent 1af4097 commit c15681d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions yls/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import logging
import re
from os import path
from pathlib import Path
from typing import Any

Expand Down Expand Up @@ -35,7 +34,7 @@ async def set_context(self, ls: Any, sample_hash: str, ruleset: str) -> PopupMes

log.debug(f'[DEBUGGER] Found sample and module files for hash "{sample_hash}": {files}')
if not files:
return ErrorMessage(f"Sample {sample_hash} not found in {path.abspath(samples_dir)}")
return ErrorMessage(f"Sample {sample_hash} not found in {samples_dir}")

# Sort files into groups by type of source
sample: str | None = None
Expand Down Expand Up @@ -106,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")
Expand Down

0 comments on commit c15681d

Please sign in to comment.