Community
    • Login

    Search++: A work in progress

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    185 Posts 11 Posters 57.5k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • guy038G Online
      guy038
      last edited by

      Hello, @coises,

      Sorry, I haven’t commented on your latest version yet. In the meantime, I replied to @Vitalii-dovgan regarding his own implementation of the Find in Files feature.

      During that testing, I also included the Search++ plugin ( v0.7 ) and the MultiReplace plugin.

      So I invite you to take a look at it : https://community.notepad-plus-plus.org/post/106389


      As for your latest version, I won’t be able to review it thoroughly until tomorrow evening. So, I’ll probaly get back to you on Saturday instead !

      BR

      guy038

      1 Reply Last reply Reply Quote 0
      • guy038G Online
        guy038
        last edited by guy038

        Hello, @coises and All,

        FIRST test. Let’s suppose I chose these settings :

        619541f4-7ee4-45ce-9bfb-48be28fa2c81-image.jpeg

        You note that I unchecked the two options Default commands automatically search within selections and Default commands automatically search within marked text. Thus, all default commands will always apply to whole document

        Note also that I checked the two options Always clear selections before Select command. (Otherwise add to existing selections.) and the Always unmark all text before Mark command. (Otherwise add to existing marked text.)

        And that I decided to not bookmark the lines containing a marked text :

        23de9898-4c1c-4ddf-8f36-447fb9a401ed-image.jpeg

        Then, starting with that text :

        
        bla
        blah
        This is the test to do
        bla
        blah
        test
        bla
        blah
        

        I marked the two words test with the Mark command or the M key. Now, given the above parameters, it just marked these two words.

        03329b13-4012-4cac-8f64-2f61c1336e03-image.jpeg

        7348f86c-56e9-46d1-b153-778f609c608e-image.jpeg

        Then, using the Synchronize bookmarks to marked text option, ( Ctrl + Shift + Z ), it bookmarked the lines 4 and 7 => OK

        475bac52-3747-4bc9-81ef-b3995130ea17-image.jpeg

        Now, using the Remove marks from active document option ( Ctrl + Shift + R ), it deleted any marked text. However the bookmarks remain.

        3767b2d0-be9d-4e0c-83d5-63f6882ff45d-image.jpeg

        Is this behavior logical as you said that, even when the Bookmark lines when marking text is not checked, the Keep bookmarks synchronized with marked text option is still honored ?


        SECOND test :

        I now decided to check the Bookmark lines when marking text option ( Ctrl + B )

        Again, I marked the two words test with the Mark command or the M key. Given the modified parameters, it correctly marked these two words and bookmarked the lines 4 and 7

        Then using the Remove marks and bookmarks from active document option ( Ctrl + Shift + R ), it deleted, both, marked text and bookmarks => OK

        Remark that this command is now labelled Remove marks and bookmarks ..., unlike Remove marks ... in the first test : nice !


        THIRD test :

        Again, I marked the two words with a Mark command. Thus, the snapshot below :

        af1745d6-6e7e-4036-a04f-e86675835818-image.jpeg

        Then, I used the Invert marked text option ( Crl + Shift + I ). I got this snapshot :

        c0bbc189-4c13-4fd8-a8d3-a2920d7ad3c4-image.jpeg

        That’s not exactly what I expected !

        I wanted to invert all the bookmarks, FIRST and SECONDLY, mark the contents of all the lines having a bookmark ! To do so, instead of searching the test word, I needed to use the regex ^((?!test).)*$ and I chose again the Mark command to get this behavior. See below :

        96971287-7731-42c8-b420-5a0cece1df53-image.jpeg

        Note that this behavior is even better than with N++. Indeed, if you decide to use the Invert bookmarks feature, it swaps the bookmarks but leaves the marked text as is, in lines 4 and 7 !

        Of course, @coises, to imagine the negative regex ^((?!test).)*$ compared to the positive regex test is easy enough with that simple example. However, how to quickly determine a correct negative regex vs a complicated positive regex ?


        Of course, it’s obvious that your plugin is already very configurable and has numerous options ! So, may be, my request might not be reasonable !

        BTW; I really appreciate the right click on any option. For example :

        • First, you right-click on the Hde all lines option ( Ctrl + Shift + D ) option => Any line of current document is hidden

        • Then, if you right-click on the Show selected lines (Shift: All) option => All lines of current document are visible again !

        Best Regards,

        guy038

        CoisesC 1 Reply Last reply Reply Quote 1
        • CoisesC Online
          Coises @guy038
          last edited by Coises

          @guy038 said:

          Thank you for taking a look at this!

          Now, using the Remove marks from active document option ( Ctrl + Shift + R ), it deleted any marked text. However the bookmarks remain.

          Is this behavior logical as you said that, even when the Bookmark lines when marking text is not checked, the Keep bookmarks synchronized with marked text option is still honored ?

          It is behaving as designed, though the intent may be unclear. For the record, what I wrote was:

          The Bookmark lines when marking text option at the bottom right is identical to the menu setting; it’s just in this dialog so you don’t have to open the menu a second time to see or change it. The other options in this dialog are only relevant when this box is checked; unchecking it, or the equivalent menu setting, keeps Search++ from doing anything with bookmarks, with one exception: the new Synchronize bookmarks to marked text command.

          The new Synchronize bookmarks to marked text command applies the policy selected for Bookmark every line containing marked text or Bookmark only the first line of each match or selection regardless of any other settings, including Bookmark lines when marking text.

          The Keep bookmarks synchronized with marked text option only applies to Tools menu commands that affect bookmarks, except for the special cases listed: Remove marks from multiple documents… (which has a check box in the dialog) and Synchronize bookmarks to marked text (which always does what it says). Except for Synchronize bookmarks to marked text, Tools menu commands do not affect bookmarks unless Bookmark lines when marking text is checked.

          I think the design makes sense, but I wish I knew how to make it more obvious. You turn Bookmark lines when marking text on or off depending on whether you want Search++ to manipulate bookmarks at all. The only exception is Synchronize bookmarks to marked text, because it’s the only command that has no other effect than to manipulate bookmarks. (I could disable that command when Bookmark lines when marking text is unchecked, but I don’t see the point. As it is, it’s a quick way to get bookmarks for marked text even if you usually don’t want Search++ messing with your bookmarks.)

          THIRD test :

          Again, I marked the two words with a Mark command. Thus, the snapshot below :

          af1745d6-6e7e-4036-a04f-e86675835818-image.jpeg

          Then, I used the Invert marked text option ( Crl + Shift + I ). I got this snapshot :

          c0bbc189-4c13-4fd8-a8d3-a2920d7ad3c4-image.jpeg

          That’s not exactly what I expected !

          It worked as designed, but the design might not be very useful.

          I wanted to invert all the bookmarks, FIRST and SECONDLY, mark the contents of all the lines having a bookmark !

          That’s an interesting thought. Not what Invert marked text does, but interesting. Invert mark text proceeds in the opposite manner: first it marks every character that wasn’t marked and unmarks every character that was marked. Then, depending on the bookmark options, it either does nothing with bookmarks or it bookmarks every line containing any marked text (or the first line of each unbroken span of marked text, depending on the every line / first line setting).

          To do so, instead of searching the test word, I needed to use the regex ^((?!test).)*$ and I chose again the Mark command to get this behavior.

          Of course, @coises, to imagine the negative regex ^((?!test).)*$ compared to the positive regex test is easy enough with that simple example. However, how to quickly determine a correct negative regex vs a complicated positive regex ?

          I did think of Invert marked text as a way to search in a negative space, but I didn’t think of someone perhaps wanting to apply it to whole lines rather than to characters.

          I did notice that (with or without bookmarks, but more obvious with them) the results of Invert marked text can be unexpected, because line endings count as characters for which marking is inverted. If you have Keep bookmarks synchronized with marked text checked and you aren’t showing line endings, unexpected bookmarks can appear where there seems to be nothing marked, because the line endings are marked.

          So far, I haven’t had a “real world” case where I wanted Invert marked text for anything, but it hasn’t been available (even to me) for all that long yet.

          I have to consider this some more, but I’m thinking that Invert marked text isn’t something that would be used very often, so it doesn’t have to be one click: it might be better to replace the single action with a dialog that lets you choose details about how you want to “negate” the text indicated by marks.

          Suggestions welcome!

          1 Reply Last reply Reply Quote 0
          • guy038G Online
            guy038
            last edited by guy038

            Hello, @coises and All,

            I noticed a bug regarding the default style which is wrongly changed why you simply left clicking on any option

            Note that I preferred to delete the Search++.json file in order to start with a default configuration. Then, I redefined my settings as described at the beginning of my previous post and I chose my options in the Search++ Configure bookmarks as below :

            328a1570-e606-4fc6-a66c-897d3e8903cb-image.jpeg

            Now, using again the example text :

            
            bla
            blah
            This is the test to do
            bla
            blah
            test
            bla
            blah
            

            I marked, successively, the two words bla, then test. So the results :

            e52efa36-1f31-47cd-af90-960368efd2b7-image.jpeg

            And

            09dc478f-2059-4aed-ae2a-c3ac4611ff73-image.jpeg

            Then, I right click in the search zone of Search++ and chose again the bla word.

            4e3297d8-e449-434c-bc7a-441966218611-image.jpeg

            Now, the first command used changes the default setting ! As I ran the Mark command by a simple left click , I got :

            d18f04e6-c721-4a19-bc39-85daafff4040-image.jpeg

            After I redefined the right button to Find All ↕, I tried again to mark the word bla by left-clicking on the Mark option. This time, the defaut third button remained Find All ↕ and the Mark command was again executed !

            Note this problem occurs ONLY when you FIRST change the word in the search dialog with a right-click within the list. If you manually delete the word test and replace it with the word bla, the problem does not occur !


            In the first test of my previous post, I said :

            Is this behavior logical as you said that, even when the Bookmark lines when marking text is not checked, the Keep bookmarks synchronized with marked text option is still honored ?

            I now realize that this behaviour is quite logical ! Indeed, as the bookmark lines when marking text option was unchecked, in this first test, the Ctrl + Shift + R option is simply labelled Remove marks from active document ( and not Remove marks and bookmarks from active document ). Thus, it correctly leaves the bookmarks as is !


            If I understood you correctly, when the Bookmark lines when marking text option is unchecked, Search++ ignore totally the Bookmark feature. Thus, it just up to you to add / remove MANUAL bookmarks to some lines, if needed !

            Now, basically, a Mark command :

            • Case 1 : can mark text

            • Case 2 : can mark text and bookmark lines

            • Case 3 : can un-mark text

            • Case 4 : can un-mark and un-bookmark lines

            Thus, I suggest this new dialog :

             Search++: Configure bookmarks
            
             ☑  Bookmark lines when marking text.
            
              Bookmark policy
            
                ◉ Bookmark every line containing marked text.
            
                ○  Bookmark only the first line of each match or selection.
            
              Tools menu
            
             ☑  When a Mark command adds existing marks to text, also add bookmarks.
            
             ☑  When a Mark command removes existing marks from text, also remove bookmarks.
            
             Invert option policy
            
                ○  Invert the marked text and bookmark the concerned lines
            
                ◉  Invert the bookmarked lines and mark the concerned lines
            
                                    [OK]           [Cancel]
            

            You’ll be able to verify that when :

            • The first When a Mark command... option is unchecked, it corresponds to the case 1, above

            • The first When a Mark command... option is checked, it corresponds to the case 2, above

            • The second When a Mark command... option is unchecked, it corresponds to the case 3, above

            • The second When a Mark command... option is checked, it corresponds to the case 4, above


            You’ll also verify that :

            • The present option When a Mark command removes existing marks ... is the second When a Mark command... option of my new dialog

            • The present Mark commands do not add or remove bookmarks. corresponds to the cases 1 and 3

              The present Mark commands add bookmarks but do not remove them. corresponds to the cases 2 and 3

              The present Keep bookmarks synchronized with marked text. corresponds to the cases 2 and 4

            At the end of this new dialog, I simply add txo choices regarding the Invert option policy !

            What is your feeling about it ?

            Best Regards,

            guy038

            P.S. :

            Oh, I forgot : Why not make the entire menu, under an unchecked Bookmark lines when marked text option, gray, in this new dialog ?

            CoisesC 1 Reply Last reply Reply Quote 1
            • CoisesC Online
              Coises @guy038
              last edited by

              @guy038 said:

              I noticed a bug regarding the default style which is wrongly changed why you simply left clicking on any option

              Then, I right click in the search zone of Search++ and chose again the bla word.

              Now, the first command used changes the default setting !

              Thank you for noting this. I can reproduce it. Any right-click in a Find or Replace box causes the next click on a search command drop-down or the Tools menu to behave as if it were a right-click.

              I will figure out why that is happening and fix it.

              If I understood you correctly, when the Bookmark lines when marking text option is unchecked, Search++ ignore totally the Bookmark feature. Thus, it just up to you to add / remove MANUAL bookmarks to some lines, if needed !

              Right. The one exception is Synchronize bookmarks to marked text, which works whether Bookmark lines when marking text is checked or unchecked.

              My intent is that people who don’t typically want Search++ disturbing their bookmarks can still use Synchronize bookmarks to marked text after a Mark command, rather than having to change a setting before the Mark, which they would then have to remember to change back. However, I think the lack of an option to add bookmarks but not remove any might limit its usefulness, so I might change it in one way or another. It honors the every line / first line policy, so perhaps it should honor add/synchronize too, but then it would no longer be always a synchronize, and it would do nothing if the Tools option were “Do not add or remove bookmarks”…

              There’s definitely a design flaw here.

              Now, basically, a Mark command :

              • Case 1 : can mark text

              • Case 2 : can mark text and bookmark lines

              • Case 3 : can un-mark text

              • Case 4 : can un-mark and un-bookmark lines

              Thus, I suggest this new dialog :

               Search++: Configure bookmarks
              
               ☑  Bookmark lines when marking text.
              
                Bookmark policy
              
                  ◉ Bookmark every line containing marked text.
              
                  ○  Bookmark only the first line of each match or selection.
              
                Tools menu
              
               ☑  When a Mark command adds existing marks to text, also add bookmarks.
              
               ☑  When a Mark command removes existing marks from text, also remove bookmarks.
              
               Invert option policy
              
                  ○  Invert the marked text and bookmark the concerned lines
              
                  ◉  Invert the bookmarked lines and mark the concerned lines
              
                                      [OK]           [Cancel]
              

              What is your feeling about it ?

              The existing When a Mark command removes existing marks from text, also remove bookmarks check box applies to Mark commands when Always unmark all text before Mark command. (Otherwise add to existing marked text.) in the Settings dialog is checked. That’s the only time a Mark command ever removes marks from text. It’s possible this shouldn’t even be an option (operating as if it were always checked) since Bookmark lines when marking text must also be checked, but I thought there might be the occasional person who would want to uncheck it.

              The choice under Mark tools applies to commands from the Tools menu (except Synchronize bookmarks to marked text) and has nothing to do with Mark commands.

              My wording needs more clarity; or possibly the problem is that the selection of available choices doesn’t make sense, and that’s why it’s hard to convey.

              Regarding the proposed Invert the bookmarked lines and mark the concerned lines: the command would clear all marks from text, invert the bookmarks, then mark every character in every line that was bookmarked? Does that include or exclude line endings? What does it do if Bookmark only the first line of each match or selection is in effect?

              I’m really tight on available menu mnemonics (the underlined letters) and memorable shortcut keys on the Tools menu, to the point where adding much more will mean I either have to remove something or use sub-menus (with limited shortcut possibilities): but this sounds more like it should be a separate command than a setting that changes how Invert marked text works. In that case, though, since Inverse Bookmarks is already a Notepad++ command, I wonder if something else (like Mark or Select all text in bookmarked lines) would be more versatile?

              I shudder to invent yet another conditional search, but maybe Find All / Select / Mark / Show in Bookmarked lines is what is really wanted here. (And then that leads to wanting to bookmark lines containing a match without bothering with marking the text…)

              I will take ideas from your dialog, but it doesn’t quite represent the options that are available now. Invert and the implications thereof I am still thinking about.

              Why not make the entire menu, under an unchecked Bookmark lines when marked text option, gray, in this new dialog ?

              Putting it at the top and disabling the options when it is not checked would help clarify the relationship between it and the other settings, but there is one problem: the “Bookmark policy” (”every line” or ”only the first line”) applies to Synchronize bookmarks to marked text, which works even if Bookmark lines when marking text is not checked. (Again, this could represent a design flaw.)

              1 Reply Last reply Reply Quote 1
              • CoisesC Online
                Coises
                last edited by Coises

                Search++ version 0.7.0.2 is a test of my second attempt at improved bookmark handling. Help and change log have not been updated.

                @guy038, @peterjones, @astewart77 and anyone else interested, please let me know if this is better than the last attempt, and anything you would like to be different.

                • Fixed right-click in Find or Search box causing next left-click on a Search++ menu to act as if it were a right-click.
                • Some changes in the wording and organization of the Configure bookmarks dialog.
                • Separated Invert and Synchronize into sub-menus on the Tools menu, with all sub-menu choices now independent of the Configure bookmarks settings.

                Hopefully the Configure bookmarks dialog is a little more clear now. I rearranged it as @guy038 suggested, putting the Bookmark lines when marking text check box at the top and disabling everything when it is not checked, and I made some changes in wording:

                ca283686-805c-46c7-9061-d5ea1c5bfb12-image.jpeg

                In version 0.7.0.1, the Invert marked text and Synchronize bookmarks to marked text commands on the Tools menu were affected by some settings in the Configure bookmarks dialog but not by others. It was confusing.

                In version 0.7.0.2 the dialog is more explicit about what commands respond to the settings in the bottom box. The commands that were previously exceptions are now on sub-menus, Invert marks or bookmarks and Synchronize marks and bookmarks. Each sub-menu has several options, none of which depend on settings in the Configure bookmarks dialog.

                A downside to this is that there are no keyboard shortcuts for the items on the sub-menus. (There are only a couple available shortcuts left, and I can’t see how I could prioritize one over another.)

                • The sub-menu options that are qualified with “excluding line endings” mark entire lines to match bookmarks, but avoid marking the line ending characters.
                • “Add (book)marks” vs “(Book)Mark only” distinguishes adding to preexisting marks or bookmarks from clearing them first.

                All feedback is welcome and appreciated.

                1 Reply Last reply Reply Quote 0
                • guy038G Online
                  guy038
                  last edited by guy038

                  Hi, @coises,

                  Yesterday, I did not have time to thoroughly test your 0.7.0.1 release. So, today, I downloaded your last v0.7.0.2 release that I’m presently testing !

                  See you later, in the evening ( in France ! )

                  BR

                  guy038

                  1 Reply Last reply Reply Quote 1
                  • guy038G Online
                    guy038
                    last edited by guy038

                    Hello, @coises,

                    For, the tests below, I needed, of course, to un-check the Always unmark all text before Mark command. (Otherwise add to existing marked text.) option in Settings

                    Regarding the present Synchronize marks and bookmarks sub-mneu, below :

                    Add a bookmark to each line with marked text
                    Add a bookmark to the first line of each span of marked text
                    
                    Bookmark only lines with marked text
                    Bookmark only the first line of each span of marked text
                    
                    Bookmark visible lines
                    
                    Add marks to all text in bookmarked lines
                    Mark only text in bookmarked lines
                    
                    Add marks to all text in bookmarked lines, excluding line endings
                    Mark only text in bookmarked lines,excluding line endings
                    

                    Two observations :

                    1 I don’t think that the options which mark only the first line of each span of marked text are really useful. Actually, the goal is more to mark all the lines that meet a certain criterion, in order to navigate between these lines, copy / cut theses lines for pasting in a other location or file or deleting these ones !

                    2 With native N++, whatever you use the ^.* or ^.*\R regex to mark AND boomark lines, then using the Copy Bookmarked lines of N++ and pasting in an other document, even with an other kind of EOL, just paste the bookmarked lines according to the EOL of the pasting document

                    So, most of the time, taking the line-breaks in account is not necessary ! However, adding the line-breaks characters is useful as it also includes the true empty lines !


                    Thus, this would simplify the Synchronize marks and bookmarks sub-menu to the following one :

                    Bookmark only lines containing marked text
                    Clear all bookmarks, then bookmark only lines containing marked text
                    
                    Bookmark visible lines
                    
                    Mark all text and EOLs of the bookmarked lines
                    Clear all marks, then mark all text and EOLs of the bookmarked lines
                    

                    Now, regarding the present Invert marks or bookmarks sub menu, below :

                    A Invert marked text
                      Invert marked text, excluding unmarked line endings
                    
                    C Invert marked text and sync bookmarks
                      Invert marked text, excluding unmarked line endings, and sync bookmarks
                    
                    B Invert bookmarks
                    D Invert bookmarks and mark only bookmarked lines
                      Invert bookmarks and mark only bookmarked lines, excluding line endings
                    

                    This time, I would avoid any option that excludes the EOLs and I propose this new sub-menu :

                    A Invert only the marked text
                    
                    B Invert only the bookmarks
                    
                    D Invert bookmarks, then mark all text and EOL of the bookmarked lines
                    
                    C Invert marked text, then bookmark all lines containing marked text
                    

                    Remarks :

                    • The letters preceding the options serve to link this present submenu to the future possible submenu !

                    • Note that running, consecutively, the A and B actions is equivalent to the D action

                    • Note also that in these two sub-menus, I specified, when necessary, the two consecutive steps to make it easier to understand :

                    For example :

                    • Clear all bookmarks, then bookmark only lines containing marked text

                    • Clear all marks, then mark all text and EOLs of the bookmarked lines

                    • D Invert bookmarks, then mark all text and EOL of the bookmarked lines

                    • C Invert marked text, then bookmark all lines containing marked text

                    It’s easier to see the first action done : on the bookmarks OR on the marks

                    BR

                    guy038

                    Again, I forgot to thank you for the fix when you do a first right-click within the Find or Replace boxes !

                    1 Reply Last reply Reply Quote 0
                    • guy038G Online
                      guy038
                      last edited by

                      Hi, @coises,

                      Oh…, my God, I’m just realizing that I did all my previous tests with the main Bookmark lines with marking text option OFF, so with the Search++ Configure bookmark dialog all greyed !

                      Thus, my tests are quite incomplete :-(( I’ll continue testing … !

                      BR

                      guy038

                      1 Reply Last reply Reply Quote 0
                      • guy038G Online
                        guy038
                        last edited by

                        Hello, @coises and All,

                        Thus, I chose these options within the Search++: Configure bookmarks dialog :

                        2056c175-9a25-44dc-813e-b3830706ef40-image.jpeg


                        And ultimately, given the chosen options, the only differences are :

                        • When you mark something, it automatically bookmarks the associated line

                        • When you unmark something, it automatically removes the bookmark of the associated line

                        Best Regards

                        guy038

                        CoisesC 1 Reply Last reply Reply Quote 1
                        • CoisesC Online
                          Coises @guy038
                          last edited by

                          @guy038 said:

                          And ultimately, given the chosen options, the only differences are :

                          • When you mark something, it automatically bookmarks the associated line

                          • When you unmark something, it automatically removes the bookmark of the associated line

                          Yes, that is one of the changes from 0.7.0.1 to 0.7.0.2, that Invert and Synchronize (previously commands, now sub-menus of commands) are no longer affected by the Configure bookmarks settings at all. That made it sensible to put all the settings under Bookmark lines when marking text. and disable them when that option is unchecked.

                          1 Reply Last reply Reply Quote 1

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          • First post
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors