My MemberList.Show(), length parameter problem

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Martin Lundberg - Sweden
Avatar
Hello again =)

I guess I have to reask my question. I'm having problem understanding how to use the length parameter of memberlist.show() functions. You told me to get the startoffset of the token, and the caret offset. I had to use the GetPreviousToken() method to get the token before the caret, but it's not working.

I've done this:

Token myCurrentToken = editor.SelectedView.GetPreviousToken();
int test = editor.Caret.Offset - myCurrentToken.StartOffset;

editor.IntelliPrompt.MemberList.Show(editor.Caret.Offset, test);
but I get the error: The offset '8' added to the length '3' must be less than or equal to the count of characters in the document.

What have I done wrong?

Martin Lundberg
Student, Sweden

Comments (4)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You have to make your start offset back further. You want the text that is before the caret offset, not after it. The way you have it is wrong in that it's calculating the length from the previous token to the caret but then you're using that length after the caret offset instead of before it.


Actipro Software Support

Posted 15 years ago by Martin Lundberg - Sweden
Avatar
I'm not sure I'm following =&

I thoutght It was like this....

Lets say I write:

"this function is called add" and then press CTRL+SPACE (which takes me to the code that shows the memberlist)

Now the caret is directly after the last d in add, I want to get 3 into the lengt, right?

To do this, I took the StartOffset of the previousToken (the previous token is add).

In this case the StartOffset of add is: 24
The offset of the carret is: 27

that makes 3, and thats whats passed int the length parameter.

I'm sure this is wrong because you juse told me so, but I don't get what it is i'm doing wrong. I'm sorry if you just told me that in the last message but please try to make it even clearer ;P

Martin Lundberg
Student, Sweden

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If the caret is after the last "d" in "add" then you don't want to move further right because you don't care what's after the word "add". You are trying to get the word "add". So you should be using an offset of (current offset - 3) and a length of 3.


Actipro Software Support

Posted 15 years ago by Martin Lundberg - Sweden
Avatar
Ahaaa! I totally ignored the first parameter of the show method because I thouth it was the position of the memberlist (where it was supposed to popup) but now I just added "-test" to the first parameter and now it worked =)

Thanks!

Martin Lundberg
Student, Sweden

The latest build of this product (v2018.1 build 0341) was released 7 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.