//ecSyntMemo.pas

  TSyntaxMemoOptionEx = (soSmartPaste, soUseCaseFormat, soAutoFormat, soKeepSearchMarks,
                         soExtractAnsiParts, soCorrectNonPrinted, soVirtualCaretPos,
                         soUnlimitedCaretPos, soNormalSelToLineEnd, soRightClickMoveCaret,
                         soDisableAutoClose, soAllowZeroTab, soNotSuppressAltNNNN,
                         eoShowCaretWhenUnfocused, soKeepCaretPaste,
                         soAllowSelectByWords, soSimplifiedUndo//AT
                         );
                         
procedure TCustomSyntaxMemo.Undo;
var aPos, N, uPos: integer;
    isGrp: Boolean;
begin
    if not CanUndo then Exit;

    BeginUpdate;
    try
        if not (soSimplifiedUndo in FOptionsEx) then
        begin
          aPos := CaretStrPos;
          uPos := TUndoRec(Lines.UndoList[Lines.UndoList.Count - Lines.RedoCount - 1]).PostPos(TextLength);
          if uPos <> aPos then begin
              CaretStrPos := uPos;
              Exit;
          end;
        end;

        with Lines do
        .....
        