From f549ecc47d69d6de575403645d21205ba976ec2f Mon Sep 17 00:00:00 2001 From: ondrej Date: Fri, 11 May 2018 01:09:53 +0000 Subject: [PATCH] IDE: fix jump point on file search result open (bug was: when opening result from a different file, the jump point in the new file was added and not the current one) git-svn-id: trunk@57895 - --- ide/main.pp | 14 +++++++++++--- ide/sourceeditor.pp | 9 +++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ide/main.pp b/ide/main.pp index 8aeb1d92fe..f9cd9f3f5d 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -8754,11 +8754,12 @@ function TMainIDE.DoJumpToSearchResult(FocusEditor: boolean): boolean; var AFileName: string; SearchedFilename: string; - LogCaretXY: TPoint; + LogCaretXY, JumpPointCaretXY: TPoint; OpenFlags: TOpenFlags; - SrcEdit: TSourceEditor; + SrcEdit, JumpPointEditor: TSourceEditor; AnUnitInfo: TUnitInfo; AnEditorInfo: TUnitEditorInfo; + JumpPointTopLine: Integer; begin Result:=false; AFileName:= SearchResultsView.GetSourceFileName; @@ -8773,6 +8774,12 @@ begin SearchedFilename := FindUnitFile(AFilename); end; if SearchedFilename<>'' then begin + JumpPointEditor := SourceEditorManager.ActiveEditor; + if JumpPointEditor<>nil then + begin + JumpPointCaretXY := JumpPointEditor.EditorComponent.LogicalCaretXY; + JumpPointTopLine := JumpPointEditor.EditorComponent.TopLine; + end; // open the file in the source editor AnUnitInfo := nil; if Project1<>nil then @@ -8787,7 +8794,8 @@ begin Result:=(DoOpenEditorFile(SearchedFilename,-1,-1,OpenFlags)=mrOk); if Result then begin // set caret position - SourceEditorManager.AddJumpPointClicked(Self); + if JumpPointEditor<>nil then + SourceEditorManager.AddCustomJumpPoint(JumpPointCaretXY, JumpPointTopLine, JumpPointEditor, True); SrcEdit:=SourceEditorManager.ActiveEditor; if LogCaretXY.Y>SrcEdit.EditorComponent.Lines.Count then LogCaretXY.Y:=SrcEdit.EditorComponent.Lines.Count; diff --git a/ide/sourceeditor.pp b/ide/sourceeditor.pp index 8e8c0e541b..06ae70c06b 100644 --- a/ide/sourceeditor.pp +++ b/ide/sourceeditor.pp @@ -1118,6 +1118,8 @@ type procedure JumpBackClicked(Sender: TObject); procedure JumpForwardClicked(Sender: TObject); procedure AddJumpPointClicked(Sender: TObject); + procedure AddCustomJumpPoint(ACaretXY: TPoint; ATopLine: integer; + AEditor: TSourceEditor; DeleteForwardHistory: boolean); procedure DeleteLastJumpPointClicked(Sender: TObject); procedure ViewJumpHistoryClicked(Sender: TObject); protected @@ -9746,6 +9748,13 @@ begin ActiveSourceWindow := Result; end; +procedure TSourceEditorManager.AddCustomJumpPoint(ACaretXY: TPoint; + ATopLine: integer; AEditor: TSourceEditor; DeleteForwardHistory: boolean); +begin + if Assigned(OnAddJumpPoint) then + OnAddJumpPoint(ACaretXY, ATopLine, AEditor, DeleteForwardHistory); +end; + function TSourceEditorManager.NewSourceWindow: TSourceNotebook; begin Result := CreateNewWindow(True);