Jump to modified file with Enter key in "Git Diff" view #224

merged 11 commits into from Mar 28, 2013


None yet
3 participants

dacap commented Dec 29, 2012

With this patch we are able to use the Enter key in an inserted/eliminated line of "Git Diff" view to jump directly to that location of the modified file.

Part of this feature was requested in issue 104, but instead of using the mouse click we've to press the Enter key when the cursor is over a inserted/eliminated line.


vanrijn commented Feb 5, 2013

I would LOVE to have this working in Sublime Text! Any chance you could get this integrated into the plugin? Thank you!! =:)

vanrijn referenced this pull request in ameyp/CscopeSublime Mar 10, 2013


Jumping To Search Results Is Too Sensitive #7


vanrijn commented Mar 16, 2013

Any updates on this? I think I found an easy way to add double-click functionality to be able to navigate from the git diff buffer to the file that the hunk came from, like I did for CscopeSublime here: https://github.com/ameyp/CscopeSublime/blob/master/Default%20(OSX).sublime-mousemap

But I want to wait until this change is submitted to master before I do so. Any update on when this might be able to get pulled into master?



vanrijn commented Mar 17, 2013

dacap, actually, I have a problem with your patch. If I use this on a project that has multiple directories, the portion of the path in file_name gets duplicated. For example, if my project root is "/Volumes/Wibble" and the file I'm working on inside my project is "foo/bar/baz/wobble.c", inside GitGotoDiff, if I look at file_name and git_working_dir, I see:

file_name == "foo/bar/baz/wobble.c"
git_working_dir = "/Volumes/Wibble/foo/bar/baz"

... which means that file_name gets changed into "/Volumes/Wibble/foo/bar/baz/foo/bar/baz/wobble.c". This obviously fails when I try to open the file from GitGotoDiff because the "foo/bar/baz" path is duplicated.

I'm forked your repository and I'm working on a fix. I also added a mousemap file that works correctly. The file is simply this, called Default.sublime-mousemap:

    // Double-click to go to results
        "button": "button1", "count": 2,
        "press_command": "drag_select",
        "press_args": {"by": "words"},
        "command": "git_goto_diff"

Any ideas on a simple fix for the path duplicating problem? Can we use the project root directory instead of git_working_dir to give the files the right directory paths for sublime?


vanrijn commented Mar 17, 2013

Actually, maybe the right thing to save in git_working_dir would be the root directory of the git repository? Isn't that going to be where all the "git diff" output is going to be relative to? Would this work to get that value? "git rev-parse --show-toplevel"


dacap commented Mar 17, 2013

Hi vanrijn, see the new commit, it should fix the problem. Now the git root directory is stored in the view settings. Also I've tested your double-click mousemap, and it works perfectly 👍


vanrijn commented Mar 17, 2013

Awesome, thanks! I'll test this tomorrow.


vanrijn commented Mar 19, 2013

Hey David, this definitely works better, thank you! It definitely seems to fix the nested directory problem I was seeing. But now I see another problem in that it looks like it's using the project root as the git root directory and not the git root directory for whatever file you're working with.

For example, I have Sublime Text open with one window and 20 tabs because I'm working on my work project directory in "/Volumes/Wibble". I open a terminal, navigate to ~/Library/Application Support/Sublime Text 2/Packages/Git/ to work on the Git plugin. I open diff.py with "subl diff.py", which reuses my existing Sublime Text window. Now I make a change and do a "Git Diff All" from this plugin. That works fine, but when I try to navigate to a hunk in the diff viewer, it's using "/Volumes/Wibble/diff.py" as the path instead of ~/Library/Application Support/Sublime Text 2/Packages/Git/diff.py .

So I think the solution is not yet 100% perfect. =:/

dacap and others added some commits Mar 19, 2013

@dacap dacap Merge pull request #1 from vanrijn/add-double-click-for-git-diff-buffer
Adding double-click mousemap file so we can navigate git diff buffer that way too.
@vanrijn vanrijn removed mousemap 185e968
@dacap dacap Merge pull request #2 from vanrijn/remove-mousemap
removed mousemap

vanrijn and others added some commits Mar 21, 2013

@vanrijn vanrijn Fix incorrect assumption that git_root_dir is populated and allow Git…
…GotoDiff to work with Git Custom commands
@vanrijn vanrijn Sanity-checking git_root_dir and if it's not valid for the current hu…
…nk's file, prompt the user to fix it rather than just failing.
@vanrijn vanrijn Stripping whitespace off filename to fix problem with filename with s…
@dacap dacap Merge pull request #3 from vanrijn/allow-git-goto-diff-to-operate-on-…

Fix incorrect assumption that git_root_dir is populated and allow GitGot...

vanrijn commented Mar 28, 2013

@kemayo, @dacap and I have been using the code in this pull request for a while now and I wouldn't be able to function at work without it. Can you please pull this into your master Git repo so we can both stop maintaining our temp repos? =;D Thanks again for all your work on the Git ST plugin!!!

@kemayo kemayo added a commit that referenced this pull request Mar 28, 2013

@kemayo kemayo Merge pull request #224 from dacap/master
Jump to modified file with Enter key in "Git Diff" view

@kemayo kemayo merged commit 6a118c3 into kemayo:master Mar 28, 2013


vanrijn commented Mar 28, 2013

Awesome, thank you so much @kemayo!!! =:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment