mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
fix whitespace at commit-msg start breaking revlog alignment (closes #158)
This commit is contained in:
parent
b54e90a0de
commit
fb6cdb92ea
1 changed files with 5 additions and 5 deletions
|
|
@ -2,7 +2,6 @@ use super::utils::repo;
|
|||
use crate::error::Result;
|
||||
use git2::{Commit, Error, Oid};
|
||||
use scopetime::scope_time;
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// identifies a single commit
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
@ -93,19 +92,20 @@ pub fn get_message(
|
|||
message_length_limit: Option<usize>,
|
||||
) -> String {
|
||||
let msg = String::from_utf8_lossy(c.message_bytes());
|
||||
let msg = msg.trim_start();
|
||||
|
||||
if let Some(limit) = message_length_limit {
|
||||
limit_str(msg, limit)
|
||||
limit_str(msg, limit).to_string()
|
||||
} else {
|
||||
msg.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn limit_str(s: Cow<'_, str>, limit: usize) -> String {
|
||||
fn limit_str(s: &str, limit: usize) -> &str {
|
||||
if let Some(first) = s.lines().next() {
|
||||
first.chars().take(limit).collect::<String>()
|
||||
&first[0..limit.min(first.len())]
|
||||
} else {
|
||||
String::new()
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue