Skip to content

Commit 353c942

Browse files
Work around spec bugs for PowerShellEditorServices (#1181)
- The "tags" in a CompletionItem response are null (invalid per spec) - The "signatures" in a textDocument/signatureHelp response is null (invalid per spec) See: PowerShell/PowerShellEditorServices#1324 See: PowerShell/PowerShellEditorServices#1325 Co-authored-by: Предраг Николић / Predrag Nikolic <[email protected]>
1 parent ee858bd commit 353c942

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

plugin/completion.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ def resolve(completion_list: sublime.CompletionList, items: List[sublime.Complet
137137

138138

139139
def is_deprecated(item: dict) -> bool:
140-
return item.get("deprecated", False) or CompletionItemTag.Deprecated in item.get("tags", [])
140+
if item.get("deprecated", False):
141+
return True
142+
tags = item.get("tags")
143+
if isinstance(tags, list):
144+
return CompletionItemTag.Deprecated in tags
145+
return False
141146

142147

143148
class CompletionHandler(LSPViewEventListener):

plugin/core/signature_help.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,17 @@ def _build_overload_selector(self) -> str:
163163
def create_signature_help(response: Optional[dict]) -> Optional[SignatureHelp]:
164164
if response is None:
165165
return None
166-
167-
signatures = list(parse_signature_information(signature) for signature in response.get("signatures", []))
168-
active_signature = response.get("activeSignature", -1)
169-
active_parameter = response.get("activeParameter", -1)
170-
166+
signatures = response.get("signatures") or []
167+
signatures = [parse_signature_information(signature) for signature in signatures]
171168
if signatures:
169+
active_signature = response.get("activeSignature", -1)
170+
active_parameter = response.get("activeParameter", -1)
172171
if not 0 <= active_signature < len(signatures):
173172
debug("activeSignature {} not a valid index for signatures length {}".format(
174173
active_signature, len(signatures)))
175174
active_signature = 0
176-
177175
return SignatureHelp(signatures, active_signature, active_parameter)
178-
else:
179-
return None
176+
return None
180177

181178

182179
def find_params_to_split_at(label: str) -> List[int]:

0 commit comments

Comments
 (0)