mirror of
https://github.com/nushell/reedline.git
synced 2024-08-17 20:00:49 +03:00
fix description line not truncating in columnar menu (#739)
* add builder functions * fix description wrap * fmt * fix
This commit is contained in:
parent
9f0095f150
commit
f2447364b9
@ -6,6 +6,7 @@ use crate::{
|
||||
Completer, Suggestion,
|
||||
};
|
||||
use nu_ansi_term::ansi::RESET;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
/// Default values used as reference for the menu. These values are set during
|
||||
/// the initial declaration of the menu and are always kept as reference for the
|
||||
@ -308,12 +309,16 @@ impl ColumnarMenu {
|
||||
.unwrap_or(self.settings.color.text_style)
|
||||
.prefix();
|
||||
|
||||
if index == self.index() {
|
||||
if let Some(description) = &suggestion.description {
|
||||
let left_text_size = self.longest_suggestion + self.default_details.col_padding;
|
||||
let right_text_size = self.get_width().saturating_sub(left_text_size);
|
||||
|
||||
let max_remaining = left_text_size.saturating_sub(match_str.width());
|
||||
let max_match = max_remaining.saturating_sub(remaining_str.width());
|
||||
|
||||
if index == self.index() {
|
||||
if let Some(description) = &suggestion.description {
|
||||
format!(
|
||||
"{}{}{}{}{}{}{:max$}{}{}{}{}{}{}",
|
||||
"{}{}{}{}{}{:max_match$}{:max_remaining$}{}{}{}{}{}{}",
|
||||
suggestion_style_prefix,
|
||||
self.settings.color.selected_match_style.prefix(),
|
||||
match_str,
|
||||
@ -331,7 +336,6 @@ impl ColumnarMenu {
|
||||
.replace('\n', " "),
|
||||
RESET,
|
||||
self.end_of_line(column),
|
||||
max = left_text_size,
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
@ -350,10 +354,8 @@ impl ColumnarMenu {
|
||||
)
|
||||
}
|
||||
} else if let Some(description) = &suggestion.description {
|
||||
let left_text_size = self.longest_suggestion + self.default_details.col_padding;
|
||||
let right_text_size = self.get_width().saturating_sub(left_text_size);
|
||||
format!(
|
||||
"{}{}{}{}{}{:max$}{}{}{}{}{}",
|
||||
"{}{}{}{}{:max_match$}{:max_remaining$}{}{}{}{}{}",
|
||||
suggestion_style_prefix,
|
||||
self.settings.color.match_style.prefix(),
|
||||
match_str,
|
||||
@ -369,7 +371,6 @@ impl ColumnarMenu {
|
||||
.replace('\n', " "),
|
||||
RESET,
|
||||
self.end_of_line(column),
|
||||
max = left_text_size,
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
|
Loading…
Reference in New Issue
Block a user