From 03a43869197f321f4cd699027dfc521131845591 Mon Sep 17 00:00:00 2001 From: Yavanni Date: Thu, 26 Sep 2024 14:04:30 -0400 Subject: [PATCH] fix: stupid windows paths --- language_server/server/__init__.py | 10 +++------- language_server/server/features/validate.py | 8 +++++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/language_server/server/__init__.py b/language_server/server/__init__.py index 363fe8f..5d7e49a 100644 --- a/language_server/server/__init__.py +++ b/language_server/server/__init__.py @@ -4,6 +4,7 @@ import logging import sys from typing import Iterator, List +import pathlib from beet import ( Context, GenericPlugin, @@ -162,11 +163,6 @@ def create_context(config: ProjectConfig, config_path: Path) -> Context: with ProjectBuilderShadow(project, root=True).build() as ctx: mc = ctx.inject(Mecha) - logging.debug(mc.steps) - - # for mod in ctx.data[Module]: - # logging.debug(mod) - logging.debug(f"Mecha created for {config_path} successfully") for pack in ctx.packs: for provider in mc.providers: @@ -176,8 +172,8 @@ def create_context(config: ProjectConfig, config_path: Path) -> Context: for location, file in pack.all(): try: - path = file.ensure_source_path() - logging.debug(path) + path = os.path.normpath(file.ensure_source_path()) + path = os.path.normcase(path) PATH_TO_RESOURCE[str(path)] = (location, file) except: continue diff --git a/language_server/server/features/validate.py b/language_server/server/features/validate.py index 1b312cc..b4e792a 100644 --- a/language_server/server/features/validate.py +++ b/language_server/server/features/validate.py @@ -1,5 +1,6 @@ from dataclasses import dataclass import logging +import os import traceback from typing import Any from beet import Context, Function, TextFileBase @@ -76,15 +77,16 @@ def validate_function( ls: MechaLanguageServer, ctx: Context, text_doc: TextDocument ) -> list[InvalidSyntax]: logging.debug(f"Parsing function:\n{text_doc.source}") - logging.debug(text_doc.path) - if text_doc.path not in PATH_TO_RESOURCE: + path = os.path.normcase(os.path.normpath(text_doc.path)) + + if path not in PATH_TO_RESOURCE: COMPILATION_RESULTS[text_doc.uri] = CompiledDocument( ctx, "", None, [], None, None ) return [] - location, file = PATH_TO_RESOURCE[text_doc.path] + location, file = PATH_TO_RESOURCE[path] if not isinstance(file, Function) and not isinstance(file, Module): COMPILATION_RESULTS[text_doc.uri] = CompiledDocument(