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 -
This commit is contained in:
ondrej 2018-05-11 01:09:53 +00:00
parent c25de54334
commit f549ecc47d
2 changed files with 20 additions and 3 deletions

View File

@ -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;

View File

@ -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);