Skip to content

Commit

Permalink
Fixed bug in hover text where it was not producing the correct text o…
Browse files Browse the repository at this point in the history
…utput for an instantiable callable.
  • Loading branch information
msfterictraut committed Jul 20, 2023
1 parent 9aa29e4 commit 97160a0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/pyright-internal/src/languageService/tooltipUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
FunctionType,
OverloadedFunctionType,
Type,
TypeBase,
TypeCategory,
UnknownType,
combineTypes,
Expand Down Expand Up @@ -115,10 +116,15 @@ export function getFunctionTooltip(
const indentStr =
functionSignatureDisplay === SignatureDisplayType.formatted ? '\n' + ' '.repeat(functionParamIndentOffset) : '';
const funcParts = evaluator.printFunctionParts(type);
const paramSignature = formatSignature(funcParts, indentStr, functionSignatureDisplay);
const paramSignature = `${formatSignature(funcParts, indentStr, functionSignatureDisplay)} -> ${funcParts[1]}`;

if (TypeBase.isInstantiable(type)) {
return `${labelFormatted}${functionName}: type[${paramSignature}]`;
}

const sep = isProperty ? ': ' : '';
const defKeyword = isProperty ? '' : 'def ';
return `${labelFormatted}${defKeyword}${functionName}${sep}${paramSignature} -> ${funcParts[1]}`;
return `${labelFormatted}${defKeyword}${functionName}${sep}${paramSignature}`;
}

export function getConstructorTooltip(
Expand Down

0 comments on commit 97160a0

Please sign in to comment.