Author Topic: Can't find in files in Linux with nonstandard file extensions... bug perhaps?  (Read 4983 times)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Guys, I've noticed something recently. I'm using CB 8.02 (and later tested it with SVN 4967). Find in files doesn't work with non-cpp files (like .php or .shtml files). No matter what I do, it only finds text in the currently open files.

The files i'm currently working on are under /var/www/html, but the problem also happens if the project's under /home.

Can anyone confirm if this happens too? Thanks!

P.S. I renamed the files to .cpp and it appears that not even with that cb can find in files. Did I hit a bug, or it's some misconfiguration in my box?

Edit: This is some of what appeared in the search log.
==========| |=== "css" ===|
| |not found in 15 files|
==========| |=== "href" ===|
| |not found in 15 files|

« Last Edit: March 21, 2008, 09:13:07 pm by rickg22 »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
It seems the HTML code confuses the search. I'll have to run cb with the --debug-log option and add some debug lines to see what's doing wrong...

I'll report back when I get more results.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
I just tried with *.php, *.html and *.css.
On my box it works as expected if the user rights are set coorrectly. If there are no read-rights it says "no files to search".

debian sid/experimental, wxWidgets 2.8.7, svn4967, default-encoding is utf-8

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
The files i'm using are saved in ISO-8859-1. I'll try - WHOA!!! YOU DID IT!!! Thanks a lot, jens! I saved the file as UTF-8 and the search was performed correctly!

So the search only fails if the files are saved as ISO-8859-1 (or maybe just not UTF-8).

Also, I just found out something very interesting.

Quote
The 18 March 2008 build (4966) is out.
* pumped wxScintilla to v1.71.1 (latest version available) which includes Scintilla v1.62

And in the Scintilla history (  http://scintilla.sourceforge.net/ScintillaHistory.html ) :

Quote
Release 1.63
* Searching bugs fixed.

It's interesting to notice that Scintilla is currently on version 1.76!!!  :shock:
Perhaps that's the problem. We're using an outdated and buggy scintilla build :(

Anyway, I'm not even sure if this happens all the time, but I'm able to replicate the success (non-bug) if i save as UTF-8. If i save to ISO-8859-1, close CB and reopen, the string in question isn't found. (Perhaps this is why the bug doesn't appear in Windows - i.e. UTF-8/unicode issues?)

I'm thinking that when opening files normally in CB, some encoding conversion is performed, and that isn't the case when finding in files. Can anyone confirm is this is the case?


Just to confirm, jens... in C::B, in editor, change the default encoding to ISO-8859-1. Edit a file, save, close, close CB, reopen it, and search for a string using find-in-files. Is the string found in the new file?
« Last Edit: March 22, 2008, 04:09:29 am by rickg22 »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
It happens for me if I have files encoded in iso8859-1 that contain special chars (like ä, â, ñ or è in comments for example).

It doesn't matter if default-encoding is iso8859-1 or utf-8, the files are not found, if they are encoded in iso8859-1.

If they are encoded in utf-8 search works as expected.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Confirmed, then. It is a bug. :) Now where was my berlios pw?  :P

Edit: Submitted the bug as http://developer.berlios.de/bugs/?func=detailbug&bug_id=13423&group_id=5358

Please fix soon! :( find-in-files is a feature i depend on! Thanks :)
« Last Edit: March 22, 2008, 08:06:26 pm by rickg22 »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Update: After a while of testing and updating, I managed to recompile C::B with the latest version of scintilla - 1.76.

The results are: Failure. The bug's still present. So it's not a Scintilla bug, but rather a mere character encoding issue.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
I DID IT!!!!
« Reply #7 on: March 23, 2008, 08:12:43 am »
The trick was replacing control->LoadFile with the new EncodingDetector class.

Here's the relevant code in editormanager.cpp: (from line 2199 approx.)
Code
        // check if the file is already opened in built-in editor and do search in it
        cbEditor* ed = IsBuiltinOpen(filesList[i]);
        if (ed)
            control->SetText(ed->GetControl()->GetText());
        else {
            EncodingDetector detector(filesList[i]);
            if(!detector.IsOK()) {
                continue;
            }
            control->SetText(detector.GetWxStr());
        }

Note that editormanager.cpp needs the following line around the beginning:
Code
#include "encodingdetector.h"

With this little modification, everything works!!! :D

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: I DID IT!!!!
« Reply #8 on: March 23, 2008, 11:10:08 am »
The trick was replacing control->LoadFile with the new EncodingDetector class.

....

With this little modification, everything works!!! :D

Rick, I've applied the patch in SVN. :)
Be a part of the solution, not a part of the problem.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Yay! :D