Skip to content

Commit

Permalink
fix: output wraps in terminal
Browse files Browse the repository at this point in the history
Tracking-issue: #103
Co-authored-by: aarondill <[email protected]>
Signed-off-by: Christina Sørensen <[email protected]>
  • Loading branch information
cafkafk and aarondill committed Aug 3, 2023
1 parent ca02411 commit b59a41f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/output/file_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub struct FileName<'a, 'dir, C> {
/// How to handle displaying links.
link_style: LinkStyle,

options: Options,
pub options: Options,
}

impl<'a, 'dir, C> FileName<'a, 'dir, C> {
Expand Down
10 changes: 9 additions & 1 deletion src/output/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use term_grid as tg;
use crate::fs::File;
use crate::fs::filter::FileFilter;
use crate::output::file_name::Options as FileStyle;
use crate::output::file_name::{ShowIcons, EmbedHyperlinks};
use crate::theme::Theme;


Expand Down Expand Up @@ -43,12 +44,19 @@ impl<'a> Render<'a> {
for file in &self.files {
let filename = self.file_style.for_file(file, self.theme);
let contents = filename.paint();
let width;

match (filename.options.embed_hyperlinks, filename.options.show_icons) {
(EmbedHyperlinks::On, ShowIcons::On(_)) => width = filename.bare_width() + 1,
(EmbedHyperlinks::On, ShowIcons::Off) => width = filename.bare_width(),
(EmbedHyperlinks::Off, _) => width = *contents.width(),
};

grid.add(tg::Cell {
contents: contents.strings().to_string(),
// with hyperlink escape sequences,
// the actual *contents.width() is larger than actually needed, so we take only the filename
width: filename.bare_width(),
width: width,
});
}

Expand Down

0 comments on commit b59a41f

Please sign in to comment.