From 8bc183a37daa598913a2f9f0b1304b917e819984 Mon Sep 17 00:00:00 2001 From: watergear Date: Wed, 28 Sep 2016 09:50:07 +0800 Subject: [PATCH] Fix goto diff for single line only (base on Git 2.10.0). like: --- a/hello.txt +++ b/hello.txt @@ -1 +1 @@ -hello world! \ No newline at end of file + new line \ No newline at end of file --- a/hello.txt +++ b/hello.txt @@ -1 +1,2 @@ -hello world! \ No newline at end of file + hello world! + new line \ No newline at end of file --- a/hello.txt +++ b/hello.txt @@ -1,2 +1 @@ - hello world! new line \ No newline at end of file --- git/diff.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git/diff.py b/git/diff.py index a4c55d82..c7e59633 100644 --- a/git/diff.py +++ b/git/diff.py @@ -90,12 +90,12 @@ def run(self, edit): pt = v.line(pt - 1).a - hunk = re.match(r"^@@ -(\d+),(\d+) \+(\d+),(\d+) @@.*", hunk_line) + hunk = re.match(r"^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@.*", hunk_line) if not hunk: sublime.status_message("No hunk info") return - hunk_start_line = hunk.group(3) + hunk_start_line = hunk.group(4) self.goto_line = int(hunk_start_line) + line_offset - 1 git_root_dir = v.settings().get("git_root_dir")