Community
    • Login

    Show only lines that contain a search term

    Scheduled Pinned Locked Moved General Discussion
    35 Posts 6 Posters 7.2k Views
    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.
    • Alan KilbornA
      Alan Kilborn @guy038
      last edited by Alan Kilborn

      @guy038 said in Show only lines that contain a search term:

      I have not finished cleaning my old micro and moved all my data yet,

      What is taking so long? Are you ever going to finish with this?? :-)


      I still use a USB key containing the N++ portable version 8.4.6 for all my tests, which must certainly slow down the execution of your Python script ??

      I don’t see how…everything should be “in memory” for the operations of the script.


      I’m really surprised that I never encountered any visible false lines during my tests

      Yes that is interesting…


      You should indeed remove these false positive answers, first of all !

      Indeed. However, at the moment, I’m out of ideas on what the problem might be. :-(

      datatraveller1D 1 Reply Last reply Reply Quote 1
      • datatraveller1D
        datatraveller1 @Alan Kilborn
        last edited by

        Hi all,
        Just two thoughts

        1. I’m not sure - what does PC speed have to do with line visibility?

        2. Doesn’t “Find All in Current Document” basically do the same thing as the Python script? Actually, the Notepad++ programmer just has to output the same thing in the same window to filter the text, doesn’t he?

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @datatraveller1
          last edited by

          @datatraveller1 said in Show only lines that contain a search term:

          I’m not sure - what does PC speed have to do with line visibility?

          I don’t think it has anything to do with it, but until the root cause is found, everything is “on the table” as a possible problem.

          Doesn’t “Find All in Current Document” basically do the same thing as the Python script?

          I think the key idea behind the script is you can edit in the filtered view.

          Michael VincentM 1 Reply Last reply Reply Quote 2
          • Michael VincentM
            Michael Vincent @Alan Kilborn
            last edited by PeterJones

            @Alan-Kilborn said in Show only lines that contain a search term:

            I think the key idea behind the script is you can edit in the filtered view.

            THIS! There is a vi mode for this IIRC, but I just figured with all the plugins and search window in Notepad++ never supporting this editing of the filtered view - just putting the results into a different view - we’d just never get it.

            Thanks @Alan-Kilborn - I assigned a hotkey and will try getting this filtered editing into my workflow.

            Cheers.

            1 Reply Last reply Reply Quote 1
            • datatraveller1D
              datatraveller1 @datatraveller1
              last edited by

              @Alan-Kilborn and @Paul-Wormer

              I have noticed that your line numbers don’t match my line numbers, e.g. my (correct) first occurence of self.settings_by_viewfile_dict is line 42.
              I use the script https://community.notepad-plus-plus.org/post/82787 - Are you perhaps using a different script with potentially problematic changes? Does the problem also occur with this original version?

              Alan KilbornA 1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @datatraveller1
                last edited by

                @datatraveller1 said in Show only lines that contain a search term:

                I have noticed that your line numbers don’t match my line numbers

                I said before “(Don’t be concerned if my line numbers don’t match yours)”.

                The reason for any mismatches would be because I’ve inserted some extra debugging statements in to possibly help solve the problem. As I’m seeing the undesired results with the original code or any variant, what I’ve changed isn’t causing the problem.

                datatraveller1D 1 Reply Last reply Reply Quote 0
                • datatraveller1D
                  datatraveller1 @Alan Kilborn
                  last edited by

                  @Alan-Kilborn ok, sometimes debugging code can also contain errors, but this does not apply in your case.

                  I still get correct results no matter what I filter for :-)

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @datatraveller1
                    last edited by

                    @datatraveller1 , @Alan-Kilborn , @Paul-Wormer,

                    The first time I created the script, and ran it, it properly filtered (showed @datatraveller1’s screenshot). And every subsequent run in that load of Notepad++ worked properly.

                    I then restarted Notepad++, and the first run after restarting gave more lines (some of the comment lines). If I run it and do the clear (shift+OK), then run it to highlight again, it works correctly. If I restart NPP and re-run to get the extra lines, then run again with the same exact search string (not shifted), it filters correctly.

                    The sequence behaves the same when searching for self.settings_by_viewfile_dict or just self.

                    I set the debug flag to TRUE (set that line to a 1 not a 0), restarted Notepad++, and then ran with the longer search string again.
                    For the bad highlight:

                    LFVH1<DBG>: view_plus_file: 0C:\Users\PJones2\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts\nppCommunity\23xxx\23929-AlanK-LineFilterViaHiding1.py
                    LFVH1<DBG>: view_plus_file: 0C:\Users\PJones2\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts\nppCommunity\23xxx\23929-AlanK-LineFilterViaHiding1.py
                    LFVH1<DBG>: L: [(1648, 1678), (2255, 2285), (2749, 2779), (2939, 2969), (4190, 4220), (4449, 4479), (5182, 5212), (5265, 5295), (5675, 5705), (6407, 6437), (6936, 6966), (7047, 7077), (9877, 9907), (9922, 9952)]
                    

                    for the good highlight immediately after:

                    LFVH1<DBG>: view_plus_file: 0C:\Users\PJones2\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts\nppCommunity\23xxx\23929-AlanK-LineFilterViaHiding1.py
                    LFVH1<DBG>: L: [(1648, 1678), (2255, 2285), (2749, 2779), (2939, 2969), (4190, 4220), (4449, 4479), (5182, 5212), (5265, 5295), (5675, 5705), (6407, 6437), (6936, 6966), (7047, 7077), (9877, 9907), (9922, 9952)]
                    

                    There is no difference in the L list, which says that the problem doesn’t lie in the searching/list, but rather someplace else.

                    Additional datapoint: if I have the bad filter (with extra comments showing), switch to another tab, and switch back, it shows the correct filtering, with the debug info:

                    LFVH1<DBG>: BUFFERACTIVATED: {'code': 1010, 'bufferID': 3019234076800L}
                    LFVH1<DBG>: view_plus_file: 0C:\Users\PJones2\AppData\Roaming\Notepad++\plugins\config\PythonScript\scripts\nppCommunity\23xxx\23929-AlanK-LineFilterViaHiding1.py
                    

                    If I take original line#114 – the self.freshen_user_view_of_active_tab() at the end of prompt_for_string_to_match()'s definition – and duplicate it, so it runs that freshen twice, on the first freshen, it shows wrong; on the second, it shows right.

                    I’m wondering if before the “hide” side of that command, if you need to clear all the lineVisible flags to known values before your script does its hiding… maybe the active lexer or other NPP feature has already tagged some lines in a way that confuses your logic.

                    That’s probably all the time I’ll have for helping debug this today, but I hope some of that info turns out to be useful.

                    PeterJonesP 1 Reply Last reply Reply Quote 3
                    • PeterJonesP
                      PeterJones @PeterJones
                      last edited by PeterJones

                      @Alan-Kilborn , in the other thread, said,

                      I don’t know if we should recommend that script at all until its shortcomings have been addressed.

                      I will admit I haven’t used it much (just the experiments I described yesterday). But my impression was that the redraw bug (which I can get around by changing tabs and back) and slowness (which is to be expected on something like this) were the issues. Was there anything else that would prevent it from being used?

                      Alan KilbornA 1 Reply Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @PeterJones
                        last edited by Alan Kilborn

                        @PeterJones said in Show only lines that contain a search term:

                        Was there anything else that would prevent it from being used?

                        Maybe my use of “…at all” came off as a little strong… I can’t see that it would corrupt data or do anything “bad”.

                        I think the downside to wider use is only the complaints that could arise in the form of “hey, this isn’t working right”. If a tool is supposed to do “X”, and it doesn’t do “X” correctly, well…

                        Paul WormerP 1 Reply Last reply Reply Quote 1
                        • Paul WormerP
                          Paul Wormer @Alan Kilborn
                          last edited by

                          @Alan-Kilborn For a simple script, see https://community.notepad-plus-plus.org/topic/20058/how-do-i-move-bookmarks-to-a-copy-of-the-same-file/20

                          Alan KilbornA 1 Reply Last reply Reply Quote 0
                          • Alan KilbornA
                            Alan Kilborn @Paul Wormer
                            last edited by

                            @Paul-Wormer said in Show only lines that contain a search term:

                            For a simple script

                            I don’t know that that script, being “simpler”, has anything over-and-above my “complicated”(?) one, given that it appears the strangeness with hidden lines continues in that script…

                            Paul WormerP 1 Reply Last reply Reply Quote 0
                            • Paul WormerP
                              Paul Wormer @Alan Kilborn
                              last edited by Paul Wormer

                              @Alan-Kilborn said

                              I don’t know that that script, being “simpler”, has anything over-and-above my “complicated”(?) one, given that it appears the strangeness with hidden lines continues in that script…

                              Your script has a fairly sophisticated UI, colors the margin of the displayed lines, and marks the strings found. My script has none of that. Therefore it has exactly 4 times less lines than yours. A quick fix for the “strangeness with hidden lines” is hiding all lines twice in a row. I’m very interested in hearing about cases where that fix breaks down. In the meantime I have tested the script a lot and so far the fix seems to work, but you never know …

                              Alan KilbornA 1 Reply Last reply Reply Quote 0
                              • Alan KilbornA
                                Alan Kilborn @Paul Wormer
                                last edited by

                                @Paul-Wormer said in Show only lines that contain a search term:

                                A quick fix for the “strangeness with hidden lines” is hiding all lines twice in a row.

                                Meh.

                                1 Reply Last reply Reply Quote -2
                                • Alan KilbornA
                                  Alan Kilborn
                                  last edited by

                                  Due to the problem seen earlier, I decided to take another approach, so that Notepad++ would cooperate better with the lines I was hiding in order to achieve the goals of the script.

                                  Unfortunately, I’ve encountered too many bugs with the hidden lines feature, that it isn’t worth continuing. I think that, at least for now, I’m giving up on this idea…

                                  1 Reply Last reply Reply Quote 2
                                  • First post
                                    Last post
                                  The Community of users of the Notepad++ text editor.
                                  Powered by NodeBB | Contributors