anchor.diff:  
       Result:= true;
     end;
  -  Ed.Strings.EndUndoGroup;
  +  St.EndUndoGroup;
   
     if Result then
     begin
       Ed.Modified:= true;
  +    Ed.DoEventChange(NLineChanged);
       Ed.Update(true);
     end;
   end;
  
positive.code:       bQuoteChar:= false;
    end;
  
    //make additional loop, to detect that ALL carets need pairing.
    //if at least one caret doesn't need, stop.
    //it's needed to make pair for all or nothing. issue #3219.
    for NCaret:= Ed.Carets.Count-1 downto 0 do
    begin
      Caret:= Ed.Carets[NCaret];
      if not Ed.Strings.IsIndexValid(Caret.PosY) then Continue;
      if Caret.EndY<0 then
        if not EditorAutoCloseBracket_NeedPair(Ed, Caret, bQuoteChar) then
          exit;
  
negative.code:     end
      else
      begin
        St.TextInsert(X2, Y2, CharEnd, false, Shift, PosAfter);
        Ed.DoCaretsShift(NCaret, X2, Y2, Shift.X, Shift.Y, PosAfter);
  
        St.TextInsert(X1, Y1, CharBegin, false, Shift, PosAfter);
        Ed.DoCaretsShift(NCaret, X1, Y1, Shift.X, Shift.Y, PosAfter);
  
        Caret.EndX:= X1+1;
  