-
Notifications
You must be signed in to change notification settings - Fork 646
Don`t process function signatures on comment lines #2496
Conversation
|
||
// Stop processing if the line is a comment | ||
if (line.text.trim().indexOf('//') === 0) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only catch the case where the entire line starts with the comment.
What about the below case?
x, err := regexp.Match("abc", data) // I have some comment here,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the most basic case of course. Either way, I'm noticing the bug isn't completely dependent on comments presence so there is still something else in it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to reuse the same function made for suggestions logic on this one
// if its current line, get the text until the position given, otherwise get the full line. | ||
const [currentLine, characterPosition] = lineNr === position.line | ||
? [line.text.substring(0, position.character), position.character] | ||
: [line.text, line.text.length - 1]; | ||
|
||
for (let char = characterPosition - 1; char >= 0; char--) { | ||
for (let char = characterPosition; char >= 0; char--) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometime during the last year I introduced this regression with the belief this would prevent an issue in the future, and while even though the code path shouldn't have caused any issues I remained none the wiser 🤦♂️
Sorry for that. This should fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem @lggomez, thanks for the fix!
Fixes (at least part of) #2481