Author Topic: FindInFiles: Context lines before and after  (Read 3243 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
FindInFiles: Context lines before and after
« on: October 03, 2017, 06:04:59 PM »
What are the limit on lines before/after?

I did a search today trying this for the 1st time.
I set it to -2/+2.

It does not print context lines for each match.
If there is a match on lines 10,11,12, then it will show lines 8,9 and 13,14 -- nice.

But, I have matches on lines 266, 273, 284, 291, 302, 308, 338, 349, 367.
It only lists b/a 264,265 and then 368, 369.

Why not 267, 268 and 271, 272?
What is the minimum spread here?

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: FindInFiles: Context lines before and after
« Reply #1 on: October 03, 2017, 06:23:33 PM »
Could you post an example of the output so I can see it?  It's supposed to try to keep contiguous lines together in groups when possible if it is within the +/- range.  Any other options enabled?  Is there anything unique about the source file?  I would expect there be a break to list the context change, but would expect the before and after for each context change.
« Last Edit: October 03, 2017, 06:29:59 PM by Lee »

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: FindInFiles: Context lines before and after
« Reply #2 on: October 03, 2017, 07:07:35 PM »
It is just a text file dump of HKLM:
Code: [Select]
reg query HKLM /s > HKLM.txt
    mark_all_occurences("py.exe","WIP",'0',"8192",'5','0','1','0','1','0','2','2');

I did Find py.exe
Match whole word
List all occurances
ListCurrentContext
B/A -2,+2

The results:
Code: [Select]
Find all "py.exe", Whole word
File C:\Users\joe\AllFiles\HKLM2.txt
          -:
          -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.ArchiveFile\DefaultIcon
  463266 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",5
  463273 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe" "%L" %*
  463284 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",2
  463291 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe" "%L" %*
  463302 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",3
  463308 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",1
  463338 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe" "%L" %*
  463349 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",5
  463367 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",1
          +:
          +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.NoConFile\shell
Total found: 9
The file size is 28,749,166 (I deleted about half of the file past the above matches).


When I remove the first 460,000 lines the problem does not repro.
New size: 169,810 bytes
Then the results look like:
Code: [Select]
Find all "py.exe", Whole word
File C:\Users\joe\AllFiles\HKLM2.txt
        -:
        -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.ArchiveFile\DefaultIcon
  3332 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",5
        +:
        +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.ArchiveFile\shell
---------:
        -:
        -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.ArchiveFile\shell\open\command
  3339 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe" "%L" %*
        +:
        +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.ArchiveFile\shellex
---------:
        -:
        -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.CompiledFile\DefaultIcon
  3350 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",2
        +:
        +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.CompiledFile\shell
---------:
        -:
        -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.CompiledFile\shell\open\command
  3357 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe" "%L" %*
        +:
        +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.CompiledFile\shellex
---------:
        -:
        -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.Extension\DefaultIcon
  3368 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",3
        +:
        +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.File
---------:
        -:
        -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.File\DefaultIcon
  3374 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",1
        +:
        +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.File\shell
---------:
        -:
        -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.File\shell\open\command
  3404 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe" "%L" %*
        +:
        +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.File\shellex
---------:
        -:
        -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.NoConArchiveFile\DefaultIcon
  3415 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",5
        +:
        +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.NoConArchiveFile\shell
---------:
        -:
        -:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.NoConFile\DefaultIcon
  3433 40:    (Default)    REG_SZ    "C:\WINDOWS\py.exe",1
        +:
        +:HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.NoConFile\shell
Total found: 9



Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: FindInFiles: Context lines before and after
« Reply #3 on: October 03, 2017, 08:20:02 PM »
Interesting, there may be a bug with line numbers comparisons for pre/post line check with large file optimizations enabled.  I'll have to double-check those.

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: FindInFiles: Context lines before and after
« Reply #4 on: October 03, 2017, 08:55:27 PM »
WrapLineLength=8001

In this file there are a number of really long lines.
The b/a output seems to be confused by these.

One of these is 49 lines (387657 bytes).

The file is UTF-8.

I did a save-as SBCS/DBCS.
CLosed the file and opened it again.
Now the b/a results are correct.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1299
  • Hero Points: 130
Re: FindInFiles: Context lines before and after
« Reply #5 on: October 04, 2017, 12:28:25 PM »
Thanks for the extra info. that helped.  I've made a few changes that should give more consistent results.