anchor.diff:        wordcnt := wordList.count;
   
   
  +      if FindOptions.AllTabs then
  +         myNote := TTabNote( Form_Main.Pages.Pages[noteidx].PrimaryObject ) // initially 0
  +      else
  +         myNote := ActiveNote; // will exit after one loop
  +
  +      if myNote.Kind = ntTree then begin
  +         GetFirstNode;
  +         while (not FindDone) and (not assigned(myTreeNode)) do begin
  +                GetNextNote();
  +                if (myNote.Kind <> ntTree) then break;
  +            end;
  +      end;
  +
  +
  +      // Recorremos cada nota
         repeat
  -
  -        SearchOrigin := 0; // starting a new note
  -        nodesSelected:= false; // [dpv] in this note, at the moment
  -
  -        if FindOptions.AllTabs then
  -          myNote := TTabNote( Form_Main.Pages.Pages[noteidx].PrimaryObject ) // initially 0
  -        else
  -          myNote := ActiveNote; // will exit after one loop
  -
  -        case myNote.Kind of
  -          ntRTF : begin
  -
  -            myTreeNode := nil;
  -            myNoteNode := nil;
  -
  -            case FindOptions.SearchMode of
  -              smPhrase : begin
  -
  -                repeat
  -
  -                  PatternPos := myNote.Editor.FindText(
  -                    FindOptions.Pattern,
  -                    SearchOrigin, myNote.Editor.GetTextLen - SearchOrigin,
  -                    SearchOpts
  -                  );
  -                  if ( PatternPos >= 0 ) then
  -                  begin
  -                    SearchOrigin := PatternPos + PatternLen; // move forward in text
  -                    inc( Counter );
  -                    Location := TLocation.Create;
  -                    Location.FileName := Notefile.FileName;
  -                    Location.NoteName := myNote.Name;
  -                    Location.CaretPos := PatternPos;
  -                    Location.SelLength := PatternLen;
  -                    Location.NoteID := myNote.ID;
  -                    AddLocation;
  -                  end;
  -
  -                  Application.ProcessMessages;
  -                  if UserBreak then
  -                  begin
  -                    FindDone := true;
  -                  end;
  -
  -                until ( FindDone or ( PatternPos < 0 )); // repeat
  -
  -              end; // smPhrase
  -
  -              smAny, smAll : begin
  -                MultiMatchOK := false;
  -                for wordidx := 1 to wordcnt do
  -                begin
  -                  thisWord := wordList[pred( wordidx )];
  -
  -                  PatternPos := myNote.Editor.FindText(
  -                    thisWord,
  -                    0, myNote.Editor.GetTextLen,
  -                    SearchOpts
  -                  );
  -
  -                  case FindOptions.SearchMode of
  -                    smAll : begin
  -                      if ( PatternPos >= 0 ) then
  +            nodesSelected:= false; // in this note, at the moment
  +            if myNote.Kind = ntTree then myTNote:= TTreeNote(myNote);
  +
  +            // Recorremos cada nodo (si es ntTree) o el nico texto (si <> ntTree)
  +            repeat
  +                PrepareEditControl(myNote, myTreeNode);
  +                nodeToFilter:= true;                     // Supongo que no se encontrar el patrn, con lo que se filtrar el nodo (si ApplyFilter=True)
  +                SearchOrigin := 0; // starting a new note
  +
  +                case FindOptions.SearchMode of
  +                    smPhrase :
  +                        begin
  +                            // look for match in node name first (si estamos buscando dentro de una nota ntTree)
  +                            if assigned(myTreeNode) and FindOptions.SearchNodeNames then
  +                            begin
  +                              myNoteNode := TNoteNode(myTreeNode.Data);
  +                              if FindOptions.MatchCase then
  +                                 PatternPos := pos( FindOptions.Pattern, myNoteNode.Name )
  +                              else
  +                                 PatternPos := pos( ansilowercase( FindOptions.Pattern ), ansilowercase( myNoteNode.Name ));
  +                              if ( PatternPos > 0 ) then begin
  +                                 inc( Counter );
  +                                 AddLocation(lsNodeName);
  +                              end;
  +                            end;
  +
  +                            repeat
  +                               PatternPos := EditControl.FindText(
  +                                 FindOptions.Pattern,
  +                                 SearchOrigin, EditControl.GetTextLen - SearchOrigin,
  +                                 SearchOpts
  +                               );
  +                               if ( PatternPos >= 0 ) then begin
  +                                   SearchOrigin := PatternPos + PatternLen; // move forward in text
  +                                   inc( Counter );
  +                                   AddLocation(lsNormal);
  +                               end;
  +                               Application.ProcessMessages;
  +                            until UserBreak or (PatternPos < 0);
  +                          end;
  +
  +                    smAny, smAll :
                         begin
  -                        MultiMatchOK := true; // assume success
  -                      end
  -                      else
  -                      begin
  -                        MultiMatchOK := false;
  -                        break; // note must have ALL words
  -                      end;
  -                    end; // smAll
  -
  -                    smAny : begin
  -                      if ( PatternPos >= 0 ) then
  -                      begin
  -                        MultiMatchOK := true;
  -                        break; // enough to find just 1 word
  -                      end;
  -                    end; // smAny
  -
  -                  end; // case FindOptions.SearchMode of
  -
  -                  Application.ProcessMessages;
  -                  if UserBreak then
  -                  begin
  -                    FindDone := true;
  -                    break;
  -                  end;
  -
  -                end; // for wordidx
  -
  -                if MultiMatchOK then
  -                begin
  -                  inc( Counter );
  -                  Location := TLocation.Create;
  -                  Location.FileName := Notefile.FileName;
  -                  Location.NoteName := myNote.Name;
  -                  Location.CaretPos := 0;
  -                  Location.SelLength := 0;
  -                  Location.NoteID := myNote.ID;
  -                  AddLocation;
  -                end;
  -
  -              end; // smAny, smAll
  -
  -            end; // case FindOptions.SearchMode
  -
  -          end; // ntRTF
  -
  -          ntTree : begin
  -            myTNote:= TTreeNote( myNote);
  -            //ActiveNote.EditorToDataStream; // update node's datastream    [dpv]
  -            myTNote.EditorToDataStream; // update node's datastream
  -
  -            myTreeNode := myTNote.TV.Items.GetFirstNode;
  -            if assigned( myTreeNode ) and myTreeNode.Hidden and (not FindOptions.HiddenNodes) then     // [dpv]
  -               myTreeNode := myTreeNode.GetNextNotHidden;
  -
  -            while assigned( myTreeNode ) do // go through all nodes
  -            begin
  -              nodeToFilter:= true;      // [dpv]
  -              // get this node's object and transfer
  -              // its RTF data to temp editor
  -              myNoteNode := TNoteNode( myTreeNode.Data );
  -              myNoteNode.Stream.Position := 0;
  -              RTFAux.Lines.LoadFromStream( myNoteNode.Stream );           // [dpv]  (002)
  -              SearchOrigin := 0;
  -
  -              case FindOptions.SearchMode of
  -
  -                smPhrase : begin
  -
  -                  // look for match in node name first
  -                  if FindOptions.SearchNodeNames then
  -                  begin
  -                    if FindOptions.MatchCase then
  -                      PatternPos := pos( FindOptions.Pattern, myNoteNode.Name )
  -                    else
  -                      PatternPos := pos( ansilowercase( FindOptions.Pattern ), ansilowercase( myNoteNode.Name ));
  -                    if ( PatternPos > 0 ) then
  -                    begin
  -                      inc( Counter );
  -                      Location := TLocation.Create;
  -                      Location.FileName := notefile.FileName;
  -                      Location.NoteName := myNote.Name;
  -                      Location.NodeName := myNoteNode.Name;
  -                      Location.CaretPos := -1; // means: text found in node name
  -                      Location.SelLength := 0;
  -                      Location.NoteID := myNote.ID;
  -                      Location.NodeID := myNoteNode.ID;
  -                      AddLocation;
  -                    end;
  -                  end;
  -
  -                  repeat // find all matches in current node
  -
  -                    // search in the temp editor
  -                    PatternPos := RTFAux.FindText(
  -                      FindOptions.Pattern,
  -                      SearchOrigin, RTFAux.GetTextLen - SearchOrigin,
  -                      SearchOpts
  -                    );
  -
  -                    if ( PatternPos >= 0 ) then
  -                    begin
  -                      SearchOrigin := PatternPos + PatternLen; // move forward in text
  -                      inc( Counter );
  -                      Location := TLocation.Create;
  -                      Location.FileName := notefile.FileName;
  -                      Location.NoteName := myNote.Name;
  -                      Location.NodeName := myNoteNode.Name;
  -                      Location.CaretPos := PatternPos;
  -                      Location.SelLength := PatternLen;
  -                      Location.NoteID := myNote.ID;
  -                      Location.NodeID := myNoteNode.ID;
  -                      AddLocation;
  -                    end;
  -
  -                    Application.ProcessMessages;
  -                    if UserBreak then
  -                    begin
  -                      FindDone := true;
  -                    end;
  -
  -                  until ( FindDone or ( PatternPos < 0 )); // repeat
  -
  -                end; // smPhrase
  -
  -                smAny, smAll : begin
  -
  -                  MultiMatchOK := false;
  -                  for wordidx := 1 to wordcnt do
  -                  begin
  -                    thisWord := wordList[pred( wordidx )];
  -
  -                    PatternPos := RTFAux.FindText(
  -                      thisWord,
  -                      0, RTFAux.GetTextLen,
  -                      SearchOpts
  -                    );
  -
  -                    case FindOptions.SearchMode of
  -                      smAll : begin
  -                        if ( PatternPos >= 0 ) then
  -                        begin
  -                          MultiMatchOK := true; // assume success
  -                        end
  -                        else
  -                        begin
  -                          MultiMatchOK := false;
  -                          break; // note must have ALL words
  -                        end;
  -                      end; // smAll
  -
  -                      smAny : begin
  -                        if ( PatternPos >= 0 ) then
  -                        begin
  -                          MultiMatchOK := true;
  -                          break; // enough to find just 1 word
  -                        end;
  -                      end; // smAny
  -
  -                    end; // case FindOptions.SearchMode of
  -
  -                    Application.ProcessMessages;
  -                    if UserBreak then
  -                    begin
  -                      FindDone := true;
  -                      break;
  -                    end;
  -
  -                  end; // for wordidx
  -
  -                  if MultiMatchOK then
  -                  begin
  -                    inc( Counter );
  -                    Location := TLocation.Create;
  -                    Location.FileName := notefile.FileName;
  -                    Location.NoteName := myNote.Name;
  -                    Location.NodeName := myNoteNode.Name;
  -                    Location.CaretPos := 0;
  -                    Location.SelLength := 0;
  -                    Location.NoteID := myNote.ID;
  -                    Location.NodeID := myNoteNode.ID;
  -                    AddLocation;
  -                  end;
  -
  -                end; // smAny, smAll
  -
  -              end; // case FindOptions.SearchMode
  -
  -
  -              if ApplyFilter and (not nodeToFilter) then    // [dpv]
  -                 TNoteNode(myTreeNode.Data).Filtered := false;
  -
  -              if FindOptions.HiddenNodes then     // [dpv]
  -                 myTreeNode := myTreeNode.GetNext
  -              else
  -                 myTreeNode := myTreeNode.GetNextNotHidden;
  -
  -            end; // while assigned( myTreeNode ) do
  -          end; // ntTree
  -
  -        end;
  -
  -        if ApplyFilter and nodesSelected then begin   // [dpv]
  -           Form_Main.FilterApplied(myTNote);
  -           ActiveNote:= nil;      // -> TreeNodeSelected will exit doing nothing
  -           HideFilteredNodes (myTNote);
  -           if myTNote.HideCheckedNodes then
  -              HideCheckedNodes (myTNote);
  -
  -           ActiveNote:= myNote;
  -           myTreeNode := myTNote.TV.Items.GetFirstNode;
  -           if myTreeNode.Hidden then myTreeNode := myTreeNode.GetNextNotHidden;
  -           myTNote.TV.Selected:= nil;
  -           myTNote.TV.Selected:= myTreeNode;   // force to select -> TreeNodeSelected
  -           ActiveNote:= oldActiveNote;
  -
  -           NoteFile.Modified := true;
  -           UpdateNoteFileState( [fscModified] );
  -        end;
  -
  -
  -        if FindOptions.AllTabs then
  -        begin
  -          inc( noteidx );
  -          if ( noteidx >= NoteFile.NoteCount ) then
  -            FindDone := true;
  -        end
  -        else
  -        begin
  -          FindDone := true;
  -        end;
  -
  -      until FindDone;
  +                         MultiMatchOK := false;
  +                         for wordidx := 1 to wordcnt do
  +                         begin
  +                            thisWord := wordList[pred( wordidx )];
  +
  +                            PatternPos := EditControl.FindText(
  +                              thisWord,
  +                              0, EditControl.GetTextLen,
  +                              SearchOpts
  +                            );
  +
  +                            case FindOptions.SearchMode of
  +                                smAll:
  +                                    if ( PatternPos >= 0 ) then
  +                                       MultiMatchOK := true // assume success
  +                                    else begin
  +                                       MultiMatchOK := false;
  +                                       break; // note must have ALL words
  +                                    end;
  +
  +                                smAny:
  +                                    if ( PatternPos >= 0 ) then begin
  +                                       MultiMatchOK := true;
  +                                       break; // enough to find just 1 word
  +                                    end;
  +                             end;
  +
  +                            Application.ProcessMessages;
  +                            if UserBreak then begin
  +                               FindDone := true;
  +                               break;
  +                            end;
  +
  +                         end; // for wordidx
  +
  +                         if MultiMatchOK then begin
  +                            inc( Counter );
  +                            AddLocation (lsMultimatch);
  +                         end;
  +
  +                      end; // smAny, smAll
  +
  +                end; // case FindOptions.SearchMode
  +
  +                if ApplyFilter and ((myNote.Kind = ntTree) and (not nodeToFilter)) then
  +                   TNoteNode(myTreeNode.Data).Filtered := false;
  +                GetNextNode;
  +
  +            until UserBreak or not assigned(myTreeNode);
  +
  +
  +            if ApplyFilter and nodesSelected then begin
  +               Form_Main.FilterApplied(myTNote);
  +               ActiveNote:= nil;      // -> TreeNodeSelected will exit doing nothing
  +               HideFilteredNodes (myTNote);
  +               ActiveNote:= myNote;
  +               myTreeNode := myTNote.TV.Items.GetFirstNode;
  +               if myTreeNode.Hidden then myTreeNode := myTreeNode.GetNextNotHidden;
  +               myTNote.TV.Selected:= nil;
  +               myTNote.TV.Selected:= myTreeNode;   // force to select -> TreeNodeSelected
  +
  +               NoteFile.Modified := true;
  +               UpdateNoteFileState( [fscModified] );
  +               myTreeNode:= nil;
  +            end;
  +
  +            while (not UserBreak) and ((not FindDone) and (not assigned(myTreeNode))) do begin
  +               GetNextNote();
  +               if (myNote.Kind <> ntTree) then break;
  +            end;
  +
  +      until FindDone or UserBreak;
   
   
         MatchCount := Location_List.Count;
         if ( MatchCount > 0 ) then
         begin
  -        lastNoteID := 0;
  -        lastNodeID := 0;
  -        lastTag := 0;
  +        lastNoteID := -1;
  +        lastNodeID := -1;
  +        lastTag := 1;
           for i := 1 to MatchCount do
           begin
             Location := TLocation( Location_List.Objects[pred( i )] );
  -          if ( i > 1 ) then
  -          begin
  -            if (( lastNoteID <> Location.NoteID ) or ( lastNodeID <> Location.NodeID )) then
  -            begin
  -              case lastTag of
  -                0 : Location.Tag := 1;
  -                else
  -                  Location.Tag := 0;
  -              end;
  -            end
  -            else
  -            begin
  -              Location.Tag := lastTag;
  -            end;
  +          if (( lastNoteID <> Location.NoteID ) or ( lastNodeID <> Location.NodeID )) then begin
  +              if lastTag = 1 then
  +                 Location.Tag := 0
  +              else
  +                 Location.Tag := 1;
             end;
             lastNoteID := Location.NoteID;
             lastNodeID := Location.NodeID;
  
positive.code:             Location
            );
          end;
          with Form_Main do
          begin
            List_ResFind.ItemIndex := 0;
  
negative.code:       // o incluso continuar buscando desde el punto de partida, de manera cclica.
  
        repeat
              PrepareEditControl(myNote, myTreeNode);
  
              PatternPos := EditControl.FindText(
                Text_To_Find,
  