mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 16:09:41 +02:00
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:
parent
c25de54334
commit
f549ecc47d
14
ide/main.pp
14
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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user