Closed vanrijn closed 11 years ago
I would tend to agree with you on this one, it would be nice to set the symbol to query without having to have it under the cursor. but we should keep the streamlined ability to lookup directly under the cursor as I use this a lot minimizing keystrokes. maybe add a new function or hotkey to "query" or "find" in the database.
when ran, it opens an overlay or split with a default value of the text under the cursor pre selected such that you can change it if you desire or set search options like ignore case and etc... ctrl+f,ctrl+s -> find symbol ctrl+f,ctrl+d -> find defintion ctrl+f,ctrl+e -> find callees ctrl+f,ctrl+r -> find callers
Here's what the Emacs/Cscope options look like:
Basically, the current CscopeSublime functionality matches "Find symbol no prompting", I think. It's interesting to note that only one of the Emacs/Cscope menu items uses "no prompting". It defaults to prompting the user, which I think is a good idea by default.
Would it be offensive to pop up an overlay that lets the user confirm or edit the symbol to ask CscopeSublime to look up by default? It would mean that the keystroke would be ctrl+f,ctrl+s,enter (adding an enter key on to confirm the symbol). Maybe if it was configurable via settings to turn the confirmation prompt off?
What would be super cool, I think, would be to have a "Find in files..." type of functionality with CscopeSublime, where the user could put in whatever search criteria they want, defaulting to the word that currently has focus, and then allow the user to specify the type of search (Find symbol, Find global definition, Find functions calling a function, Find called functions, Find text string, Find a file, Find files #including a file), etc. And tie it to a "Cscope Advanced Search..." menu or something. Maybe something to keep in mind for the future.
Right now I'd just like to be able to do a symbol search and enter something not present in the file I'm viewing. =:)
I agree, this would be a nice feature to have, and I don't think most users would mind an additional keypress. To get started, the best place would probably be sublime.active_window().show_input_panel(caption, initial_text, on_done, on_change, on_cancel)
here. Please let me know if you get stuck anywhere.
@vanrijn Have you started working on this yet? Need help with anything?
Hey Amey, no, not yet. I just haven't had the time yet.
No worries :)
I was just starting to look into this a bit. There's a couple of ways of doing this:
1) Always prompt the user to confirm via an show_input_panel (this would require 1 additional keystroke of
2) Add a new command to the plugin, like CscopeConfirmCommand that would prompt the user first, defaulting to whatever word(s) are selected. And then have the on_done call into the existing CscopeCommand. This would require at least one additional context menu with the text "Cscope: Look up symbol..."? I think that would be confusing, especially since we have 5 modes, so I wouldn't want to provide 5 new menu items or whatever.
3) Provide a new config setting called "confirm_before_searching" or something that defaults to true, but allows users to disable the prompting behavior.
I don't like approach 2. I think approach 1 and 3 would be good.
What do you think?
Oh... one other thing that confused me... It looks like there can be multiple words selected and multiple cscope searches going on at the same time?
for sel in self.view.sel():
symbol = self.view.substr(self.view.word(sel))
worker = CscopeSublimeWorker(
view = self.view,
platform = sublime.platform(),
root = self.root,
database = self.database,
symbol = symbol,
mode = mode
)
worker.start()
workers.append(worker)
Maybe if more than one symbol is selected, we don't prompt the user? Or am I misunderstanding this?
Okay, it looks like the multi-select cscope lookup doesn't actually work today anyway? I get this error in the console when I try:
Traceback (most recent call last):
File "./cscope.py", line 319, in
So it looks like only the first selection is able to be searched? Or is this a bug/regression?
Apologies, I've been remiss in my duties. Had some other stuff going on.
Actually, the multi-symbol search is that way solely because Sublime's view.sel()
returns an array of selections. I haven't actually tested it to see if it works (and evidently it doesn't) so we could just pick the first selection and drop the rest. I've never actually felt the need to search for different symbols at once, have you?
Yeah, you're completely right. Okay, I'll add to this branch to make it clear that we only support one lookup, not multiples. =:)
I'm going to open a new issue to track only doing a single query instead of multiples and close this one since this issue has been fixed. =:)
I'm coming from Emacs to Sublime Text and I'll just say that if this Cscope plugin didn't exist for Sublime Text 2, I would not be using ST2. So THANK YOU very much Amey! =:)
But there's a couple of things that I really like in the Emacs/Cscope integration that aren't there (yet =;)) in CscopeSublime that I'd like to help add.
This first issue is around the user interaction before the Cscope database is searched. In Emacs, the user is allowed to confirm or change the symbol that is being looked up before the database is searched. I use this all the time in Emacs to lookup a symbol that I'm looking for even though I don't know where it is in the source code. For example, I'm doing code review for a colleague and they use the constant FOO_BAR_BAZ. In Emacs, I can open any source file, start a Cscope symbol search for whatever my cursor happens to be on, and when Emacs prompts me for the symbol to lookup, I can change it to FOO_BAR_BAZ.
The Ctags Sublime plugin works kind of the same way in that it pops up an editable menu/list at the top of the window that the user can use to type in and narrow his search results down. I think it would be really nice to provide this same kind of functionality to CscopeSublime.
What do you think?
And I'm more than willing to dive in and add the code to do this, but I wanted to check with you first to see if you'd be open to it.
Thanks very much!!