diff --git a/CHANGELOG.md b/CHANGELOG.md index 761d5ec4..bc55c843 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/components/diff.rs b/src/components/diff.rs index c46ab2d0..d1ed6758 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -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), ), ]) diff --git a/src/components/mod.rs b/src/components/mod.rs index aca90a14..013d9675 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -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 + } +} diff --git a/src/components/syntax_text.rs b/src/components/syntax_text.rs index 26d4eba2..7a5dddc7 100644 --- a/src/components/syntax_text.rs +++ b/src/components/syntax_text.rs @@ -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(),