If you delete a line and then insert a new line into TSynMemo how do you update the UndoList and RedoList so that the change can be undone with SynMemo.Undo?
SynMemo1.BeginUpdate;
iLineIndex := SynMemo1.Lines.IndexOf( SynMemo1.LineText );
SynMemo1.Lines.Delete( iLineIndex );
iStartTag := SourceStyleComboBox1.CurText;
iEndTag := SourceStyleComboBox1.CurText;
System.Insert( '/', iEndTag, 2 );
iHTML := iStartTag + iElement + iEndTag;
SynMemo1.Lines.Insert( iLineIndex, iHTML );
SynMemo1.EndUpdate;
EDIT I tried this but undo and redo does not work correctly... what I mean by this is after an undo the line is not restored to what it was before the actions.
StartOfBlock.Line := SynMemo1.CaretY;
StartOfBlock.Char := 0;
EndOfBlock.Line := SynMemo1.CaretY;
EndOfBlock.Char := Length( iHTML );
SynMemo1.UndoList.BeginBlock;
SynMemo1.UndoList.AddChange(crInsert, StartOfBlock, EndOfBlock, iHTML, smNormal);
SynMemo1.UndoList.EndBlock;
SynMemo1.RedoList.BeginBlock;
SynMemo1.RedoList.AddChange(crInsert, StartOfBlock, EndOfBlock, iHTML, smNormal);
SynMemo1.RedoList.EndBlock;
I can not find any guidance about setting the StartOfBlock and EdifOfBlock parameters. The two "actions" should be combined so that there is only one undo and redo for the "combined" action - "Insert and Delete" with option eoGroupUndo = True.