diff --git a/components/ideintf/srceditorintf.pas b/components/ideintf/srceditorintf.pas index 392a614c4c..a3bd835d45 100644 --- a/components/ideintf/srceditorintf.pas +++ b/components/ideintf/srceditorintf.pas @@ -270,6 +270,11 @@ type var AText: String; var AMode: TSemSelectionMode; ALogStartPos: TPoint; var AnAction: TSemCopyPasteAction) of object; + TSemBeautyFlag = ( + sembfNotBreakDots + ); + TSemBeautyFlags = set of TSemBeautyFlag; + { TSourceEditorManagerInterface } TSourceEditorManagerInterface = class(TComponent) @@ -319,7 +324,7 @@ type // Messages procedure ClearErrorLines; virtual; abstract; // General source functions - function Beautify(const Src: string): string; virtual; abstract; + function Beautify(const Src: string; const Flags: TSemBeautyFlags = []): string; virtual; abstract; protected // Completion Plugins function GetActiveCompletionPlugin: TSourceEditorCompletionPlugin; virtual; abstract; diff --git a/ide/sourceeditor.pp b/ide/sourceeditor.pp index 1523fe6bb1..88feac6e03 100644 --- a/ide/sourceeditor.pp +++ b/ide/sourceeditor.pp @@ -1109,7 +1109,7 @@ type procedure ClearExecutionMarks; procedure FillExecutionMarks; procedure ReloadEditorOptions; - function Beautify(const Src: string): string; override; + function Beautify(const Src: string; const Flags: TSemBeautyFlags = []): string; override; // find / replace text procedure FindClicked(Sender: TObject); procedure FindNextClicked(Sender: TObject); @@ -10286,20 +10286,36 @@ begin end; end; -function TSourceEditorManager.Beautify(const Src: string): string; +function TSourceEditorManager.Beautify(const Src: string; + const Flags: TSemBeautyFlags): string; var NewIndent, NewTabWidth: Integer; + Beauty: TBeautifyCodeOptions; + OldDoNotSplitLineInFront, OldDoNotSplitLineAfter: TAtomTypes; begin - Result:=CodeToolBoss.Beautifier.BeautifyStatement(Src,2,[bcfDoNotIndentFirstLine]); + Beauty:=CodeToolBoss.SourceChangeCache.BeautifyCodeOptions; + OldDoNotSplitLineInFront:=Beauty.DoNotSplitLineInFront; + OldDoNotSplitLineAfter:=Beauty.DoNotSplitLineAfter; + try + if sembfNotBreakDots in Flags then + begin + Include(Beauty.DoNotSplitLineInFront,atPoint); + Include(Beauty.DoNotSplitLineAfter,atPoint); + end; + Result:=CodeToolBoss.Beautifier.BeautifyStatement(Src,2,[bcfDoNotIndentFirstLine]); - if (eoTabsToSpaces in EditorOpts.SynEditOptions) - or (EditorOpts.BlockTabIndent=0) then - NewTabWidth:=0 - else - NewTabWidth:=EditorOpts.TabWidth; - NewIndent:=EditorOpts.BlockTabIndent*EditorOpts.TabWidth+EditorOpts.BlockIndent; + if (eoTabsToSpaces in EditorOpts.SynEditOptions) + or (EditorOpts.BlockTabIndent=0) then + NewTabWidth:=0 + else + NewTabWidth:=EditorOpts.TabWidth; + NewIndent:=EditorOpts.BlockTabIndent*EditorOpts.TabWidth+EditorOpts.BlockIndent; - Result:=BasicCodeTools.ReIndent(Result,2,0,NewIndent,NewTabWidth); + Result:=BasicCodeTools.ReIndent(Result,2,0,NewIndent,NewTabWidth); + finally + Beauty.DoNotSplitLineInFront:=OldDoNotSplitLineInFront; + Beauty.DoNotSplitLineAfter:=OldDoNotSplitLineAfter; + end; end; procedure TSourceEditorManager.FindClicked(Sender: TObject);