mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 18:59:32 +02:00
IDE: Fix minor bugs in SearchResultView. Issue #40334, patch by n7800.
This commit is contained in:
parent
c5cddde52e
commit
5821b61cdc
@ -582,7 +582,6 @@ begin
|
|||||||
// create a search result page
|
// create a search result page
|
||||||
//debugln(['ShowIdentifierReferences ',DbgSName(SearchResultsView)]);
|
//debugln(['ShowIdentifierReferences ',DbgSName(SearchResultsView)]);
|
||||||
SearchPageIndex:=SearchResultsView.AddSearch(
|
SearchPageIndex:=SearchResultsView.AddSearch(
|
||||||
'Ref: '+Identifier,
|
|
||||||
Identifier,
|
Identifier,
|
||||||
'',
|
'',
|
||||||
ExtractFilePath(DeclarationCode.Filename),
|
ExtractFilePath(DeclarationCode.Filename),
|
||||||
@ -596,11 +595,11 @@ begin
|
|||||||
TreeOfPCodeXYPosition,true,SearchPageIndex.PageIndex);
|
TreeOfPCodeXYPosition,true,SearchPageIndex.PageIndex);
|
||||||
OldSearchPageIndex:=SearchPageIndex;
|
OldSearchPageIndex:=SearchPageIndex;
|
||||||
SearchPageIndex:=nil;
|
SearchPageIndex:=nil;
|
||||||
SearchResultsView.EndUpdate(OldSearchPageIndex.PageIndex);
|
SearchResultsView.EndUpdate(OldSearchPageIndex.PageIndex, 'Ref: '+Identifier);
|
||||||
IDEWindowCreators.ShowForm(SearchResultsView,true);
|
IDEWindowCreators.ShowForm(SearchResultsView,true);
|
||||||
finally
|
finally
|
||||||
if SearchPageIndex <> nil then
|
if SearchPageIndex <> nil then
|
||||||
SearchResultsView.EndUpdate(SearchPageIndex.PageIndex);
|
SearchResultsView.EndUpdate(SearchPageIndex.PageIndex, 'Ref: '+Identifier);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -10567,7 +10567,6 @@ begin
|
|||||||
// create a search result page
|
// create a search result page
|
||||||
//debugln(['ShowIdentifierReferences ',DbgSName(SearchResultsView)]);
|
//debugln(['ShowIdentifierReferences ',DbgSName(SearchResultsView)]);
|
||||||
SearchPageIndex:=SearchResultsView.AddSearch(
|
SearchPageIndex:=SearchResultsView.AddSearch(
|
||||||
'Ref: '+ExtractFileName(UsedUnitFilename),
|
|
||||||
UsedUnitFilename,
|
UsedUnitFilename,
|
||||||
'',
|
'',
|
||||||
ExtractFilePath(UsedUnitFilename),
|
ExtractFilePath(UsedUnitFilename),
|
||||||
@ -10597,7 +10596,7 @@ begin
|
|||||||
|
|
||||||
OldSearchPageIndex:=SearchPageIndex;
|
OldSearchPageIndex:=SearchPageIndex;
|
||||||
SearchPageIndex:=nil;
|
SearchPageIndex:=nil;
|
||||||
SearchResultsView.EndUpdate(OldSearchPageIndex.PageIndex);
|
SearchResultsView.EndUpdate(OldSearchPageIndex.PageIndex, 'Ref: '+ExtractFileName(UsedUnitFilename));
|
||||||
IDEWindowCreators.ShowForm(SearchResultsView,true);
|
IDEWindowCreators.ShowForm(SearchResultsView,true);
|
||||||
|
|
||||||
finally
|
finally
|
||||||
|
@ -989,15 +989,13 @@ end;
|
|||||||
procedure TSearchProgressForm.DoSearchAndAddToSearchResults;
|
procedure TSearchProgressForm.DoSearchAndAddToSearchResults;
|
||||||
var
|
var
|
||||||
ListPage: TTabSheet;
|
ListPage: TTabSheet;
|
||||||
Cnt: integer;
|
|
||||||
State: TIWGetFormState;
|
State: TIWGetFormState;
|
||||||
begin
|
begin
|
||||||
Cnt:= 0;
|
|
||||||
LazarusIDE.DoShowSearchResultsView(iwgfShow);
|
LazarusIDE.DoShowSearchResultsView(iwgfShow);
|
||||||
if fResultsPageIndex >= 0 then
|
if fResultsPageIndex >= 0 then
|
||||||
ListPage := SearchResultsView.GetResultsPage(fResultsPageIndex)
|
ListPage := SearchResultsView.GetResultsPage(fResultsPageIndex)
|
||||||
else
|
else
|
||||||
ListPage := SearchResultsView.AddSearch(SearchText, SearchText, ReplaceText,
|
ListPage := SearchResultsView.AddSearch(SearchText, ReplaceText,
|
||||||
SearchDirectories, SearchMask, SearchOptions);
|
SearchDirectories, SearchMask, SearchOptions);
|
||||||
try
|
try
|
||||||
(* BeginUpdate prevents ListPage from being closed,
|
(* BeginUpdate prevents ListPage from being closed,
|
||||||
@ -1008,21 +1006,20 @@ begin
|
|||||||
ResultsWindow:= ListPage;
|
ResultsWindow:= ListPage;
|
||||||
try
|
try
|
||||||
Show; // floating window, not dockable
|
Show; // floating window, not dockable
|
||||||
Cnt:= DoSearch;
|
DoSearch;
|
||||||
except
|
except
|
||||||
on E: ERegExpr do
|
on E: ERegExpr do
|
||||||
IDEMessageDialog(lisUEErrorInRegularExpression, E.Message,mtError,
|
IDEMessageDialog(lisUEErrorInRegularExpression, E.Message,mtError,
|
||||||
[mbCancel]);
|
[mbCancel]);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
SearchResultsView.SetPageFoundCount(ListPage, Cnt);
|
|
||||||
// show, but bring to front only if Search Progress dialog was active
|
// show, but bring to front only if Search Progress dialog was active
|
||||||
if fWasActive then
|
if fWasActive then
|
||||||
State := iwgfShowOnTop
|
State := iwgfShowOnTop
|
||||||
else
|
else
|
||||||
State := iwgfShow;
|
State := iwgfShow;
|
||||||
LazarusIDE.DoShowSearchResultsView(State);
|
LazarusIDE.DoShowSearchResultsView(State);
|
||||||
SearchResultsView.EndUpdate(ListPage.PageIndex);
|
SearchResultsView.EndUpdate(ListPage.PageIndex, SearchText);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -246,8 +246,7 @@ type
|
|||||||
procedure UpdateShowing; override;
|
procedure UpdateShowing; override;
|
||||||
property AsyncUpdateCloseButtons: TSVCloseButtonsState read FAsyncUpdateCloseButtons write SetAsyncUpdateCloseButtons;
|
property AsyncUpdateCloseButtons: TSVCloseButtonsState read FAsyncUpdateCloseButtons write SetAsyncUpdateCloseButtons;
|
||||||
public
|
public
|
||||||
function AddSearch(const aResultsName: string;
|
function AddSearch(const aSearchText: string;
|
||||||
const aSearchText: string;
|
|
||||||
const aReplaceText: string;
|
const aReplaceText: string;
|
||||||
const aDirectories: string;
|
const aDirectories: string;
|
||||||
const aFileMask: string;
|
const aFileMask: string;
|
||||||
@ -261,7 +260,7 @@ type
|
|||||||
const TheText: string;
|
const TheText: string;
|
||||||
const MatchStart: integer; const MatchLen: integer);
|
const MatchStart: integer; const MatchLen: integer);
|
||||||
procedure BeginUpdate(APageIndex: integer);
|
procedure BeginUpdate(APageIndex: integer);
|
||||||
procedure EndUpdate(APageIndex: integer);
|
procedure EndUpdate(APageIndex: integer; APageName: string = '');
|
||||||
procedure Parse_Search_Phrases(var slPhrases: TStrings);
|
procedure Parse_Search_Phrases(var slPhrases: TStrings);
|
||||||
procedure ClosePage(PageIndex: integer);
|
procedure ClosePage(PageIndex: integer);
|
||||||
|
|
||||||
@ -271,7 +270,6 @@ type
|
|||||||
write fOnSelectionChanged;
|
write fOnSelectionChanged;
|
||||||
property Items[Index: integer]: TStrings read GetItems write SetItems;
|
property Items[Index: integer]: TStrings read GetItems write SetItems;
|
||||||
function GetResultsPage(aIndex: integer): TTabSheet;
|
function GetResultsPage(aIndex: integer): TTabSheet;
|
||||||
procedure SetPageFoundCount(aPage: TTabSheet; aCnt: integer);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -588,12 +586,16 @@ begin
|
|||||||
TCustomTreeView(lTree).BeginUpdate; // TCustomTreeView, but not TLazSearchResultTV!
|
TCustomTreeView(lTree).BeginUpdate; // TCustomTreeView, but not TLazSearchResultTV!
|
||||||
try
|
try
|
||||||
lNode := lTree.Selected;
|
lNode := lTree.Selected;
|
||||||
lNodeText := lNode.Text;
|
lNodeText := '';
|
||||||
lOldScroll.X := lTree.ScrolledLeft;
|
if lNode <> nil then
|
||||||
lOldScroll.Y := lTree.ScrolledTop;
|
begin
|
||||||
lTree.MoveEnd;
|
lNodeText := lNode.Text;
|
||||||
lNode.MakeVisible;
|
lOldScroll.X := lTree.ScrolledLeft;
|
||||||
lDeltaScrollY := lTree.ScrolledTop - lOldScroll.Y;
|
lOldScroll.Y := lTree.ScrolledTop;
|
||||||
|
lTree.MoveEnd;
|
||||||
|
lNode.MakeVisible;
|
||||||
|
lDeltaScrollY := lTree.ScrolledTop - lOldScroll.Y;
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
lTree.ScrolledTop := lOldScroll.Y; // go back while searching
|
lTree.ScrolledTop := lOldScroll.Y; // go back while searching
|
||||||
TCustomTreeView(lTree).EndUpdate;
|
TCustomTreeView(lTree).EndUpdate;
|
||||||
@ -915,10 +917,12 @@ begin
|
|||||||
UpdateToolbar;
|
UpdateToolbar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSearchResultsView.EndUpdate(APageIndex: integer);
|
procedure TSearchResultsView.EndUpdate(APageIndex: integer; APageName: string = '');
|
||||||
var
|
var
|
||||||
lTree: TLazSearchResultTV;
|
lTree: TLazSearchResultTV;
|
||||||
lNode: TTreeNode;
|
lNode: TTreeNode;
|
||||||
|
lPage: TTabSheet;
|
||||||
|
lEllipsed: boolean;
|
||||||
begin
|
begin
|
||||||
lTree := GetTreeView(APageIndex);
|
lTree := GetTreeView(APageIndex);
|
||||||
if assigned(lTree) then
|
if assigned(lTree) then
|
||||||
@ -938,6 +942,17 @@ begin
|
|||||||
if lNode <> nil then
|
if lNode <> nil then
|
||||||
lNode.Selected := true;
|
lNode.Selected := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Page name
|
||||||
|
lPage := GetResultsPage(APageIndex); // this also check APageIndex range
|
||||||
|
if (lPage <> nil) and (APageName <> '') then
|
||||||
|
begin
|
||||||
|
lPage.Caption := BeautifyPageName(APageName, lEllipsed);
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Count
|
||||||
|
lPage.Caption := lPage.Caption + ' (' + inttostr(lTree.Items.Count - lTree.Items.TopLvlCount) + ')';
|
||||||
|
|
||||||
UpdateToolbar;
|
UpdateToolbar;
|
||||||
if FFocusTreeViewInEndUpdate and assigned(lTree) then
|
if FFocusTreeViewInEndUpdate and assigned(lTree) then
|
||||||
ActivateControl(lTree)
|
ActivateControl(lTree)
|
||||||
@ -1005,11 +1020,6 @@ begin
|
|||||||
Result := nil;
|
Result := nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSearchResultsView.SetPageFoundCount(aPage: TTabSheet; aCnt: integer);
|
|
||||||
begin
|
|
||||||
aPage.Caption := aPage.Caption + Format(' (%d)',[aCnt]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{Sets the Items from the treeview on the currently selected page in the TNoteBook}
|
{Sets the Items from the treeview on the currently selected page in the TNoteBook}
|
||||||
procedure TSearchResultsView.SetItems(Index: Integer; Value: TStrings);
|
procedure TSearchResultsView.SetItems(Index: Integer; Value: TStrings);
|
||||||
var
|
var
|
||||||
@ -1230,7 +1240,6 @@ end;
|
|||||||
{ Add Result will create a tab in the Results view window with an new
|
{ Add Result will create a tab in the Results view window with an new
|
||||||
treeview or focus an existing TreeView and update it's searchoptions.}
|
treeview or focus an existing TreeView and update it's searchoptions.}
|
||||||
function TSearchResultsView.AddSearch(
|
function TSearchResultsView.AddSearch(
|
||||||
const aResultsName: string;
|
|
||||||
const aSearchText: string;
|
const aSearchText: string;
|
||||||
const aReplaceText: string;
|
const aReplaceText: string;
|
||||||
const aDirectories: string;
|
const aDirectories: string;
|
||||||
@ -1247,7 +1256,7 @@ begin
|
|||||||
with ResultsNoteBook do
|
with ResultsNoteBook do
|
||||||
begin
|
begin
|
||||||
FFocusTreeViewInEndUpdate := (ActivePage = nil) and SearchInListEdit.IsParentOf(ActivePage);
|
FFocusTreeViewInEndUpdate := (ActivePage = nil) and SearchInListEdit.IsParentOf(ActivePage);
|
||||||
FWorkedSearchText := BeautifyPageName(aResultsName, lTabEllipsed);
|
FWorkedSearchText := BeautifyPageName(aSearchText, lTabEllipsed); // default page name
|
||||||
PageIndex := TCustomTabControl(ResultsNoteBook).Pages.Add(FWorkedSearchText);
|
PageIndex := TCustomTabControl(ResultsNoteBook).Pages.Add(FWorkedSearchText);
|
||||||
|
|
||||||
lNewTree := TLazSearchResultTV.Create(Page[PageIndex]);
|
lNewTree := TLazSearchResultTV.Create(Page[PageIndex]);
|
||||||
@ -1564,9 +1573,7 @@ var
|
|||||||
lPage: TTabSheet;
|
lPage: TTabSheet;
|
||||||
begin
|
begin
|
||||||
result := nil;
|
result := nil;
|
||||||
if not InRange(APageIndex, 0, ResultsNoteBook.PageCount - 1) then exit;
|
lPage := GetResultsPage(APageIndex); // this also check APageIndex range
|
||||||
|
|
||||||
lPage := ResultsNoteBook.Pages[APageIndex];
|
|
||||||
if not assigned(lPage) then exit;
|
if not assigned(lPage) then exit;
|
||||||
|
|
||||||
for i:= 0 to lPage.ComponentCount - 1 do
|
for i:= 0 to lPage.ComponentCount - 1 do
|
||||||
|
Loading…
Reference in New Issue
Block a user