I am using a ScintillaNET control in my C# Winforms application. I am trying to implement an auto-tag feature that will auto-complete the tag before, for example, when a user types <html>, auto-complete feature will trigger and insert </html>.
I'm using the ScintillaNET CharAdded function for this implementation:
if (caretPos != 0)
{
//If the characters before the caret are "ml>" (last three chars from "<html>")
if (TextArea.Text[caretPos - 1] == '>' && TextArea.Text[caretPos - 2] == 'l' && TextArea.Text[caretPos - 3] == 'm')
{
TextArea.Text = TextArea.Text.Insert(caretPos, "</html>");
TextArea.SelectionStart = caretPos + 0;
TextArea.Selections.First();
TextArea.ScrollCaret();
}
}
My problem is, the Scintilla control keeps scrolling either all the way up or all the way down. I thought the ScrollCaret() function would work, but it keeps happening. Any ideas?
I've struggled with this problem too. Thought it was a bug. Even the solutions given on the Github issues page didn't help. But then i found out that if you insert a text using:
TextArea.Text = TextArea.Text.Insert(caretPos, "");
Then that itself will be the problem. ScintillaNET already has a function for Text.Insert. Using InsertText will prevent the control from scrolling.
Found the problem also issued here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With