Community
    • Login

    Search++: A work in progress

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    228 Posts 13 Posters 111.9k Views 3 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 guy038

      Hi, @coises and All,

      You said :

      Since all you need to do to cancel a selection is to click anywhere in the document, I didn’t figure anything more would be needed.

      I agree with you that’s not a big task ! I just wanted to point out, that if you want to keep focus on the Search++ dialog, in order to use any other Alt + ... command, I do not see any command which could cancel the selection !


      Now, regarding the five shortcuts problem, you’re totally right : my FRENCH keyboard is a standard one and in order to get, for example, the Alt + 1 action, I must use the combination Alt + Shift + 1 ! Now, I do not mind to stay with these Alt + Shift + 1-5 shortcuts ! But, if you find a way to detect the keys themselves, that would be fine too !

      BR

      guy038

      P.S. : Sorry for thinking you might have made a mistake when assigning those 5 shortcuts !

      1 Reply Last reply Reply Quote 1
      • guy038G guy038 referenced this topic on
      • sevem47S Offline
        sevem47
        last edited by

        Hello @coises

        I think there is a small visual glitch in search/replace history

        If a search or replace string ends with a blank character the entry is not displayed correctly in the history: the character just in front of the blank is not shown, instead it shows a blank as well:

        SearchReplaceHistory_image.jpg

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

          Hello, @coises,

          Could you take a look at my three consecutive posts, below , relative to simultaneous search of compatible Unicode forms / characters ?

          https://community.notepad-plus-plus.org/topic/27611/is-there-a-way-to-find-both-alphabets-with-and-without-accents-at-the-same-time-when-searching/11
          https://community.notepad-plus-plus.org/topic/27611/is-there-a-way-to-find-both-alphabets-with-and-without-accents-at-the-same-time-when-searching/12
          https://community.notepad-plus-plus.org/topic/27611/is-there-a-way-to-find-both-alphabets-with-and-without-accents-at-the-same-time-when-searching/13

          Do you think it would be possible to add this feature to Search++ as part of the plugin’s future development ?

          Many thanks for your attention !

          Best Regards,

          guy038

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

            @guy038 said:

            Do you think it would be possible to add this feature to Search++ as part of the plugin’s future development ?

            I do think it would be possible, and that it would be a useful enhancement.

            I haven’t studied the problem in detail yet. The relevant concepts exist and are well-defined: Unicode canonical equivalence and compatibility equivalence. Probably someone has already implemented practical searches using canonical and compatibility equivalence in open source code, so finding and studying existing, mature solutions that have already encountered and resolved whatever complications inevitably arise will no doubt be my first step.

            1 Reply Last reply Reply Quote 1
            • CoisesC Offline
              Coises @sevem47
              last edited by

              @sevem47 said:

              I think there is a small visual glitch in search/replace history

              Yes, that is an error. Thank you for catching and reporting it! I will find the cause and fix it.

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

                Hello, @coises, @thomas-knoefel and All,

                For some obscure reasons, one day, my usual USB key for tests was just considered as containing RAW text. I did not even succeeded to reformat it ! So I threw it in the trash and from a ( not too old ) copy of that key, I was able more or less, to reconstruct the original contents of this USB drive !


                Now, when I asked Google about “softwares able to search canonical and compatibility Unicode characters”, the IA answer, at the beginning, proposed, among other things, the CLI software ripgrep (rg). Although it does not seem to really treat canonical and compatibility Unicode forms AFAIK, it is quite fast and has plenty of interesting options !

                Refer to https://github.com/BurntSushi/ripgrep. The last release is version 16.0 . Download, preferably, the ripgrep-16.0.0-x86_64-pc-windows-msvc.zip archive which is compatible with 64-bit Windows 11 laptops

                After extraction of the rg.exe software, in a CMD window, run rg -h for short descriptions or rg --help for more details !


                Following my usual procedure, I searched for any file, including binary ones as well, of my new USB key, the string Fi, with this exact case, in regex mode and I got these results :

                Search "Fi" (32 189 hits in 624 files of 1 119 searched) [RegEx: Case]  with native N++ v8.9.9.1
                
                Search "Fi" (32 189 hits in 624 file(s)) [1 119 file(s) searched]       with MultiReplace v6.2.0.38
                
                32 189 matches in 624 of 1 118 files (Regex, match case): Fi            with Search++ v0.8 (x64)
                
                And running the DOS command "rg -a --stats Fi", it displayed, at the end :
                
                32189 matches
                24492 matched lines
                624 files contained matches
                1118 files searched
                12462212 bytes printed
                498369521 bytes searched
                0.173930 seconds spent searching
                0.573693 seconds total
                

                As you can see, the count of matches and the files concerned are identical for these 4 tests However, the number of files analyzed varies :

                • 1,119 for N++ and MultiReplace

                • 1,118 for Search++ and rg.exe

                I figured out why ! On my D: key, I have only :

                • One directory which is hidden : System Volume Information

                • One file which is hidden : Thumbs.db

                As the Hidden folders option was unchecked, N++ and MultiReplace did not consider the folder System Volume Information but did take in account the Thumbs.db file !

                Whereas, the Search++ plugin and the rg software did not consider, both, hidden files AND folders. Thus, it did not analyse the Thumbs.db, as well !

                Consequently, @coises, I suppose that you have enough place to modify the label of the option from Hidden files to Hidden files and folders. Alternatively, you could also decide to add a new option Hidden folders. Do as you like !


                Now, I ran the same tests again, on txt files ONLY and there are the results :

                    •==============•==========•========•===========•===============•===============•==========================•
                    |   Software   |   Hits   |  In    |  Scanned  |  First Time   |  Second Time  |        Command           |
                    |   / Plugin   |          | Files  |   Files   | After Restart |  Right after  |                          |
                    •==============•==========•========•===========•===============•===============•==========================•
                    |   Notepad++  |  10600   |  311   |    641    |   17 s 25 "   |    5 s 32 "   |                          |
                    •--------------•----------•--------•-----------•---------------•---------------•--------------------------•
                    | MultiReplace |  10600   |  311   |    641    |   11 s 80 "   |    1 s 78 "   |                          |
                    •--------------•----------•--------•-----------•---------------•---------------•--------------------------•
                    |   Search++   |  10600   |  311   |    641    |   16 s 94 "   |    0 s 66 "   |                          |
                    •--------------•----------•--------•-----------•---------------•---------------•--------------------------•
                    |    rg.exe    |  10600   |  311   |    641    |   16 s 69 "   |    0 s 55 "   |  rg -a -ttxt --stats Fi  |
                    •==============•==========•========•===========•===============•===============•==========================•
                

                Best Regards,

                guy038

                P.S. : Please note that the tests were all conducted BEFORE I wrote this post, which, obviously, modify the results !

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

                  @guy038 said:

                  Refer to https://github.com/BurntSushi/ripgrep.

                  An interesting and sophisticated piece of software. It is written in Rust and by default uses that language’s regular expression search engine, which is a “finite state machine” implementation rather than a “backtracking” implementation. The practical effect of that is that the default engine doesn’t support lookarounds or backreferences, though it does support some constructs Boost::regex does not. It also avoids the “complexity” error that can occur during matching with Boost::regex. (The expression itself can still be “too complex,” but if it is, that’s known before matching ever begins.)

                  One of the “someday…” wishes I have for Search++ is to add an alternate regex engine that uses a finite state machine (e.g., RE2), for use when the search expression doesn’t need backtracking-only features but the total space to be searched is huge.

                  Consequently, @coises, I suppose that you have enough place to modify the label of the option from Hidden files to Hidden files and folders. Alternatively, you could also decide to add a new option Hidden folders.

                  Yes, I see I should be more clear. Without thinking about it, I always assumed that if you were excluding “hidden” anything, that meant both hidden files and anything that could only be reached through a hidden folder. I hadn’t realized that Notepad++’s native search would still search hidden files if that box was not checked, so long as they weren’t in a hidden folder.

                  I’m curious whether you, or anyone, foresees practical cases in which you would want to omit one from a search but not the other.

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

                    Hi, @coises and All,

                    You said :

                    The practical effect of that is that the default engine [ of rg.exe ] doesn’t support lookarounds or backreferences …

                    Well, actually, if you choose the --pcre2 option, it does support them ! For example :

                    The rg -a -t txt --stats Fi(?=le) DOS command returns :

                    C:\>d:
                    
                    D:\>rg -a -t txt --stats Fi(?=le)
                    rg: regex parse error:
                        (?:Fi(?=le))
                             ^^^
                    error: look-around, including look-ahead and look-behind, is not supported
                    
                    Consider enabling PCRE2 with the --pcre2 flag, which can handle backreferences
                    and look-around.
                    
                    D:\>
                    

                    And, indeed, the command rg -a -t txt --stats --pcre2 Fi(?=le), after a restart, is quite functional and give these results :

                    2250 matches
                    1596 matched lines
                    104 files contained matches
                    642 files searched
                    271490 bytes printed
                    88413019 bytes searched
                    130.606157 seconds spent searching
                    17.113812 seconds total
                    

                    Note that I do not understand why the total search took about 17 s and the search, itself, took about 130 s ? But this is an off-topic question !


                    Then, the next step, to my mind, was to try, for example, the regexes :

                    (?=[[=O=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=f=]])\X(?=[[=r=]])\X(?=[[=i=]])\X(?=[[=e=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=S=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=u=]])\X(?=[[=n=]])\X(?=[[=a=]])\X(?=[[=s=]])\X
                    (?=[[=O=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=f=]])\X(?=[[=r=]])\X(?=[[=i=]])\X(?=[[=e=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=Š=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=ū=]])\X(?=[[=n=]])\X(?=[[=a=]])\X(?=[[=s=]])\X
                    (?=[[=O=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=f=]])\X(?=[[=r=]])\X(?=[[=i=]])\X(?=[[=e=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=S=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=u=]])\X(?=[[=n=]])\X(?=[[=a=]])\X(?=[[=s=]])\X
                    
                    Our friend Sarunas
                    Our friend Šarūnas
                    Our friend Šarūnas
                    

                    And verify if EACH of these three regexes did match the three lines beginning with Our friend ..., right below !

                    Alas, thrice alas ! The program returns the message :

                    D:\>rg --stats --pcre2 (?=[[=O=]])\X(?=[[=u=]])\X(?=[[=r=]])\X(?=[[= =]])\X(?=[[=f=]])\X(?=[[=r=]])\X(?=[[=i=]])\X(?=[[=e=]])\X(?=[[=n=]])\X(?=[[=d=]])\X(?=[[= =]])\X(?=[[=Š=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=ū=]])\X(?=[[=n=]])\X(?=[[=a=]])\X(?=[[=s=]])\X Coises.txt
                    rg: PCRE2: error compiling pattern at offset 12: POSIX collating elements are not supported
                    
                    D:\>
                    

                    Even this simple command, below, fails :

                    D:\>rg --stats --pcre2 [[=q=]] Coises.txt
                    rg: PCRE2: error compiling pattern at offset 9: POSIX collating elements are not supported
                    
                    D:\>
                    

                    You can verify this assumption, at the end of this page : https://www.regular-expressions.info/refcharclass.html

                    7ea82473-ab89-4100-8ef8-37b0f0dbd412-image.jpeg


                    Now, you said :

                    I’m curious whether you, or anyone, foresees practical cases in which you would want to omit one from a search but not the other.

                    Well, I do not need that distinction for myself ! It’s just that your excellent Search in Files dialog can already filter :

                    • By folder

                    • And /or by included extensions or excluded extensions or regex

                    • And/or by size

                    • And/or by date-type and date

                    Thus, it seemed to me that you could also add these two separate options Hiden files and Hidden folders, in order that this dialog was even more flexible ! But, of course, do as you like ;-)

                    Best Regards,

                    guy038

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

                      Hello, @coises and All,

                      You said, in a previous post :

                      I do think it would be possible, and that it would be a useful enhancement.

                      I haven’t studied the problem in detail yet. The relevant concepts exist and are well-defined: Unicode canonical equivalence and compatibility equivalence. Probably someone has already implemented practical searches using canonical and compatibility equivalence in open source code,

                      To my mind, we do not need the help of anyone to achieve such a feature. Of course, my statement seems a little pretentious, but consider this :


                      In your Search++ plugin’s code, the ONLY thing you have to do, in order to use this fantastic improvement, would be :

                      • When the Plain button is selected, to use this layout :
                       □ M̱atch case     □ Whole word only
                      
                                        □ Matches all U̱nicode forms
                      
                      • When the Regex button is selected, to use this layout :
                       □ M̱atch case     □ Ḏot matches line breaks
                      
                       □ Free spacing̱   □ Unicode word ḇoundaries ( greyed )
                      
                      • When the ICU button is selected, to use this layoout
                       □ M̱atch case     □ Ḏot matches line breaks
                      
                       □ Free spacing̱   □ Unicode word ḇoundaries
                      

                      Thus, when the Search++ dialog is selected :

                        ALT + B  toggles 'Unicode word boundaries'  ( ICU mode )
                        ALT + D  toggles 'Dot matches line breaks   ( Regex / ICU mode )
                        ALT + G  toggles 'Free spacing'             ( Regex / ICU mode )
                        ALT + M  toggles 'Match case'               ( Plain / Regex / ICU mode )
                        ALT + U  toggles 'Match all Unicode forms'  ( Plain mode )
                        ALT + W  toggles 'Whole word only'          ( Plain mode )
                      
                      • Then, as long as, both, the Plain button and the Match all Unicode forms option are selected :

                      • Switch INTERNALLY to the Regex mode

                      • Replace, INTERNALLY, ANY character • of the text ( ABOVE \x001F and different from \R), within the search window, by the regex (?=[[=•=]])\X

                      That’s all !


                      One short example : internally, IF the search dialog contains :

                      • The Sarun string, you would change it with the regex (?=[[=S=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=u=]])\X(?=[[=n=]])\X

                      • The Šarūn string, you would change it with the regex (?=[[=Š=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=ū=]])\X(?=[[=n=]])\X

                      • The Šarūn string, you would change it with the regex (?=[[=S=]])\X(?=[[=a=]])\X(?=[[=r=]])\X(?=[[=u=]])\X(?=[[=n=]])\X

                      And you can verify that each of these three regexes do match the three strings Sarun, Šarūn and Šarūn , simultaneously !!

                      Best Regards,

                      guy038

                      P.S. :

                      • In the first string Sarun, NO character with an accent

                      • In the second string Šarūn, two single chars with an accent ( Š and ū )

                      • In the third string Šarūn, two characters with a base letter ( S and u ) followed with an accent ( ̌ and ̄ )

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

                        @guy038 said:

                        In your Search++ plugin’s code, the ONLY thing you have to do, in order to use this fantastic improvement, would be :

                        • When the Plain button is selected, to use this layout :
                         □ M̱atch case     □ Whole word only
                        
                                          □ Matches all U̱nicode forms
                        

                        Well, one immediate problem is that [[=x=]] doesn’t respect case, regardless of whether (?i) or (?-i) is in effect.

                        Beyond that, I’m thinking that there ought to be the ability to choose to match using canonical equivalence or compatibility equivalence. In fact, for plain text searches especially, I suspect canonical equivalence is what most people would expect. It probably should be the default.

                        1 Reply Last reply Reply Quote 0

                        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