Skip to content

Commit

Permalink
Fix navigation between chunks after splitting chunk (#1162)
Browse files Browse the repository at this point in the history
Also fix the color of the first split chunk.

Closes #1101

Reviewed-by: Johannes Altmanninger <[email protected]>
  • Loading branch information
koutcher authored Jan 4, 2022
1 parent 62eaaf8 commit 1ca8a05
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/stage.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "tig/status.h"
#include "tig/main.h"
#include "tig/stage.h"
#include "tig/search.h"

static struct status stage_status;
static enum line_type stage_line_type;
Expand Down Expand Up @@ -320,8 +321,10 @@ stage_insert_chunk(struct view *view, struct chunk_header *header,
int i;

box = from->data;
for (i = 0; i < box->cells; i++)
for (i = 0; i < box->cells; i++) {
box->cell[i].length = 0;
box->cell[i].type = LINE_DIFF_CHUNK;
}

if (!append_line_format(view, from, "@@ -%lu,%lu +%lu,%lu @@",
header->old.position, header->old.lines,
Expand Down Expand Up @@ -401,6 +404,7 @@ stage_split_chunk(struct view *view, struct line *chunk_start)
if (chunks) {
stage_insert_chunk(view, &header, chunk_start, NULL, NULL);
redraw_view(view);
reset_search(view);
report("Split the chunk in %d", chunks + 1);
} else {
report("The chunk cannot be split");
Expand Down

0 comments on commit 1ca8a05

Please sign in to comment.