Fix placement of images in diff broken by new render layout
This commit is contained in:
parent
e73282ceb0
commit
e0cdc26e68
@ -82,7 +82,7 @@ func (self *LogicalLine) render_screen_line(n int, lp *loop.Loop, margin_size, c
|
|||||||
left_text = format_as_sgr.filler + left_text
|
left_text = format_as_sgr.filler + left_text
|
||||||
} else {
|
} else {
|
||||||
switch self.line_type {
|
switch self.line_type {
|
||||||
case CHANGE_LINE:
|
case CHANGE_LINE, IMAGE_LINE:
|
||||||
left_margin = format_as_sgr.removed_margin + left_margin
|
left_margin = format_as_sgr.removed_margin + left_margin
|
||||||
left_text = format_as_sgr.removed + left_text
|
left_text = format_as_sgr.removed + left_text
|
||||||
case HUNK_TITLE_LINE:
|
case HUNK_TITLE_LINE:
|
||||||
@ -105,7 +105,7 @@ func (self *LogicalLine) render_screen_line(n int, lp *loop.Loop, margin_size, c
|
|||||||
right_text = format_as_sgr.filler + right_text
|
right_text = format_as_sgr.filler + right_text
|
||||||
} else {
|
} else {
|
||||||
switch self.line_type {
|
switch self.line_type {
|
||||||
case CHANGE_LINE:
|
case CHANGE_LINE, IMAGE_LINE:
|
||||||
right_margin = format_as_sgr.added_margin + right_margin
|
right_margin = format_as_sgr.added_margin + right_margin
|
||||||
right_text = format_as_sgr.added + right_text
|
right_text = format_as_sgr.added + right_text
|
||||||
case HUNK_TITLE_LINE:
|
case HUNK_TITLE_LINE:
|
||||||
@ -376,9 +376,13 @@ func image_lines(left_path, right_path string, screen_size screen_size, margin_s
|
|||||||
sl := ScreenLine{}
|
sl := ScreenLine{}
|
||||||
if i < len(left_lines) {
|
if i < len(left_lines) {
|
||||||
sl.left.marked_up_text = left_lines[i]
|
sl.left.marked_up_text = left_lines[i]
|
||||||
|
} else {
|
||||||
|
sl.left.is_filler = true
|
||||||
}
|
}
|
||||||
if i < len(right_lines) {
|
if i < len(right_lines) {
|
||||||
sl.right.marked_up_text = right_lines[i]
|
sl.right.marked_up_text = right_lines[i]
|
||||||
|
} else {
|
||||||
|
sl.right.is_filler = true
|
||||||
}
|
}
|
||||||
ll.screen_lines = append(ll.screen_lines, &sl)
|
ll.screen_lines = append(ll.screen_lines, &sl)
|
||||||
}
|
}
|
||||||
@ -402,6 +406,7 @@ func first_binary_line(left_path, right_path string, columns, margin_size int, r
|
|||||||
for _, x := range splitlines(line, available_cols) {
|
for _, x := range splitlines(line, available_cols) {
|
||||||
sl := ScreenLine{}
|
sl := ScreenLine{}
|
||||||
sl.right.marked_up_text = x
|
sl.right.marked_up_text = x
|
||||||
|
sl.left.is_filler = true
|
||||||
ll.screen_lines = append(ll.screen_lines, &sl)
|
ll.screen_lines = append(ll.screen_lines, &sl)
|
||||||
}
|
}
|
||||||
} else if right_path == "" {
|
} else if right_path == "" {
|
||||||
@ -411,6 +416,7 @@ func first_binary_line(left_path, right_path string, columns, margin_size int, r
|
|||||||
}
|
}
|
||||||
for _, x := range splitlines(line, available_cols) {
|
for _, x := range splitlines(line, available_cols) {
|
||||||
sl := ScreenLine{}
|
sl := ScreenLine{}
|
||||||
|
sl.right.is_filler = true
|
||||||
sl.left.marked_up_text = x
|
sl.left.marked_up_text = x
|
||||||
ll.screen_lines = append(ll.screen_lines, &sl)
|
ll.screen_lines = append(ll.screen_lines, &sl)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -321,15 +321,19 @@ func (self *Handler) draw_image(key string, num_rows, starting_row int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *Handler) draw_image_pair(ll *LogicalLine, starting_row int) {
|
func (self *Handler) draw_image_pair(ll *LogicalLine, starting_row int) {
|
||||||
|
if ll.left_image.key == "" && ll.right_image.key == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer self.lp.QueueWriteString("\r")
|
||||||
if ll.left_image.key != "" {
|
if ll.left_image.key != "" {
|
||||||
|
self.lp.QueueWriteString("\r")
|
||||||
self.lp.MoveCursorHorizontally(self.logical_lines.margin_size)
|
self.lp.MoveCursorHorizontally(self.logical_lines.margin_size)
|
||||||
self.draw_image(ll.left_image.key, ll.left_image.count, starting_row)
|
self.draw_image(ll.left_image.key, ll.left_image.count, starting_row)
|
||||||
self.lp.QueueWriteString("\r")
|
|
||||||
}
|
}
|
||||||
if ll.right_image.key != "" {
|
if ll.right_image.key != "" {
|
||||||
|
self.lp.QueueWriteString("\r")
|
||||||
self.lp.MoveCursorHorizontally(self.logical_lines.margin_size + self.logical_lines.columns/2)
|
self.lp.MoveCursorHorizontally(self.logical_lines.margin_size + self.logical_lines.columns/2)
|
||||||
self.draw_image(ll.right_image.key, ll.right_image.count, starting_row)
|
self.draw_image(ll.right_image.key, ll.right_image.count, starting_row)
|
||||||
self.lp.QueueWriteString("\r")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +354,11 @@ func (self *Handler) draw_screen() {
|
|||||||
seen_images := utils.NewSet[int]()
|
seen_images := utils.NewSet[int]()
|
||||||
for num_written := 0; num_written < self.screen_size.num_lines; num_written++ {
|
for num_written := 0; num_written < self.screen_size.num_lines; num_written++ {
|
||||||
ll := self.logical_lines.At(pos.logical_line)
|
ll := self.logical_lines.At(pos.logical_line)
|
||||||
is_image := ll != nil && ll.line_type == IMAGE_LINE
|
if ll == nil {
|
||||||
|
num_written--
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
is_image := ll.line_type == IMAGE_LINE
|
||||||
ll.render_screen_line(pos.screen_line, lp, self.logical_lines.margin_size, self.logical_lines.columns)
|
ll.render_screen_line(pos.screen_line, lp, self.logical_lines.margin_size, self.logical_lines.columns)
|
||||||
if is_image && !seen_images.Has(pos.logical_line) && pos.screen_line >= ll.image_lines_offset {
|
if is_image && !seen_images.Has(pos.logical_line) && pos.screen_line >= ll.image_lines_offset {
|
||||||
seen_images.Add(pos.logical_line)
|
seen_images.Add(pos.logical_line)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user