Access to the "index"

I have a “Find References” (and also “Find Symbols”) capability in some of my plugins. I’ve implemented a “preview” like feature which shows the relevant line of text from the file in the side bar results window.

The problem with this is that to implement it I had to open the file so I could read the actual contents of the file for the given line. For some searches, this could open hundreds of files which was super ugly.

What I have now is a compromise, where if the file is not already open I just show the line number of the match and placeholder ellipses.

What I’d really to do is be able to ask Nova for the contents without opening the file (using for example a Range based query). I know Nova can do this because it already does so for it’s builtin search results.

I’d like to have a similar ability expressed in an API.

Can’t you use file = nova.fs.open(path) and contents = file.read()?

I use this in my extension to read the contents of a .gitignore file without opening it in the workspace.

In retrospect, yes, I could do this. But it means that I have to also scan the file. This is expensive, I’d rather not do that-- I believe Nova already has this all indexed.