Skip to content

Commit

Permalink
Open the blob corresponding to the diff line
Browse files Browse the repository at this point in the history
  • Loading branch information
koutcher committed May 15, 2024
1 parent 587a59a commit c0fee6a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Release notes
=============

master
------

Improvements:

- Open the blob corresponding to the diff line. (#1334)

tig-2.5.10
----------
Expand Down
9 changes: 5 additions & 4 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ diff_get_lineno(struct view *view, struct line *line, bool old)
}

static enum request
diff_trace_origin(struct view *view, struct line *line)
diff_trace_origin(struct view *view, struct line *line, enum request request)
{
struct line *commit_line = find_prev_line_by_type(view, line, LINE_COMMIT);
char id[SIZEOF_REV];
Expand Down Expand Up @@ -704,10 +704,10 @@ diff_trace_origin(struct view *view, struct line *line)
}

string_ncopy(view->env->file, commit.filename, strlen(commit.filename));
string_copy(view->env->ref, header.id);
string_copy(request == REQ_VIEW_BLAME ? view->env->ref : view->env->commit, header.id);
view->env->goto_lineno = header.orig_lineno - 1;

return REQ_VIEW_BLAME;
return request;
}

const char *
Expand Down Expand Up @@ -782,7 +782,8 @@ diff_request(struct view *view, enum request request, struct line *line)
{
switch (request) {
case REQ_VIEW_BLAME:
return diff_trace_origin(view, line);
case REQ_VIEW_BLOB:
return diff_trace_origin(view, line, request);

case REQ_EDIT:
return diff_common_edit(view, request, line);
Expand Down

0 comments on commit c0fee6a

Please sign in to comment.