Skip to content

Commit 8030022

Browse files
cruesslerStephan Dilly
authored andcommitted
Address minor issues in blame view
1 parent 874d2e4 commit 8030022

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/blame_file.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::convert::TryInto;
1818
use tui::{
1919
backend::Backend,
2020
layout::{Constraint, Rect},
21+
symbols::line::VERTICAL,
2122
text::Span,
2223
widgets::{Block, Borders, Cell, Clear, Row, Table, TableState},
2324
Frame,
@@ -37,10 +38,12 @@ pub struct BlameFileComponent {
3738
static COMMIT_ID: &str = "HEAD";
3839
static NO_COMMIT_ID: &str = "0000000";
3940
static NO_AUTHOR: &str = "<no author>";
40-
static AUTHOR_WIDTH: usize = 20;
41+
static MIN_AUTHOR_WIDTH: usize = 3;
42+
static MAX_AUTHOR_WIDTH: usize = 20;
4143

4244
fn get_author_width(width: usize) -> usize {
43-
(width.saturating_sub(19) / 3).max(3).min(AUTHOR_WIDTH)
45+
(width.saturating_sub(19) / 3)
46+
.clamp(MIN_AUTHOR_WIDTH, MAX_AUTHOR_WIDTH)
4447
}
4548

4649
const fn number_of_digits(number: usize) -> usize {
@@ -279,10 +282,10 @@ impl BlameFileComponent {
279282

280283
let line_number_width = self.get_line_number_width();
281284
cells.push(
282-
// U+2502 is BOX DRAWINGS LIGHT VERTICAL.
283285
Cell::from(format!(
284-
"{:>line_number_width$}\u{2502}",
286+
"{:>line_number_width$}{}",
285287
line_number,
288+
VERTICAL,
286289
line_number_width = line_number_width,
287290
))
288291
.style(self.theme.text(true, false)),
@@ -312,7 +315,7 @@ impl BlameFileComponent {
312315
let author = format!(
313316
"{:author_width$}",
314317
truncated_author,
315-
author_width = AUTHOR_WIDTH
318+
author_width = MAX_AUTHOR_WIDTH
316319
);
317320
let time = blame_hunk.map_or_else(
318321
|| "".into(),

0 commit comments

Comments
 (0)