Highlight in AdvRichEditor

Hello, I want to highlicht some words in AdvRichEditor. The word are in a StringList.

After every Change of the Editor Content, it should update the highlight.

My Code so far in the procedure RichEditorChange:


 var ASel : integer := ARichEditor.SelStart;
 ARichEditor.OnChange := nil;
 ARichEditor.UnHighlight;


 for var AIndex: integer := 0 to Pred(AStringList.Count) do
 begin
    if ARichEditor.FindFirst(Format('?%s?', [AStringList[AIndex]])) then
    begin
      ARichEditor.SetSelectionHighlight;
      while ARichEditor.FindNext do
        ARichEditor.SetSelectionHighlight;
    end;
  end;
  ARichEditor.ClearSelection;
  ARichEditor.SetCaret(ASel); 
  ARichEditor.CaretToSelection;


  ARichEditor.OnChange := RichEditorChange;

it is working, but for example TAB and Enter isn't working correctly anymore. What is wrong?
Best regards


I retested this here but I couldn't see an issue with tab & enter?
What exact issue do you experience?

After highlighting i can just tab & enter in the TAdvRichEditor as expected.
Did you set the Highlight methode to the RichEdit Change Event?



procedure TTest.RichEditor1Change(Sender: TObject);
begin
  inherited;
  HighlightPlaceholder(RichEditor1);
end;


So when I press enter and then type any letters, they are inserted to the first position of the line, not to the end, because the caret isn't jumping to the next position.

when I insert a TAB and I want to remove it then, it isn't working, like the key is discarded inernally.