facelessuser / Rummage

Rummage is a GUI for grep like searches in Python
https://facelessuser.github.io/Rummage/
MIT License
74 stars 10 forks source link

Linux: "Files which match" option doesn't work for excluded files #421

Closed toxpal closed 3 years ago

toxpal commented 3 years ago

This option works fine for "normal" match, when you enter a list of files to match. For example:

*.css|*.js|*.php

finds matches in css/js/php files and ignores rest files. However, I can't get it to work if I need to exclude some files. Let's say I want to math all the files listed above, except "file.php". As per documentation (Example Patterns), I enter:

*.css|*.js|*.php|-file.php

and file.php is still matched. If I enter just:

-file.php

no single file is matched at all. Search always returns 0 matches.

Running Manjaro KDE with latest version of Rummage and Python 3.8.6

facelessuser commented 3 years ago

I'm going to need more information. The underlying library used is wcmatch, which I wrote. Using that library, I get proper behavior:

>>> from wcmatch import glob
>>> glob.globfilter(['test.php', 'file.php'], '*.php|-file.php', flags=glob.S | glob.N | glob.M)                                                                                  
['test.php']

I'll need a better understanding of what version of everything you are using and example file paths that are getting evaluated, along with file search settings:

  1. Can you paste info from Help -> Support Info here?

  2. Can you provide a minimal example. Failing file paths relative to your base path?

  3. Maybe a screencap of your search settings from the Preferences' Search tab?

@gir-bot add S: more-info-needed

toxpal commented 3 years ago

Sure.

- Arch: 64bit
- Platform: linux
- Python: 3.8.6 (CPython)
- Rummage: 4.14 final
- WxPython: 4.1.0 gtk3 (phoenix) wxWidgets 3.1.4
- Backrefs: 4.3
- Bracex: 2.0
- Wcmatch: 7.0
- Chardet: 3.0.4
- cChardet: Version could not be acquired!
- Regex: Version could not be acquired!
- Filelock: 3.0.12
- Gntp: 1.0.3
- Markdown: 3.2.1
- Pymdown Extensions: 7.1

File/folder structure - https://i.postimg.cc/XYcdJnfQ/files.png

Search settings (I'm trying to exclude file "mpt_upgrade.php") - https://i.postimg.cc/bwjBG0M8/rummage-settings.png

Search results - https://i.postimg.cc/fTW3M1Wh/rummage-results.png

Preferences - https://i.postimg.cc/ncK6GwqM/rummage-preferences.png

facelessuser commented 3 years ago

Can I get a search preference screen cap? From the the file menu preferences?

toxpal commented 3 years ago

Yes, just updated the post with it.

facelessuser commented 3 years ago

Cool, I'll check a little later when I'm in the office.

facelessuser commented 3 years ago

Small note, it may not be a factor, but I'd update wcmatch to 7.1.

toxpal commented 3 years ago

Just updated, but no luck...

facelessuser commented 3 years ago

Hmm, there may be a bug in processing the setting that controls - negation vs ! negation.

Try using ! as a workaround.

@gir-bot remove S: triage, S: more-info-needed @gir-bot add T: bug

facelessuser commented 3 years ago

Looks like a config issue on Rummage's side dealing with the config option as wcmatch seems to behave fine.

This is the method Rummage uses to crawl directories:

Without exclusion:

>>> list(wcmatch.WcMatch('.', '*.py').match())
['./setup.py']

With exclusion:

>>> list(wcmatch.WcMatch('.', '*.py|!setup.py').match())
[]

With minus exclusion:

>>> list(wcmatch.WcMatch('.', '*.py|-setup.py', flags=wcmatch.M).match())
[]

So, the library is fine. We just aren't passing the flag properly. This looks like a regression in Rummage itself.

facelessuser commented 3 years ago

Turns out we were masking some flags incorrectly. Should have a fix out soonish.

facelessuser commented 3 years ago

Fix has been released

toxpal commented 3 years ago

Works fine now. Thank you for super-fast fix.

facelessuser commented 3 years ago

No problem. I would have noticed this sooner, but I've been using ! for negations recently. I knew the underlying library worked properly as I had plenty of tests for it, but I hadn't confirmed that I hadn't broken anything in Rummage 😬.