mirror of
https://github.com/nushell/reedline.git
synced 2024-09-11 15:55:50 +03:00
This commit is contained in:
parent
bde962bbf3
commit
295f16f367
@ -299,7 +299,7 @@ impl ColumnarMenu {
|
|||||||
use_ansi_coloring: bool,
|
use_ansi_coloring: bool,
|
||||||
) -> String {
|
) -> String {
|
||||||
if use_ansi_coloring {
|
if use_ansi_coloring {
|
||||||
let match_len = self.working_details.shortest_base_string.len();
|
let match_len = self.working_details.shortest_base_string.width();
|
||||||
|
|
||||||
// Split string so the match text can be styled
|
// Split string so the match text can be styled
|
||||||
let (match_str, remaining_str) = suggestion.value.split_at(match_len);
|
let (match_str, remaining_str) = suggestion.value.split_at(match_len);
|
||||||
@ -408,7 +408,7 @@ impl ColumnarMenu {
|
|||||||
+ self
|
+ self
|
||||||
.default_details
|
.default_details
|
||||||
.col_padding
|
.col_padding
|
||||||
.saturating_sub(marker.len()),
|
.saturating_sub(marker.width()),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!(
|
||||||
@ -417,7 +417,7 @@ impl ColumnarMenu {
|
|||||||
&suggestion.value,
|
&suggestion.value,
|
||||||
"",
|
"",
|
||||||
self.end_of_line(column),
|
self.end_of_line(column),
|
||||||
empty = empty_space.saturating_sub(marker.len()),
|
empty = empty_space.saturating_sub(marker.width()),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ impl Menu for ColumnarMenu {
|
|||||||
self.working_details.shortest_base_string = base_ranges
|
self.working_details.shortest_base_string = base_ranges
|
||||||
.iter()
|
.iter()
|
||||||
.map(|range| editor.get_buffer()[range.clone()].to_string())
|
.map(|range| editor.get_buffer()[range.clone()].to_string())
|
||||||
.min_by_key(|s| s.len())
|
.min_by_key(|s| s.width())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
self.reset_position();
|
self.reset_position();
|
||||||
@ -530,15 +530,15 @@ impl Menu for ColumnarMenu {
|
|||||||
self.working_details.col_width = painter.screen_width() as usize;
|
self.working_details.col_width = painter.screen_width() as usize;
|
||||||
|
|
||||||
self.longest_suggestion = self.get_values().iter().fold(0, |prev, suggestion| {
|
self.longest_suggestion = self.get_values().iter().fold(0, |prev, suggestion| {
|
||||||
if prev >= suggestion.value.len() {
|
if prev >= suggestion.value.width() {
|
||||||
prev
|
prev
|
||||||
} else {
|
} else {
|
||||||
suggestion.value.len()
|
suggestion.value.width()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let max_width = self.get_values().iter().fold(0, |acc, suggestion| {
|
let max_width = self.get_values().iter().fold(0, |acc, suggestion| {
|
||||||
let str_len = suggestion.value.len() + self.default_details.col_padding;
|
let str_len = suggestion.value.width() + self.default_details.col_padding;
|
||||||
if str_len > acc {
|
if str_len > acc {
|
||||||
str_len
|
str_len
|
||||||
} else {
|
} else {
|
||||||
@ -654,7 +654,7 @@ impl Menu for ColumnarMenu {
|
|||||||
// Correcting the enumerate index based on the number of skipped values
|
// Correcting the enumerate index based on the number of skipped values
|
||||||
let index = index + skip_values;
|
let index = index + skip_values;
|
||||||
let column = index as u16 % self.get_cols();
|
let column = index as u16 % self.get_cols();
|
||||||
let empty_space = self.get_width().saturating_sub(suggestion.value.len());
|
let empty_space = self.get_width().saturating_sub(suggestion.value.width());
|
||||||
|
|
||||||
self.create_string(suggestion, index, column, empty_space, use_ansi_coloring)
|
self.create_string(suggestion, index, column, empty_space, use_ansi_coloring)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user