Skip to content

Commit 6398294

Browse files
authored
Improve readability
1 parent 60a5d0a commit 6398294

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pylsp/_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def match_uri_to_workspace(uri, workspaces):
141141
workspace_parts = pathlib.Path(workspace).parts
142142
if len(workspace_parts) > len(path):
143143
continue
144+
144145
match_len = 0
145146
is_parent = True
146147
for workspace_part, path_part in zip(workspace_parts, path):
@@ -149,20 +150,24 @@ def match_uri_to_workspace(uri, workspaces):
149150
if IS_WIN:
150151
workspace_part = workspace_part.lower()
151152
path_part = path_part.lower()
153+
152154
if workspace_part == path_part:
153155
match_len += 1
154156
else:
155157
# give up, any subsequent match is no longer relevant
156158
is_parent = False
157159
break
160+
158161
# prefer a match that is actually a parent of uri
159162
# otherwise fall back to longest matching non-parent
160163
if is_parent and match_len > 0:
161164
match_len += 1000
165+
162166
if match_len > 0:
163167
if match_len > max_len:
164168
max_len = match_len
165169
chosen_workspace = workspace
170+
166171
return chosen_workspace
167172

168173

0 commit comments

Comments
 (0)