File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1616import docstring_to_markdown
1717import jedi
1818
19+ from pylsp import IS_WIN
20+
1921JEDI_VERSION = jedi .__version__
2022
2123# Eol chars accepted by the LSP protocol
@@ -134,9 +136,23 @@ def match_uri_to_workspace(uri, workspaces):
134136 if len (workspace_parts ) > len (path ):
135137 continue
136138 match_len = 0
139+ is_parent = True
137140 for workspace_part , path_part in zip (workspace_parts , path ):
141+ # filename match is case insensitive on windows
142+ # also, uris._normalize_win_path() lowercases the drive letter
143+ if IS_WIN :
144+ workspace_part = workspace_part .lower ()
145+ path_part = path_part .lower ()
138146 if workspace_part == path_part :
139147 match_len += 1
148+ else :
149+ # give up, any subsequent match is no longer relevant
150+ is_parent = False
151+ break
152+ # prefer a match that is actually a parent of uri
153+ # otherwise fall back to longest matching non-parent
154+ if is_parent and match_len > 0 :
155+ match_len += 1000
140156 if match_len > 0 :
141157 if match_len > max_len :
142158 max_len = match_len
You can’t perform that action at this time.
0 commit comments