diff --git a/CHANGELOG.md b/CHANGELOG.md index 672abeee..c7b1500c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - introduced proper changelog ### Changed +- show longer commit messages in log view - introduce propper error handling in `asyncgit` [[@MCord](https://github.com/MCord)] ([#53](https://github.com/extrawurst/gitui/issues/53)) - better error message when trying to run outside of a valid git repo ([#56](https://github.com/extrawurst/gitui/issues/56)) - improve ctrl+c handling so it is checked first and no component needs to worry of blocking it diff --git a/asyncgit/src/sync/commits_info.rs b/asyncgit/src/sync/commits_info.rs index be734f06..f37811b9 100644 --- a/asyncgit/src/sync/commits_info.rs +++ b/asyncgit/src/sync/commits_info.rs @@ -20,6 +20,7 @@ pub struct CommitInfo { pub fn get_commits_info( repo_path: &str, ids: &[Oid], + message_length_limit: usize, ) -> Result> { scope_time!("get_commits_info"); @@ -33,7 +34,7 @@ pub fn get_commits_info( let res = commits .map(|c: Commit| { - let message = get_message(&c); + let message = get_message(&c, message_length_limit); let author = if let Some(name) = c.author().name() { String::from(name) } else { @@ -51,9 +52,9 @@ pub fn get_commits_info( Ok(res) } -fn get_message(c: &Commit) -> String { +fn get_message(c: &Commit, message_length_limit: usize) -> String { if let Some(msg) = c.message() { - limit_str(msg, 50) + limit_str(msg, message_length_limit) } else { String::from("") } @@ -91,7 +92,8 @@ mod tests { stage_add_file(repo_path, file_path).unwrap(); let c2 = commit(repo_path, "commit2").unwrap(); - let res = get_commits_info(repo_path, &vec![c2, c1]).unwrap(); + let res = + get_commits_info(repo_path, &vec![c2, c1], 50).unwrap(); assert_eq!(res.len(), 2); assert_eq!(res[0].message.as_str(), "commit2"); diff --git a/asyncgit/src/sync/logwalker.rs b/asyncgit/src/sync/logwalker.rs index b364db4d..9202227e 100644 --- a/asyncgit/src/sync/logwalker.rs +++ b/asyncgit/src/sync/logwalker.rs @@ -98,7 +98,7 @@ mod tests { let mut walk = LogWalker::new(&repo); walk.read(&mut items, 100).unwrap(); - let info = get_commits_info(repo_path, &items).unwrap(); + let info = get_commits_info(repo_path, &items, 50).unwrap(); dbg!(&info); assert_eq!(items.len(), 2); diff --git a/src/tabs/revlog/mod.rs b/src/tabs/revlog/mod.rs index 37b78e56..7fc244ad 100644 --- a/src/tabs/revlog/mod.rs +++ b/src/tabs/revlog/mod.rs @@ -54,7 +54,7 @@ pub struct Revlog { first_open_done: bool, scroll_state: (Instant, f32), tags: Tags, - current_height: u16, + current_size: (u16, u16), } impl Revlog { @@ -69,7 +69,7 @@ impl Revlog { first_open_done: false, scroll_state: (Instant::now(), 0_f32), tags: Tags::new(), - current_height: 0, + current_size: (0, 0), } } @@ -98,6 +98,7 @@ impl Revlog { let commits = sync::get_commits_info( CWD, &self.git_log.get_slice(want_min, SLICE_SIZE).unwrap(), + self.current_size.0.into(), ); if let Ok(commits) = commits { @@ -114,7 +115,7 @@ impl Revlog { .max(1); let page_offset = - usize::from(self.current_height).saturating_sub(1); + usize::from(self.current_size.1).saturating_sub(1); self.selection = match scroll { ScrollType::Up => { @@ -236,7 +237,10 @@ impl Revlog { impl DrawableComponent for Revlog { fn draw(&mut self, f: &mut Frame, area: Rect) { - self.current_height = area.height.saturating_sub(2); + self.current_size = ( + area.width.saturating_sub(2), + area.height.saturating_sub(2), + ); let height = area.height as usize; let selection =