ameyp / CscopeSublime

A Cscope plugin for Sublime Text 2 and 3
89 stars 37 forks source link

Fuzzy Searching for Cscope Symbols #10

Closed blockbomb closed 11 years ago

blockbomb commented 11 years ago

I have no clue how to implement this but I really like the fuzzy finding of files in sublime text [ctrl+p] and if we could somehow create a fuzzy search for symbols without totally destroying responsiveness we should try what's the worst that could happen.

the problem is that sublime text 2 has a list of all files in a project ready to be processed where CscopeSublime has to query the Cscope database to get it's dataset to process. if there was a way to get the list of every symbol in the database and perform a fuzzy search algorithm on that fixed set we should be able to make something work.

then create a function that the users begins to typing in what they think the symbol is and CscopeSublime pop's up options to querty the Cscope Database with. Not a high priority but would certainly make the plug-in stand out. this could be a great addition to #8

vanrijn commented 11 years ago

I think it's a neat idea, but I'm concerned about being able to pull this off, especially with large projects. For instance, I mainly use ST2 for my work, where I work on an extremely large code base. My cscope.out file is 280 MB in size. When I invoke CscopeSublime, looking for a symbol, it takes about 8 seconds before I get a response back from the plugin. And this is on a 2.2 GHz Intel Core i7 MacBook Pro with 16 GB of RAM. I question whether we'd be able to do something like what you're proposing on a project of this size.

However, from what I've heard, SublimeText3 sounds like it actually has a working "GoTo Symbol" feature that seems to work very well, based on what one of my co-workers tells me. I think right now it only takes you to the symbol definition, which is only a fraction of what Cscope does for us. But I'm hoping that it will soon provide a "show me all the places where this symbol is used or defined", and if it does, Cscope may be unnecessary.

Anyway, this sounds like it might be something to keep in mind although I'd probably sooner put my efforts behind getting ST3's Goto Symbol functionality to match what we get from Cscope. =:)

ameyp commented 11 years ago

I thought ST3's Goto Symbol functionality was only working for scripting languages like JS and Python. Does it work for C++ too?

I don't know how feasible this idea is, I think it would work better with a plugin like CTags, where you already have a plaintext file that has a list of all symbols. As far as I know cscope doesn't allow you to, say, list all global symbols in the database.

ameyp commented 11 years ago

About the long response times you're facing. I've seen the same issue a couple of times at work, do you think it would be better if the plugin did the cscope query in another thread and then displayed the results? It would still take 8 seconds to show anything, but in the meantime I could just update the statusbar with "Fetching results" or something like that instead of the whole editor just hanging.

Thoughts?

vanrijn commented 11 years ago

Hi Amey! I believe ST3's Goto Symbol functionality works for C and C++ too, although I'm not 100% sure.

As for the 8 seconds... I definitely wasn't complaining!! =:) But now that you mention, I think it would be great if CscopeSublime could use threads! The user could get immediate feedback that work is being done in response to his action, and then the results could show as soon as they're done. I think that would be much cleaner and more user-friendly!

ameyp commented 11 years ago

Cool, I'll get started on this, I've raised an issue to track this: https://github.com/ameyp/CscopeSublime/issues/13

vanrijn commented 11 years ago

I'm inclined to close this issue now. Now that I think about it, to do this, I think we'd have to bring the entire cscope database into memory to try to do something like this and that's definitely not something we're going to do. The cscope database I'm dealing with right now, for instance, is 282 MB. I think we've covered the functionality that cscope provides and to do something like this issue would be going outside of cscope's functionality. I do appreciate the suggestion, but this one just isn't going to happen. If you want to try to do something like this, I would be more than willing to look at a pull request! =:)