IDE: code explorer: clear when no source editor shown, bug #29050

git-svn-id: trunk@50559 -
This commit is contained in:
mattias 2015-12-02 10:51:02 +00:00
parent 9f61b39bd4
commit 26910afd1e
3 changed files with 45 additions and 19 deletions

View File

@ -198,6 +198,8 @@ type
ImgIDUnit: Integer; ImgIDUnit: Integer;
ImgIDVariable: Integer; ImgIDVariable: Integer;
ImgIDHint: Integer; ImgIDHint: Integer;
procedure ClearCodeTreeView;
procedure ClearDirectivesTreeView;
function GetCodeFilter: string; function GetCodeFilter: string;
function GetCurrentPage: TCodeExplorerPage; function GetCurrentPage: TCodeExplorerPage;
function GetDirectivesFilter: string; function GetDirectivesFilter: string;
@ -594,7 +596,19 @@ begin
if not (cevCheckOnIdle in FFlags) then exit; if not (cevCheckOnIdle in FFlags) then exit;
if (Screen.ActiveCustomForm<>nil) if (Screen.ActiveCustomForm<>nil)
and (fsModal in Screen.ActiveCustomForm.FormState) then and (fsModal in Screen.ActiveCustomForm.FormState) then
begin
// do not update while a modal form is shown, except for clear
if SourceEditorManagerIntf=nil then exit;
if SourceEditorManagerIntf.SourceEditorCount=0 then
begin
Exclude(FFlags,cevCheckOnIdle);
FLastCodeValid:=false;
ClearCodeTreeView;
FDirectivesFilename:='';
ClearDirectivesTreeView;
end;
exit; exit;
end;
if not IsVisible then exit; if not IsVisible then exit;
Exclude(FFlags,cevCheckOnIdle); Exclude(FFlags,cevCheckOnIdle);
case CurrentPage of case CurrentPage of
@ -807,6 +821,25 @@ begin
Result:=CodeFilterEdit.Text; Result:=CodeFilterEdit.Text;
end; end;
procedure TCodeExplorerView.ClearCodeTreeView;
var
f: TCEObserverCategory;
c: TCodeExplorerCategory;
begin
for c:=low(TCodeExplorerCategory) to high(TCodeExplorerCategory) do
fCategoryNodes[c]:=nil;
fObserverNode:=nil;
for f:=low(TCEObserverCategory) to high(TCEObserverCategory) do
fObserverCatNodes[f]:=nil;
fSurroundingNode:=nil;
CodeTreeview.Items.Clear;
end;
procedure TCodeExplorerView.ClearDirectivesTreeView;
begin
DirectivesTreeView.Items.Clear;
end;
function TCodeExplorerView.GetCurrentPage: TCodeExplorerPage; function TCodeExplorerView.GetCurrentPage: TCodeExplorerPage;
begin begin
if MainNotebook.ActivePage=CodePage then if MainNotebook.ActivePage=CodePage then
@ -2035,8 +2068,6 @@ procedure TCodeExplorerView.RefreshCode(OnlyVisible: boolean);
var var
OldExpanded: TTreeNodeExpandedState; OldExpanded: TTreeNodeExpandedState;
ACodeTool: TCodeTool; ACodeTool: TCodeTool;
c: TCodeExplorerCategory;
f: TCEObserverCategory;
SrcEdit: TSourceEditorInterface; SrcEdit: TSourceEditorInterface;
Filename: String; Filename: String;
Code: TCodeBuffer; Code: TCodeBuffer;
@ -2142,14 +2173,8 @@ begin
if not CurFollowNode then if not CurFollowNode then
OldExpanded:=TTreeNodeExpandedState.Create(CodeTreeView); OldExpanded:=TTreeNodeExpandedState.Create(CodeTreeView);
for c:=low(TCodeExplorerCategory) to high(TCodeExplorerCategory) do ClearCodeTreeView;
fCategoryNodes[c]:=nil;
fObserverNode:=nil;
for f:=low(TCEObserverCategory) to high(TCEObserverCategory) do
fObserverCatNodes[f]:=nil;
fSurroundingNode:=nil;
CodeTreeview.Items.Clear;
if (ACodeTool<>nil) and (ACodeTool.Tree<>nil) and (ACodeTool.Tree.Root<>nil) if (ACodeTool<>nil) and (ACodeTool.Tree<>nil) and (ACodeTool.Tree.Root<>nil)
then begin then begin
CreateIdentifierNodes(ACodeTool,ACodeTool.Tree.Root,nil,nil,true); CreateIdentifierNodes(ACodeTool,ACodeTool.Tree.Root,nil,nil,true);
@ -2251,12 +2276,10 @@ begin
DirectivesTreeView.BeginUpdate; DirectivesTreeView.BeginUpdate;
OldExpanded:=TTreeNodeExpandedState.Create(DirectivesTreeView); OldExpanded:=TTreeNodeExpandedState.Create(DirectivesTreeView);
if (ADirectivesTool=nil) or (ADirectivesTool.Tree=nil) ClearDirectivesTreeView;
or (ADirectivesTool.Tree.Root=nil) then if (ADirectivesTool<>nil) and (ADirectivesTool.Tree<>nil)
and (ADirectivesTool.Tree.Root<>nil) then
begin begin
DirectivesTreeView.Items.Clear;
end else begin
DirectivesTreeView.Items.Clear;
CreateDirectiveNodes(ADirectivesTool,ADirectivesTool.Tree.Root,nil,nil,true); CreateDirectiveNodes(ADirectivesTool,ADirectivesTool.Tree.Root,nil,nil,true);
end; end;

View File

@ -10661,8 +10661,8 @@ end;
procedure TMainIDE.OnSrcNotebookCurCodeBufferChanged(Sender: TObject); procedure TMainIDE.OnSrcNotebookCurCodeBufferChanged(Sender: TObject);
begin begin
if SourceEditorManager.SourceEditorCount = 0 then Exit; if CodeExplorerView<>nil then
if CodeExplorerView<>nil then CodeExplorerView.CurrentCodeBufferChanged; CodeExplorerView.CurrentCodeBufferChanged;
end; end;
procedure TMainIDE.OnSrcNotebookShowHintForSource(SrcEdit: TSourceEditor; procedure TMainIDE.OnSrcNotebookShowHintForSource(SrcEdit: TSourceEditor;

View File

@ -7284,9 +7284,12 @@ var
begin begin
// Todo: Move to manager, include window changes // Todo: Move to manager, include window changes
SrcEdit:=GetActiveSE; SrcEdit:=GetActiveSE;
if SrcEdit = nil then Exit; if SrcEdit <> nil then
if FLastCodeBuffer=SrcEdit.CodeBuffer then exit; begin
FLastCodeBuffer:=SrcEdit.CodeBuffer; if FLastCodeBuffer=SrcEdit.CodeBuffer then exit;
FLastCodeBuffer:=SrcEdit.CodeBuffer;
end else if FLastCodeBuffer=nil then
exit;
if assigned(Manager) and Assigned(Manager.OnCurrentCodeBufferChanged) then if assigned(Manager) and Assigned(Manager.OnCurrentCodeBufferChanged) then
Manager.OnCurrentCodeBufferChanged(Self); Manager.OnCurrentCodeBufferChanged(Self);
end; end;