From b4492e5a16af273d009b6c706f66f97d4b11b354 Mon Sep 17 00:00:00 2001 From: Evan Hall Date: Wed, 5 Sep 2018 18:05:12 -0400 Subject: [PATCH] Changed how signatures are matched (#17) * Added comments to signature provider * Signatures must now be an exact match Perform a 1:1 match against the SignatureInformation label before the first open paren instead of performing a partial match against the whole label --- server/src/server.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/server.ts b/server/src/server.ts index 51d460da..36058e0c 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -242,12 +242,17 @@ connection.onSignatureHelp((params: TextDocumentPositionParams) => { } const results: Array = new Array() + + // add all matching signatures to the results array for (const signa of tspItem.signatures) { - if (signa.label.indexOf(unreversed) !== -1) { + const signaBeforeParams = signa.label.slice(0, signa.label.indexOf('(')) + + if (signaBeforeParams.localeCompare(unreversed) === 0) { results.push(signa) } } + // get the index of each comma between our surrounding parenthesis for (let i = openParenOffset + 1; i < closeParenOffset;) { const commaIndex = content.getText().indexOf(',', i) if (commaIndex >= i) { @@ -259,6 +264,7 @@ connection.onSignatureHelp((params: TextDocumentPositionParams) => { } } + // compare the current offset to the index of the last comma to get the active parameter let activeParam = 0 commaIndices.forEach((element: number) => { if (offset > element) {