Skip to content

Commit

Permalink
exception shouldn't trown if rg path not found
Browse files Browse the repository at this point in the history
  • Loading branch information
mattia72 committed Feb 9, 2025
1 parent aa33e36 commit c1fbbe1
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/UI/RipGrepper.UI.MiddleFrame.pas
Original file line number Diff line number Diff line change
Expand Up @@ -911,32 +911,40 @@ procedure TRipGrepperMiddleFrame.RunRipGrep;
workDir : string;
args : TStrings;
argsArrs : TStringsArrayEx;
rgPath: string;
begin
rgPath := Settings.RipGrepParameters.RipGrepPath;
if not FileExists(rgPath) then begin
TAsyncMsgBox.ShowError(Format(FORMAT_RIPGREP_EXE_NOT_FOUND, [Settings.IniFile.FileName]));
Exit;
end;

FRipGrepTask := TTask.Create(
procedure()
begin
if not FileExists(Settings.RipGrepParameters.RipGrepPath) then begin
TAsyncMsgBox.ShowError(Format(FORMAT_RIPGREP_EXE_NOT_FOUND, [Settings.IniFile.FileName]));
end;

workDir := TDirectory.GetCurrentDirectory();
TDebugUtils.DebugMessage('TRipGrepperMiddleFrame.RunRipGrep: run: ' + Settings.RipGrepParameters.RipGrepPath + ' '
TDebugUtils.DebugMessage('TRipGrepperMiddleFrame.RunRipGrep: run: ' + rgPath + ' '
{ } + Settings.RipGrepParameters.RipGrepArguments.DelimitedText);
FswSearchStart := TStopwatch.StartNew;
args := TStringList.Create;
try
argsArrs := SliceArgs(Settings.RipGrepParameters);
for var i := 0 to argsArrs.MaxIndex do begin
for var i := 0 to argsArrs.MaxIndex do begin
args.Clear;
args.AddStrings(argsArrs[i]);
if i < argsArrs.MaxIndex then begin
FHistItemObj.RipGrepResult := TProcessUtils.RunProcess(Settings.RipGrepParameters.RipGrepPath, args,
// if cmd line is too long, we slice it and run in separate processes...
FHistItemObj.RipGrepResult := TProcessUtils.RunProcess(
{ } rgPath,
{ } args,
{ } workDir,
{ } self as INewLineEventHandler,
{ } self as ITerminateEventProducer,
{ } nil);
end else begin
FHistItemObj.RipGrepResult := TProcessUtils.RunProcess(Settings.RipGrepParameters.RipGrepPath, args,
FHistItemObj.RipGrepResult := TProcessUtils.RunProcess(
{ } rgPath,
{ } args,
{ } workDir,
{ } self as INewLineEventHandler,
{ } self as ITerminateEventProducer,
Expand Down

0 comments on commit c1fbbe1

Please sign in to comment.