Problem with the autocomplet and dot character

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Problem with the autocomplet and dot character

Postby Guillaume » Thu Jan 13, 2011 1:34 pm

Hello,

I used the autocomplet with "words" containing the dot character (for example X.a, X.b and Y.z ),
when the caret is just before the dot there is no problem the autocomplet popup displays the good choices (X.a and X.b if X has been typed) , but if the caret is after the dot (for example I typed "X.") the autocomplete open popup with all completion (X.a, X.b and Y.z). The autocomplet should display only X.a and X.b !?

Thank
Guillaume
 
Posts: 7
Joined: Fri Dec 10, 2010 2:16 pm

Re: Problem with the autocomplet and dot character

Postby robert » Thu Jan 13, 2011 4:46 pm

Is your CompletionProvider a DefaultCompletionProvider or a subclass? If so, you'll need to override the isValidChar(char) method to include '.' as a character that is accepted as part of an identifier to auto-complete.

The default implementation:

java code:

/**
* Returns whether the specified character is valid in an auto-completion.
* The default implementation is equivalent to
* "<code>Character.isLetterOrDigit(ch) || ch=='_'</code>". Subclasses
* can override this method to change what characters are matched.
*
* @param ch The character.
* @return Whether the character is valid.
*/
protected boolean isValidChar(char ch) {
return Character.isLetterOrDigit(ch) || ch=='_';
}


You can override it to look like this, for example:

java code:

protected boolean isValidChar(char ch) {
return super.isValidChar(ch) || ch=='.';
}
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Problem with the autocomplet and dot character

Postby Guest » Fri Jan 14, 2011 11:09 am

thank you very much it works
Guest
 

Re: Problem with the autocomplet and dot character

Postby GroG » Thu Sep 27, 2012 9:59 pm

Thanks,
This helped me too.
GroG
 
Posts: 2
Joined: Thu Jun 07, 2012 4:39 am


Return to Help

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests