diff --git a/editor/kn_LinksMng.pas b/editor/kn_LinksMng.pas index c541d07..d8089b7 100644 --- a/editor/kn_LinksMng.pas +++ b/editor/kn_LinksMng.pas @@ -90,6 +90,7 @@ interface var _Executing_History_Jump : boolean; + _Executing_JumpToKNTLocation_ToOtherNote : boolean; _LastMoveWasHistory : boolean; @@ -1281,36 +1282,44 @@ function DeleteBookmark09 (Location: TLocation): boolean; end; GetTreeNodeFromLocation(Location, myNote, myTreeNode); - // if not current note, switch to it - if ( myNote <> ActiveNote ) then - begin - SameEditor:= False; - Form_Main.Pages.ActivePage := myNote.TabSheet; - Form_Main.PagesChange( Form_Main.Pages ); - end; - if assigned( myTreeNode ) then begin - // select the node - if TTreeNote( ActiveNote ).TV.Selected <> myTreeNode then begin - SameEditor:= False; - myTreeNode.MakeVisible; // It could be hidden - TTreeNote( ActiveNote ).TV.Selected := myTreeNode; + _Executing_JumpToKNTLocation_ToOtherNote:= false; + try + // if not current note, switch to it + if ( myNote <> ActiveNote ) then + begin + _Executing_JumpToKNTLocation_ToOtherNote:= true; + SameEditor:= False; + Form_Main.Pages.ActivePage := myNote.TabSheet; + Form_Main.PagesChange( Form_Main.Pages ); end; - end - else - if ActiveNote.Kind = ntTree then - Exit; + + if assigned( myTreeNode ) then begin + // select the node + if TTreeNote( ActiveNote ).TV.Selected <> myTreeNode then begin + SameEditor:= False; + myTreeNode.MakeVisible; // It could be hidden + TTreeNote( ActiveNote ).TV.Selected := myTreeNode; + end; + end + else + if ActiveNote.Kind = ntTree then + Exit; - result := true; - if SameEditor then - AdjustVisiblePosition:= True; + result := true; + if SameEditor then + AdjustVisiblePosition:= True; - if not SearchTargetMark (Location.Bookmark09) then - SearchCaretPos(myNote, myTreeNode, Location.CaretPos, Location.SelLength, AdjustVisiblePosition); + if not SearchTargetMark (Location.Bookmark09) then + SearchCaretPos(myNote, myTreeNode, Location.CaretPos, Location.SelLength, AdjustVisiblePosition); - myNote.Editor.SetFocus; + myNote.Editor.SetFocus; + + finally + _Executing_JumpToKNTLocation_ToOtherNote:= false; + end; if _Executing_History_Jump then begin @@ -2510,6 +2519,7 @@ procedure TForm_Main.CreateHyperlink; Initialization _Executing_History_Jump := false; + _Executing_JumpToKNTLocation_ToOtherNote := false; _LastMoveWasHistory := false; diff --git a/structure/kn_TreeNoteMng.pas b/structure/kn_TreeNoteMng.pas index f164be6..79fc11f 100644 --- a/structure/kn_TreeNoteMng.pas +++ b/structure/kn_TreeNoteMng.pas @@ -417,7 +417,7 @@ procedure TreeNodeSelected( Node : TTreeNTNode; OnDeletingNode: boolean= false ) myTreeNote := TTreeNote( ActiveNote ); KeepModified:= false; - if ( not _Executing_History_Jump ) then begin + if ( not _Executing_History_Jump ) and (not _Executing_JumpToKNTLocation_ToOtherNote) then begin AddHistoryLocation( myTreeNote, false); // Add to history the location of current node, before the new node comes to be the selected node _LastMoveWasHistory := false; UpdateHistoryCommands;