Skip to content

Commit

Permalink
Adjustment in history navigation
Browse files Browse the repository at this point in the history
Currently it could add some unnecessary "history point" when activating an internal Keynote link
(or using an auxiliary bookmark (0-9))

For example, being 'Node 1' the selected node in "Note B", and "Note A" the selected note, after jumping with a internal knt link
 to 'Node 2' in "Note B", navigating back should return to Note A and not to 'Node 1' in Note B.
  • Loading branch information
dpradov committed Feb 3, 2024
1 parent 81109f0 commit 4df2b5a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
56 changes: 33 additions & 23 deletions editor/kn_LinksMng.pas
Expand Up @@ -90,6 +90,7 @@ interface

var
_Executing_History_Jump : boolean;
_Executing_JumpToKNTLocation_ToOtherNote : boolean;
_LastMoveWasHistory : boolean;


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2510,6 +2519,7 @@ procedure TForm_Main.CreateHyperlink;

Initialization
_Executing_History_Jump := false;
_Executing_JumpToKNTLocation_ToOtherNote := false;
_LastMoveWasHistory := false;


Expand Down
2 changes: 1 addition & 1 deletion structure/kn_TreeNoteMng.pas
Expand Up @@ -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;
Expand Down

0 comments on commit 4df2b5a

Please sign in to comment.