From 8b858d1cab8263f3123529d0c5df5f01b5ddebcc Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 4 May 2026 15:08:59 +0200 Subject: [PATCH] FilenameMatcher: fix in new method string_contains_relevant_filename --- src/solidlsp/ls_config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/solidlsp/ls_config.py b/src/solidlsp/ls_config.py index be6fd7e4..f04f4817 100644 --- a/src/solidlsp/ls_config.py +++ b/src/solidlsp/ls_config.py @@ -2,6 +2,7 @@ Configuration objects for language servers """ +import re from collections.abc import Iterable from dataclasses import dataclass, field from enum import Enum @@ -25,8 +26,12 @@ class FilenameMatcher: return False def string_contains_relevant_filename(self, string: str) -> bool: + """:return: whether ``string`` contains an occurrence of any registered extension as + a *complete* extension — i.e. the extension must either end the string or be followed + by a non-extension-character (anything other than a letter, digit, or underscore). + """ for ext in self._file_extensions: - if ext in string: + if re.search(rf"{re.escape(ext)}(?:\W|$)", string): return True return False