Skip to content

Commit 6524af6

Browse files
author
Stephan Dilly
committed
fix filetree content not showing tabs (fixes #874)
1 parent e500302 commit 6524af6

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
## Fixed
1818
- fix commit msg being broken inside tag list ([#871](https://github.com/extrawurst/gitui/issues/871))
19+
- fix filetree file content not showing tabs correctly ([#874](https://github.com/extrawurst/gitui/issues/874))
1920

2021
## [0.17.0] - 2021-08-21
2122

src/components/diff.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use super::{
33
Direction, DrawableComponent, ScrollType,
44
};
55
use crate::{
6-
components::{CommandInfo, Component, EventState},
6+
components::{
7+
tabs_to_spaces, CommandInfo, Component, EventState,
8+
},
79
keys::SharedKeyConfig,
810
queue::{Action, InternalEvent, NeedsUpdate, Queue, ResetItem},
911
strings, try_or_popup,
@@ -425,13 +427,11 @@ impl DiffComponent {
425427
// weird eof missing eol line
426428
format!("{}\n", trimmed)
427429
};
428-
//TODO: allow customize tabsize
429-
let content = Cow::from(filled.replace("\t", " "));
430430

431431
Spans::from(vec![
432432
left_side_of_line,
433433
Span::styled(
434-
content,
434+
Cow::from(tabs_to_spaces(filled)),
435435
theme.diff_line(line.line_type, selected),
436436
),
437437
])

src/components/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,12 @@ where
312312
.alignment(Alignment::Left)
313313
.wrap(Wrap { trim: true })
314314
}
315+
316+
//TODO: allow customize tabsize
317+
pub fn tabs_to_spaces(input: String) -> String {
318+
if input.contains('\t') {
319+
input.replace("\t", " ")
320+
} else {
321+
input
322+
}
323+
}

src/components/syntax_text.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{
2-
CommandBlocking, CommandInfo, Component, DrawableComponent,
3-
EventState,
2+
tabs_to_spaces, CommandBlocking, CommandInfo, Component,
3+
DrawableComponent, EventState,
44
};
55
use crate::{
66
keys::SharedKeyConfig,
@@ -104,6 +104,7 @@ impl SyntaxTextComponent {
104104
//TODO: fetch file content async aswell
105105
match sync::tree_file_content(CWD, item) {
106106
Ok(content) => {
107+
let content = tabs_to_spaces(content);
107108
self.async_highlighting.spawn(
108109
AsyncSyntaxJob::new(
109110
content.clone(),

0 commit comments

Comments
 (0)