Author Topic: Exclude binary files in search of files with no extensions  (Read 2580 times)

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Exclude binary files in search of files with no extensions
« on: August 15, 2018, 01:18:00 AM »
I was doing a search in my "bin" directory, looking for a script that contains a certain word.

In this "bin" directory, there are script files with no extension that are purely text. There are also binary executables in this directory with no extension.

In Tools->Editing->Search, the help for "Exclude binary files" states: "automatically exclude known binary file extensions". However, "no extension" files can mean binary or not binary in my "bin" directory. As a result, even though I have "exclude binary files" checked, I do see undesired search results of binary files that have no extension.

It would be nice if this "exclude binary files" could detect that a file is binary (for example, has characters in a certain byte range) and automatically excludes them from search results instead of relying on the extension, which is not useful in this example.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6868
  • Hero Points: 528
Re: Exclude binary files in search of files with no extensions
« Reply #1 on: August 15, 2018, 03:32:58 PM »
Beta 2 will support this Exclude binary files feature in a better way but it won't change this issue.

Automatically detecting Unix binary files would be very useful. We'll see if we can make this smarter.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: Exclude binary files in search of files with no extensions
« Reply #2 on: August 15, 2018, 03:39:33 PM »
Thanks Clark!

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6868
  • Hero Points: 528
Re: Exclude binary files in search of files with no extensions
« Reply #3 on: August 16, 2018, 03:40:47 AM »
This will be smarter in Beta 2.

If you specify <Binary Files> in your excludes (<Default Excludes> contains <Binary Files> by default), additional logic will occur to exclude files that contain binary data. The algorithm used isn't amazing but it works quite well in practice. For example, this algorithm may or may not skip vrestore.slk because it contains a bit of binary data. It only looks at the first 2k of the file and only considers certain low bytes as binary. Files with text BOM markers are always considered non-binary (Utf-8, Utf-16, Utf-32).

At the moment, this additional logic doesn't support the "List filenames only" or "List current context" options.

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: Exclude binary files in search of files with no extensions
« Reply #4 on: August 16, 2018, 01:23:58 PM »
Thank you very much Clark! +1

I usually have "list current context" checked - so having it work with that will also be useful for me, but I really appreciate what you have already done and so quickly!

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6868
  • Hero Points: 528
Re: Exclude binary files in search of files with no extensions
« Reply #5 on: August 16, 2018, 02:19:45 PM »
Added support for "list current context"

rowbearto

  • Senior Community Member
  • Posts: 2335
  • Hero Points: 132
Re: Exclude binary files in search of files with no extensions
« Reply #6 on: August 16, 2018, 02:21:09 PM »
Thanks Clark!

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6868
  • Hero Points: 528
Re: Exclude binary files in search of files with no extensions
« Reply #7 on: August 16, 2018, 10:03:39 PM »
Added support for "List filenames only"

Now if you edit a file of an unknown type (no extension or unknown extension) that has binary data, the Binary language mode is used.