-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Results keyboard navigation, keyboard shortcuts and fixes #67
base: master
Are you sure you want to change the base?
Conversation
…, fix for file path regex
…ing opened tabs and rebuilding DB, OSX fix
Hi @Filios92!! I meant to answer months ago and got way behind. So sorry about that. Thanks so much for the patch! I'll look through this now. =:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate all the hard work you've done here, but you've submitted a large chunk of changes that are for different features. I'd rather review each piece of functionality individually. As I see it, the logical groups here are:
- Allow multiple project directories to be passed to cscope for database operations
- Add arguments to the CscopeVisiter class so that movement can be added
- Add keybindings and commands for the above
- Change the way results are displayed in a way I don't understand
So... this change is too big as it is. I'd like to focus on the first 2 pieces of functionality first and then look at the other pieces separately. Also, please add comments generously as to exactly what the code is that you're proposing be added. There's a lot of very non-obvious changes you're proposing here.
If you can do that, I'd appreciate it and we can re-look at this patch. =:)
Thanks!
root_re = re.compile(r'In folder (.+)') | ||
filepath_re = re.compile(r'^(.+):$') | ||
filepath_re = re.compile(r'^(((?!scope: ).)+):$') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this change please? Why the change in regexp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If line with symbol ends with ':' it is catched by this regex (seen below), which leads to such error when trying to open results lower than that.
Unable to open file: E:\Dev\C\sandbox\cscope_tmp\ 17 [scope: main] case ENUM_TESTCASE_1
@@ -9,7 +9,7 @@ | |||
<array> | |||
<dict> | |||
<key>match</key> | |||
<string>(.*):$</string> | |||
<string>^(((?!scope: ).)*):$</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why you changed this please? I'm not aware of a problem with this right now, so I'm not sure what this is trying to fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CscopeSublime.sublime-settings
Outdated
|
||
// On default build command, whether to treat folders in project (after the 1st one) as | ||
// additional source directories | ||
"auto_next_source_dirs": false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about the use case here. I've never been part of a project so big that it is split into multiple directories and is not contained within a common parent folder. Can you help me understand what kind of scenario would require this or how you have things set up such that this is useful?
Also, I wonder if we even need auto_next_source_dirs
or if we can do the right thing automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this reason I didn't want to make it default option :) In my case the other folders contain library-like project (used by other 'main' projects also) or headers of this library, it is handy to have these sources in the same project. Sublime Text automatically indexes all folders in the project for definitions, so I guess this is similar behavior.
Also, it wasn't possible to update or create database with more than 1 folder in project, because of restriction ... len(project_info_paths) == 1
Default (Linux).sublime-keymap
Outdated
@@ -51,6 +51,50 @@ | |||
"command": "cscope_visiter", | |||
"context": [{"key": "selector", "operand": "text.find-in-files"}] | |||
}, | |||
{ | |||
"keys": ["j"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather leave out the sublime-keymap changes at least for the first round and just make the changes that are required to support it. Can you remove these sublime-keymap changes for at least this first review and let's get through all the other changes first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
@@ -41,6 +42,14 @@ def get_setting(key, default=None, view=None): | |||
pass | |||
return get_settings().get(key, default) | |||
|
|||
def update_result_selection(view, selection_index, selection, update_sel=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused on what this is doing here too. Can you please help me understand what this is doing that it wasn't already doing? Also, I suspect that this will not work with Sublime Text 2. Thus far, while I'm not actively supporting Sublime Text 2, I've been making sure I at least don't break it with changes. Can you verify that this will at least not cause errors in ST2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep results and currently selected results in view settings of every Cscope results.
I checked on ST2 and fixed scrolling to result and disabled class for mouse support.
But. The master branch wasn't working on ST2 :) Minor problems:
- trailing comma in settings
ValueError: zero length fields name in format
cause of lack of indices in the format specs
cscope.py
Outdated
if self.view.settings().get('syntax') == CSCOPE_SYNTAX_FILE: | ||
if args.get('direction'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand what you're doing here? I gather the concept is to allow navigation in the results buffer using direction increments? Is this assuming there's only 1 cscope results window? I frequently have multiple cscope results windows. I'm not sure what the goal is here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, keyboard navigation. I also have multiple cscope results windows, no problems. Saved results and currently selected result are held in settings 'results' and 'cscope_results_sel' per cscope results buffer/view.
cscope.py
Outdated
what = { | ||
'up': -1, | ||
'down': 1, | ||
'up2': -20, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to do this, I think maybe up/down/pageup/pagedown would be better than up/down/up2/down2 as far as names go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, changed
cscope.py
Outdated
if command_mode in [0, 4, 6, 8]: | ||
if nested: | ||
match_string = ("{0:>6}\n{1:>6} [scope: {2}] {3}").format("..", match["line"], match["scope"], match["instance"]) | ||
match_string['head'] = ("{0:>6}\n").format("..") | ||
match_string['main'] = ("{0:>6} [scope: {1}] {2}").format(match["line"], match["scope"], match["instance"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, going to need help understand what you're doing here too, please, in each of these. I didn't write these regexps originally, so I honestly don't understand what they were doing completely nor what you're changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regexes just format results appearance. I only split them into the 'head' part with the separator ('..') or file path and 'main' part with proper result line, which was needed for keyboard navigation and selecting/highlighting. Effectively there is no difference in appearance.
I would also add the option to the settings for disabling the separator between results altogether.
Hey @Filios92 , I’m so sorry this has gone so long since I last looked at it. I really do appreciate the work you’ve done here. Unfortunately, I am not going to be able to contribute to this project anymore for the foreseeable future, and I’m not going to be able to work through this and get it included. Maybe @ameyp might be able to see this through to completion? Also, would you be interested in helping to maintain this plugin long term? If so, please say so and maybe we can get you added as a contributor so you can merge this change in and help keep this little plugin chugging along? =:) Again, I’m so sorry I can’t keep working with you on this PR. I definitely do not like leaving this halfway done but my hands are tied. =:( |
Hi,
Here's a bunch of features I added some time ago and would like to share, could be merged to master.