fix filetree content not showing tabs (fixes #874)

This commit is contained in:
Stephan Dilly 2021-08-24 23:02:23 +02:00
parent e500302b8b
commit 6524af65a1
4 changed files with 17 additions and 6 deletions

View file

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Fixed
- fix commit msg being broken inside tag list ([#871](https://github.com/extrawurst/gitui/issues/871))
- fix filetree file content not showing tabs correctly ([#874](https://github.com/extrawurst/gitui/issues/874))
## [0.17.0] - 2021-08-21

View file

@ -3,7 +3,9 @@ use super::{
Direction, DrawableComponent, ScrollType,
};
use crate::{
components::{CommandInfo, Component, EventState},
components::{
tabs_to_spaces, CommandInfo, Component, EventState,
},
keys::SharedKeyConfig,
queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem},
strings, try_or_popup,
@ -425,13 +427,11 @@ impl DiffComponent {
// weird eof missing eol line
format!("{}\n", trimmed)
};
//TODO: allow customize tabsize
let content = Cow::from(filled.replace("\t", " "));
Spans::from(vec![
left_side_of_line,
Span::styled(
content,
Cow::from(tabs_to_spaces(filled)),
theme.diff_line(line.line_type, selected),
),
])

View file

@ -312,3 +312,12 @@ where
.alignment(Alignment::Left)
.wrap(Wrap { trim: true })
}
//TODO: allow customize tabsize
pub fn tabs_to_spaces(input: String) -> String {
if input.contains('\t') {
input.replace("\t", " ")
} else {
input
}
}

View file

@ -1,6 +1,6 @@
use super::{
CommandBlocking, CommandInfo, Component, DrawableComponent,
EventState,
tabs_to_spaces, CommandBlocking, CommandInfo, Component,
DrawableComponent, EventState,
};
use crate::{
keys::SharedKeyConfig,
@ -104,6 +104,7 @@ impl SyntaxTextComponent {
//TODO: fetch file content async aswell
match sync::tree_file_content(CWD, item) {
Ok(content) => {
let content = tabs_to_spaces(content);
self.async_highlighting.spawn(
AsyncSyntaxJob::new(
content.clone(),