fix diff at the end of file

This commit is contained in:
Stephan Dilly 2020-03-27 10:32:55 +01:00
parent b1f8914cba
commit bfbde25116
2 changed files with 11 additions and 4 deletions

View file

@ -55,7 +55,6 @@ GITUI_LOGGING=true gitui
# todo for 0.1 (first release) # todo for 0.1 (first release)
* [ ] fix: diff broken at end of file
* [ ] fix: reset unstaged file also resets staged hunks * [ ] fix: reset unstaged file also resets staged hunks
* [ ] better help command * [ ] better help command
* [ ] -> fix: dont show scroll option when any popup open * [ ] -> fix: dont show scroll option when any popup open
@ -67,4 +66,7 @@ GITUI_LOGGING=true gitui
* https://github.com/jesseduffield/lazygit * https://github.com/jesseduffield/lazygit
* https://github.com/jonas/tig * https://github.com/jonas/tig
* https://github.com/git-up/GitUp (would be nice to comeup with a way to have the map view available in a terminal tool) * https://github.com/git-up/GitUp (would be nice to comeup with a way to have the map view available in a terminal tool)
asdad

View file

@ -133,6 +133,7 @@ impl DiffComponent {
Color::Reset Color::Reset
}) })
.fg(Color::DarkGray); .fg(Color::DarkGray);
if end_of_hunk { if end_of_hunk {
text.push(Text::Styled( text.push(Text::Styled(
Cow::from(symbols::line::BOTTOM_LEFT), Cow::from(symbols::line::BOTTOM_LEFT),
@ -170,11 +171,15 @@ impl DiffComponent {
let filled = if selected { let filled = if selected {
format!( format!(
"{:w$}\n", "{:w$}\n",
line.content.trim_end(), line.content.trim_matches('\n'),
w = width as usize w = width as usize
) )
} else { } else {
line.content.clone() if line.content.matches('\n').count() == 1 {
line.content.clone()
} else {
format!("{}\n", line.content.trim_matches('\n'))
}
}; };
let content = Cow::from(filled); let content = Cow::from(filled);