refactor(widgets): remove iter::repeat for blank symbols

This commit is contained in:
Florian Dehau 2021-08-01 15:01:38 +02:00
parent 34a2be6458
commit 8eb6336f5e
2 changed files with 3 additions and 11 deletions

View file

@ -5,7 +5,6 @@ use crate::{
text::Text, text::Text,
widgets::{Block, StatefulWidget, Widget}, widgets::{Block, StatefulWidget, Widget},
}; };
use std::iter::{self, Iterator};
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -185,9 +184,7 @@ impl<'a> StatefulWidget for List<'a> {
state.offset = start; state.offset = start;
let highlight_symbol = self.highlight_symbol.unwrap_or(""); let highlight_symbol = self.highlight_symbol.unwrap_or("");
let blank_symbol = iter::repeat(" ") let blank_symbol = " ".repeat(highlight_symbol.width());
.take(highlight_symbol.width())
.collect::<String>();
let mut current_height = 0; let mut current_height = 0;
let has_selection = state.selected.is_some(); let has_selection = state.selected.is_some();

View file

@ -10,10 +10,7 @@ use cassowary::{
WeightedRelation::*, WeightedRelation::*,
{Expression, Solver}, {Expression, Solver},
}; };
use std::{ use std::collections::HashMap;
collections::HashMap,
iter::{self, Iterator},
};
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
/// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`]. /// A [`Cell`] contains the [`Text`] to be displayed in a [`Row`] of a [`Table`].
@ -427,9 +424,7 @@ impl<'a> StatefulWidget for Table<'a> {
let has_selection = state.selected.is_some(); let has_selection = state.selected.is_some();
let columns_widths = self.get_columns_widths(table_area.width, has_selection); let columns_widths = self.get_columns_widths(table_area.width, has_selection);
let highlight_symbol = self.highlight_symbol.unwrap_or(""); let highlight_symbol = self.highlight_symbol.unwrap_or("");
let blank_symbol = iter::repeat(" ") let blank_symbol = " ".repeat(highlight_symbol.width());
.take(highlight_symbol.width())
.collect::<String>();
let mut current_height = 0; let mut current_height = 0;
let mut rows_height = table_area.height; let mut rows_height = table_area.height;