anchor.diff:  function EditorFindHtmlLastOpenedTagInText(const AText: UnicodeString): string;
   var
     tags: TEditorHtmlTagList;
  +  tagPtr, tagPtr2: PEditorHtmlTagRecord;
     i, j: integer;
   begin
     Result:= '';
  
positive.code:     //delete pairs <tag> - </tag>
      for i:= tags.Count-1 downto 0 do
      begin
        if not tags[i].bClosing then
          for j:= i+1 to tags.Count-1 do
            if tags[j].bClosing and SameText(tags[i].sTagName, tags[j].sTagName) then
            begin
              tags.Delete(j);
              tags.Delete(i);
              Break;
            end;
      end;
  
      //take last opened tag
      for i:= tags.Count-1 downto 0 do
        if not tags[i].bClosing then
        begin
          Result:= tags[i].sTagName;
          Break
        end;
    finally
      FreeAndNil(tags);
    end;
  
negative.code: end;
  
  type
    { TEditorHtmlTagRecord }
  
    PEditorHtmlTagRecord = ^TEditorHtmlTagRecord;
    TEditorHtmlTagRecord = record
      bClosing: boolean;
      sTagName: string[30];
      class operator =(const a, b: TEditorHtmlTagRecord): boolean;
    end;
  
    { TEditorHtmlTagList }
  
    TEditorHtmlTagList = class(specialize TFPGList<TEditorHtmlTagRecord>)
    public
      function ItemPtr(AIndex: integer): PEditorHtmlTagRecord;
    end;
  
  procedure EditorFindHtmlTagsInText(const AText: UnicodeString;
    AList: TEditorHtmlTagList; AllowSingletonTags: boolean);
  