ameyp / CscopeSublime

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

Cscope: "Rebuild database" does not create cscope.out if one does not already exist #53

Closed zwsu closed 7 years ago

zwsu commented 8 years ago

Thanks for your works on is useful plugin. The Function Rebuild database works fine in windows 7 x64, but when I trys it in Windows 10 x64, cscope.out does't create.

vanrijn commented 8 years ago

Hi @suzhiwei. I don't have a Windows 10 environment to test this on. Can you give me some more information please? What version of Sublime Text are you using? What version of cscope are you using? Does an error show up in Sublime Text's console view (Control+`)? What happens if you open a command prompt and run "cscope -Rbqk" yourself? Do you see an error then?

zwsu commented 8 years ago

I use Package Control to setup CscopeSublime, , Sublime Text Version is 3114 windows x64, cscope version is 15.8a, and drop it in system path (C:\windows\) , I change CscopeSublime setting to ("executable": "cscope.exe") Not anything output information in Sublime Text's console after I click (Cscope: Rebuild database) in sublime text side-bar fold menu item, it just flash a command win.

Sublime Text's console View On startup:

startup, version: 3114 windows x64 channel: stable executable: /C/Program Files/Sublime Text 3/sublime_text.exe working dir: /C/Users/SG01 packages path: /C/Users/SG01/AppData/Roaming/Sublime Text 3/Packages state path: /C/Users/SG01/AppData/Roaming/Sublime Text 3/Local zip path: /C/Program Files/Sublime Text 3/Packages zip path: /C/Users/SG01/AppData/Roaming/Sublime Text 3/Installed Packages ignored_packages: ["Vintage"] pre session restore time: 0.447185 startup time: 1.78719 first paint time: 1.79218 first paint time: 1.79319 reloading plugin Default.auto_indent_tag reloading plugin Default.block reloading plugin Default.comment reloading plugin Default.convert_syntax reloading plugin Default.copy_path reloading plugin Default.delete_word reloading plugin Default.detect_indentation reloading plugin Default.duplicate_line reloading plugin Default.echo reloading plugin Default.exec reloading plugin Default.fold reloading plugin Default.font reloading plugin Default.goto_line reloading plugin Default.history_list reloading plugin Default.indentation reloading plugin Default.kill_ring reloading plugin Default.mark reloading plugin Default.new_templates reloading plugin Default.open_context_url reloading plugin Default.open_file_settings reloading plugin Default.open_in_browser reloading plugin Default.pane reloading plugin Default.paragraph reloading plugin Default.paste_from_history reloading plugin Default.profile reloading plugin Default.quick_panel reloading plugin Default.run_syntax_tests reloading plugin Default.save_on_focus_lost reloading plugin Default.scroll reloading plugin Default.set_unsaved_view_name reloading plugin Default.show_scope_name reloading plugin Default.side_bar reloading plugin Default.sort reloading plugin Default.swap_line reloading plugin Default.switch_file reloading plugin Default.symbol reloading plugin Default.transform reloading plugin Default.transpose reloading plugin Default.trim_trailing_white_space reloading plugin CSS.css_completions reloading plugin Diff.diff reloading plugin HTML.encode_html_entities reloading plugin HTML.html_completions reloading plugin 0_package_control_loader.00-package_control reloading plugin 0_package_control_loader.02-bz2 reloading plugin Cscope.cscope reloading plugin Package Control.1_reloader reloading plugin Package Control.2bootstrap reloading plugin Package Control.Package Control plugins loaded Package Control: Skipping automatic upgrade, last run at 2016-07-14 09:06:33, next run at 2016-07-14 10:06:33 or after

I run "cscope -Rbqk" by myself in the test fold, it's fine. D:\test_code 2016/07/14 09:53

. 2016/07/14 09:53 .. 2016/07/14 09:53 3,584 cscope.in.out 2016/07/14 09:53 162 cscope.out 2016/07/14 09:53 36 cscope.po.out 2016/07/14 09:19 64 main.c

and I try to rebuild database again in sublime text, the Sublime Text's console View add an output: Database found: D:\test_code\cscope.out

by the way, other function of Cscopesublime works well after i make cscope.out myself.

zwsu commented 8 years ago

Pass: In case, I run "cscope -Rbqk" in a outside command prompt myself, and then rebuild database in Sublime text, console output (Database found: D:\test_code\cscope.out), after that I delete (cscope.in.out,cscope.out,cscope.po.out) and rebuild again, it works!

canfoderiskii commented 8 years ago

+1

vanrijn commented 8 years ago

Oh okay.... I think what you're saying is that "rebuild database" does not work if there was no previous database file found, right?

Yes, this makes sense now.

The problem, I think, is that the cscope sublime plugin doesn't know where to create your cscope database file. So what it does currently is it looks to see if it can find an existing one, and then rebuilds it. This is why the text of this command is "rebuild database", not "build/create database". So what the code does is it takes the current open file and then looks in the parent directory recursively until it either finds a cscope.out file or reaches the root node in the directory tree. If it can find one, it can rebuild it. If it can't find one, it doesn't know where to create it for the first time and just does nothing.

I would LOVE to improve this behavior, but I'm not quite sure how. As far as I've seen, there's no way to ask Sublime Text what the root of the project is, and I haven't seen anything that would tell me what a safe directory would be to create cscope.out in. You certainly wouldn't want a cscope.out to be created in c:\ if there wasn't an existing cscope.out in c:\myprojects\testcode\, for example.

So I'm definitely open to taking submissions or suggestions for this. I just don't have any good ideas on what safe behavior would be.

canfoderiskii commented 8 years ago

@vanrijn when i call "cscope: rebuild database" from the side bar context menu, is there any way to know about which file or folder is selected by cursor?

vanrijn commented 8 years ago

Hey @canfoderiskii. Hmmm, that's a good question. I don't honestly know. https://github.com/ameyp/CscopeSublime/blob/master/cscope.py#L420 is where we run from, whether it's from the side bar context menu or from the command palette, etc. I would assume that the "view" that available to the plugin is whatever tab is selected, but I don't know for sure.

vanrijn commented 7 years ago

I just submitted pull #57 that should address this. It should work if you're working in a project that includes 1 path. If this doesn't address your needs, please let me know what you think should be used as the root folder for running the cscope rebuild database command.