From 482124d17eb541bdeebd384b43ed59cd873ca039 Mon Sep 17 00:00:00 2001 From: DomingoGP Date: Sun, 9 Mar 2025 10:23:01 +0100 Subject: [PATCH] Jedi code format: refactor, extract function FormatIncludeFile --- .../jcf2/IdePlugin/lazarus/jcfidemain.pas | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/components/jcf2/IdePlugin/lazarus/jcfidemain.pas b/components/jcf2/IdePlugin/lazarus/jcfidemain.pas index ba3d12b377..bc4e10939e 100644 --- a/components/jcf2/IdePlugin/lazarus/jcfidemain.pas +++ b/components/jcf2/IdePlugin/lazarus/jcfidemain.pas @@ -72,6 +72,7 @@ type constructor Create; destructor Destroy; override; + procedure FormatIncludeFile(srcEditor: TSourceEditorInterface); procedure DoFormatSelection(Sender: TObject); procedure DoFormatIncludeFile(Sender: TObject); procedure DoFormatCurrentIDEWindow(Sender: TObject); @@ -378,19 +379,22 @@ begin end; procedure TJcfIdeMain.DoFormatIncludeFile(Sender: TObject); +begin + if (SourceEditorManagerIntf = nil) or (SourceEditorManagerIntf.ActiveEditor = nil) then + begin + LogIdeMessage('', 'No current window', mtInputError, -1, -1); + Exit; + end; + FormatIncludeFile(SourceEditorManagerIntf.ActiveEditor); +end; + +procedure TJcfIdeMain.FormatIncludeFile(srcEditor: TSourceEditorInterface); var - srcEditor: TSourceEditorInterface; sourceCode: string; BlockBegin, BlockEnd: TPoint; fcConverter: TConverter; outputstr: string; begin - if (SourceEditorManagerIntf = nil) or (SourceEditorManagerIntf.ActiveEditor = nil) then - begin - LogIdeMessage('', 'No current window', mtInputError, -1, -1); - exit; - end; - srcEditor := SourceEditorManagerIntf.ActiveEditor; if srcEditor.ReadOnly then Exit; sourceCode := srcEditor.GetText(False); //get ALL editor text.