refactor: avoid unnecessary casts
This commit is contained in:
parent
d60611deba
commit
1034872e8f
1 changed files with 3 additions and 4 deletions
|
|
@ -1557,19 +1557,18 @@ pub const Editor = struct {
|
|||
.bg = if (hl_row) |_| theme.editor_line_highlight.bg else theme.editor_hint.bg,
|
||||
});
|
||||
|
||||
var summary_freespace: i32 = @intCast(screen_width - space_begin);
|
||||
const static_text = " , ";
|
||||
summary_freespace -= @intCast(static_text.len + commit.author.len);
|
||||
const summary_freespace = screen_width -| (space_begin + static_text.len + commit.author.len);
|
||||
|
||||
var buf: std.Io.Writer.Allocating = .init(self.allocator);
|
||||
defer buf.deinit();
|
||||
|
||||
if (summary_freespace >= @as(i32, @intCast(commit.summary.len))) {
|
||||
if (summary_freespace >= commit.summary.len) {
|
||||
_ = buf.writer.print(" {s}, {s}", .{ commit.summary, commit.author }) catch 0;
|
||||
} else if (summary_freespace <= 3) {
|
||||
_ = buf.writer.print(" {s}", .{commit.author}) catch 0;
|
||||
} else {
|
||||
_ = buf.writer.print(" {s}..., {s}", .{ commit.summary[0 .. @as(usize, @intCast(summary_freespace)) - 3], commit.author }) catch 0;
|
||||
_ = buf.writer.print(" {s}..., {s}", .{ commit.summary[0..summary_freespace -| 3], commit.author }) catch 0;
|
||||
}
|
||||
|
||||
const msg = buf.written();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue