Skip to content

Commit

Permalink
Changed how signatures are matched (#17)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ethall authored Sep 5, 2018
1 parent 72e6760 commit b4492e5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,17 @@ connection.onSignatureHelp((params: TextDocumentPositionParams) => {
}

const results: Array<SignatureInformation> = 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) {
Expand All @@ -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) {
Expand Down

0 comments on commit b4492e5

Please sign in to comment.