Hi,
I found a problem with Suggester in SourceCodeEditor.
If startPos = 0 (start position of the replacement) then SourceCodeEditor not replace text.
For startPos > 0 is ok.
@Install(to = "addEmailAddressesField", subject = "suggester")
private fun addEmailAddressesFieldSuggester(source: AutoCompleteSupport, text: String, cursorPosition: Int): List<Suggestion> {
val suggestions: MutableList<Suggestion> = ArrayList()
var searchText= ""
var startPos=-1
for (i in (cursorPosition-1) downTo 0){
if (text[i]==' ' || text[i]==',' || text[i]==';' || text[i]=='\n' || i==0){
startPos=if (i==0) 0 else i+1
searchText=text.substring(startPos,cursorPosition).trim(' ',',',';','\n')
break;
}
}
dataManager.load(AddressBook::class.java)
.query("select e from app_AddressBook e where e.name like :search or e.email like :search order by e.name,e.email")
.parameter("search", "$searchText%")
.view("addressBook-browse")
.maxResults(10)
.list()
.forEach { item->
suggestions.add(Suggestion(source, item.name, item.email, null, startPos, -1))
}
return suggestions
}
Regards
Marcin