Skip to content

Commit 1ba8c05

Browse files
BenjaminSchaafBenjamin Schaafrchl
authored
Fix usage of sublime.score_selector (#2427)
ST 4173 tweaks how selector scoring works resulting in LSP no longer functioning. As per the comment there seems to be a misunderstanding of how `sublime.score_selector` works. The entire selector must always match for a non-zero score, so if the goal is to check if it's not empty and matches then checking for `>= 8` is simply wrong. --------- Co-authored-by: Benjamin Schaaf <[email protected]> Co-authored-by: Rafał Chłodnicki <[email protected]>
1 parent 12b3e93 commit 1ba8c05

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

plugin/core/types.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,10 @@ def match_view(self, view: sublime.View, scheme: str) -> bool:
840840
syntax = view.syntax()
841841
if not syntax:
842842
return False
843-
# Every part of a x.y.z scope seems to contribute 8.
844-
# An empty selector result in a score of 1.
845-
# A non-matching non-empty selector results in a score of 0.
846-
# We want to match at least one part of an x.y.z, and we don't want to match on empty selectors.
847-
return scheme in self.schemes and sublime.score_selector(syntax.scope, self.selector) >= 8
843+
selector = self.selector.strip()
844+
if not selector:
845+
return False
846+
return scheme in self.schemes and sublime.score_selector(syntax.scope, selector) > 0
848847

849848
def map_client_path_to_server_uri(self, path: str) -> str:
850849
if self.path_maps:

0 commit comments

Comments
 (0)