Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "folder_exclude_patterns" handling with relative project path #2142

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions plugin/core/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,6 +42,7 @@
from weakref import WeakSet
import functools
import json
import os
import sublime
import threading
import urllib.parse
Expand Down Expand Up @@ -375,15 +378,24 @@ 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))
# 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']))
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))
print('PATH', path)
print('PATTERNS', patterns)
if matches_pattern(path, patterns):
print('MATCHES')
return "matches a pattern in folder_exclude_patterns"
return None

Expand Down