From ccbc12a16cfdfe3a35bab5c36cbe68bfa5c03ee7 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 30 Mar 2024 11:15:00 +0100 Subject: [PATCH] blame, add early exit for when the initial data are not yet collected --- src/u_blame.pas | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/u_blame.pas b/src/u_blame.pas index 4d2c7b74..e5d72099 100644 --- a/src/u_blame.pas +++ b/src/u_blame.pas @@ -1,6 +1,6 @@ unit u_blame; -{$mode ObjFPC}{$H+} +{$I u_defines.inc} interface @@ -450,7 +450,7 @@ end; procedure TBlameWidget.btnCpyPrevHashClick(Sender: TObject); begin - if fDocData.isAssigned and fDoc.isAssigned then + if fDocData.isAssigned and (length(fDocData.lineData) <> 0) and fDoc.isAssigned then Clipboard.AsText := fDocData.lineData[fDoc.CaretY-1].hash; end; @@ -462,7 +462,7 @@ end; procedure TBlameWidget.btnLogPrevClick(Sender: TObject); begin - if fDocData.isAssigned and fDoc.isAssigned then + if fDocData.isAssigned and (length(fDocData.lineData) <> 0) and fDoc.isAssigned then showLog(fDocData.lineData[fDoc.CaretY-1].hash); end; @@ -470,11 +470,14 @@ procedure TBlameWidget.showLog(const hash: string); var p: TProcess; g: TStringList; + n: string = ''; begin + if not checkTool(n) or hash.isEmpty() or (hash = 'HEAD') then + exit; p := TProcess.Create(nil); g := TStringList.Create; try - p.Executable := exeFullName('git' + exeExt); + p.Executable := n; p.Options := [poUsePipes, poNoConsole]; p.ShowWindow := swoHIDE; p.CurrentDirectory:= getGitCwd();