From fd5a10c132313e64fcc51da9c7d6b68452451f8b Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 29 Jun 2010 16:42:32 +0000 Subject: [PATCH] codeexplorer: CodeExplorerView.FindCodeTVNodeAtCleanPos: find deepest node git-svn-id: trunk@26326 - --- ide/codeexplorer.pas | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ide/codeexplorer.pas b/ide/codeexplorer.pas index 282bcece77..ab328ec101 100644 --- a/ide/codeexplorer.pas +++ b/ide/codeexplorer.pas @@ -1990,6 +1990,8 @@ var KeyPos: integer; AVLNode: TAvgLvlTreeNode; Node: TTreeNode; + NodeData: TViewNodeData; + BestData: TViewNodeData; begin Result:=nil; if (fLastCodeTool=nil) or (not FLastCodeValid) or (CodeTreeview=nil) @@ -1997,10 +1999,23 @@ begin KeyPos:=CleanPos; AVLNode:=fCodeSortedForStartPos.FindLeftMostKey(@KeyPos, TListSortCompare(@CompareStartPosWithViewNodeData)); - if AVLNode=nil then exit; - Node:=TTreeNode(AVLNode.Data); - // ToDo: find the shortest - Result:=Node; + // find the shortest + BestData:=nil; + Result:=nil; + while AVLNode<>nil do begin + Node:=TTreeNode(AVLNode.Data); + if TObject(Node.Data) is TViewNodeData then begin + NodeData:=TViewNodeData(Node.Data); + if (BestData=nil) + or ((BestData.StartPos<=NodeData.StartPos) + and (BestData.EndPos>=NodeData.EndPos)) + then begin + Result:=Node; + BestData:=TViewNodeData(Node.Data); + end; + end; + AVLNode:=fCodeSortedForStartPos.FindSuccessor(AVLNode); + end; end; procedure TCodeExplorerView.BuildCodeSortedForStartPos;