diff --git a/components/synedit/syngutter.pp b/components/synedit/syngutter.pp index 4cb7025eba..7f8a56e928 100644 --- a/components/synedit/syngutter.pp +++ b/components/synedit/syngutter.pp @@ -118,6 +118,7 @@ type FOnGutterClick: TGutterClickEvent; function GetGutterParts: TSynGutterPartList; procedure SetMarkupInfo(const AValue: TSynSelectedColor); + procedure SetRealWidth(const AValue: Integer); protected FWidth : integer; procedure SetAutoSize(const AValue : boolean); virtual; @@ -127,6 +128,7 @@ type property GutterParts: TSynGutterPartList read GetGutterParts; property Gutter: TSynGutter read FGutter; property SynEdit:TSynEditBase read FSynEdit; + property RealWidth: Integer write SetRealWidth; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -600,8 +602,10 @@ end; procedure TSynGutter.SetWidth(Value: integer); begin + if FAutoSize then + Value := RealGutterWidth(FTextDrawer.CharWidth); Value := Max(0, Value); - if (FWidth <> Value) and not FAutoSize then + if (FWidth <> Value) then begin FWidth := Value; DoChange(Self); @@ -728,6 +732,13 @@ begin FMarkupInfo.Assign(AValue); end; +procedure TSynGutterPartBase.SetRealWidth(const AValue: Integer); +begin + if FWidth = AValue then exit; + FWidth := AValue; + DoChange(self); +end; + procedure TSynGutterPartBase.SetAutoSize(const AValue : boolean); begin if FAutoSize=AValue then exit; diff --git a/components/synedit/syngutterchanges.pas b/components/synedit/syngutterchanges.pas index 389dd7bb08..375e932563 100644 --- a/components/synedit/syngutterchanges.pas +++ b/components/synedit/syngutterchanges.pas @@ -90,7 +90,7 @@ begin end; if AutoSize then - Width := 4; + RealWidth := 4; Result := Width; end; diff --git a/components/synedit/syngutterlinenumber.pp b/components/synedit/syngutterlinenumber.pp index a75c79871b..797486e3c6 100644 --- a/components/synedit/syngutterlinenumber.pp +++ b/components/synedit/syngutterlinenumber.pp @@ -136,7 +136,7 @@ begin end; if AutoSize then - FWidth := FAutoSizeDigitCount * CharWidth + 1; + RealWidth := FAutoSizeDigitCount * CharWidth + 1; Result := Width; end; @@ -153,8 +153,12 @@ begin FAutoSizeDigitCount := nDigits; DoChange(Self); end; - end else + end + else + if FAutoSizeDigitCount <> FDigitCount then begin FAutoSizeDigitCount := FDigitCount; + DoChange(Self); + end; end; function TSynGutterLineNumber.FormatLineNumber(Line: integer; IsDot: boolean): string;