case insensitive file search?


Is it possible to use FilenameIndex to do a case-insensitive search on a filename? The filename in question comes from user input so I can't guess the correct case ahead of time. If not, is there a different way to do this?



If the name specified by the user includes the path, then there's no need to use FilenameIndex at all; LocalFileSystem.findFileByPath() uses the case senstivity rules of the file system on the user's machine.

If you do want to use FIlenameIndex, you need to call getAllKeys(), filter the keys which match the entered name case-insensitively and then get the files for each key. (Of course, this whole process is going to be quite slow.)



Unfortunately the user only enters the file name, not the entire path. There could be multiple matches retrieved which I later filter out according to some other rules. I was hoping to basically have similar functionality to the Find File action (Ctrl+Shift+N). Is there some way to access the logic it uses behind the scenes?

Chris Folger


The name matching logic is implemented by the MinusculeMatcher class; it's fairly easy to reuse. You can also study the implementation of the existing action (GotoFileAction); you may find more pieces that you want to reuse.


Please sign in to leave a comment.