From f7aa163895eee2df0b956ef3bd15a96766c03db7 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Thu, 15 Dec 2022 08:56:21 +0100 Subject: [PATCH 1/3] Fix issue with handling "folder_exclude_patterns" with relative project path --- plugin/core/windows.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugin/core/windows.py b/plugin/core/windows.py index 5d8a940fb..4518ab202 100644 --- a/plugin/core/windows.py +++ b/plugin/core/windows.py @@ -40,6 +40,7 @@ from weakref import WeakSet import functools import json +import os import sublime import threading import urllib.parse @@ -375,14 +376,18 @@ def should_present_diagnostics(self, uri: DocumentUri) -> Optional[str]: project_data = self.window.project_data() if project_data: for folder in project_data.get('folders', []): + folder_path = folder['path'] + if not os.path.isabs(folder_path): + project_file_directory = os.path.dirname(self.window.project_file_name()) + folder_path = os.path.abspath(os.path.join(project_file_directory, folder_path)) for pattern in folder.get('folder_exclude_patterns', []): if pattern.startswith('//'): - patterns.append(sublime_pattern_to_glob(pattern, True, folder['path'])) + patterns.append(sublime_pattern_to_glob(pattern, True, folder_path)) elif pattern.startswith('/'): patterns.append(sublime_pattern_to_glob(pattern, True)) else: - patterns.append(sublime_pattern_to_glob('//' + pattern, True, folder['path'])) - patterns.append(sublime_pattern_to_glob('//**/' + pattern, True, folder['path'])) + patterns.append(sublime_pattern_to_glob('//' + pattern, True, folder_path)) + patterns.append(sublime_pattern_to_glob('//**/' + pattern, True, folder_path)) if matches_pattern(path, patterns): return "matches a pattern in folder_exclude_patterns" return None From b7089edbdd8c55e6cb7e7025605c8e536a390112 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Thu, 15 Dec 2022 09:13:08 +0100 Subject: [PATCH 2/3] debug --- plugin/core/windows.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin/core/windows.py b/plugin/core/windows.py index 4518ab202..a669097ee 100644 --- a/plugin/core/windows.py +++ b/plugin/core/windows.py @@ -388,7 +388,10 @@ def should_present_diagnostics(self, uri: DocumentUri) -> Optional[str]: else: patterns.append(sublime_pattern_to_glob('//' + pattern, True, folder_path)) patterns.append(sublime_pattern_to_glob('//**/' + pattern, True, folder_path)) + print('URI', uri) + print('PATTERNS', patterns) if matches_pattern(path, patterns): + print('MATCHES') return "matches a pattern in folder_exclude_patterns" return None From 37ed4366ce56f86efb4ed058c95a949aa3fe20a1 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Thu, 15 Dec 2022 09:49:30 +0100 Subject: [PATCH 3/3] normalize path --- plugin/core/windows.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/core/windows.py b/plugin/core/windows.py index a669097ee..f299f886a 100644 --- a/plugin/core/windows.py +++ b/plugin/core/windows.py @@ -26,7 +26,9 @@ from .types import matches_pattern from .types import sublime_pattern_to_glob from .typing import Optional, Any, Dict, Deque, List, Generator, Tuple, Union +from .url import filename_to_uri from .url import parse_uri +from .url import uri_to_filename from .views import extract_variables from .views import format_diagnostic_for_panel from .views import make_link @@ -380,6 +382,8 @@ def should_present_diagnostics(self, uri: DocumentUri) -> Optional[str]: if not os.path.isabs(folder_path): project_file_directory = os.path.dirname(self.window.project_file_name()) folder_path = os.path.abspath(os.path.join(project_file_directory, folder_path)) + # Normalize path + folder_path = uri_to_filename(filename_to_uri(folder_path)) for pattern in folder.get('folder_exclude_patterns', []): if pattern.startswith('//'): patterns.append(sublime_pattern_to_glob(pattern, True, folder_path)) @@ -388,7 +392,7 @@ def should_present_diagnostics(self, uri: DocumentUri) -> Optional[str]: else: patterns.append(sublime_pattern_to_glob('//' + pattern, True, folder_path)) patterns.append(sublime_pattern_to_glob('//**/' + pattern, True, folder_path)) - print('URI', uri) + print('PATH', path) print('PATTERNS', patterns) if matches_pattern(path, patterns): print('MATCHES')