unicode: use new decoded_width function

For now, only add it in a single place. There are more instances where
width calculation could be improved, but this one has already been
converted to use the `unicode-width` crate before, so conversion is easy
and a strict improvement.

Closes #12457
This commit is contained in:
Daniel Rainer
2026-02-17 02:27:35 +01:00
committed by Johannes Altmanninger
parent c38dd1f420
commit 1b0fa8f804
3 changed files with 3 additions and 7 deletions

1
Cargo.lock generated
View File

@@ -296,7 +296,6 @@ dependencies = [
"rsconf",
"rust-embed",
"serial_test",
"unicode-width",
"unix_path",
"xterm-color",
]

View File

@@ -126,7 +126,6 @@ num-traits.workspace = true
once_cell.workspace = true
pcre2.workspace = true
rand.workspace = true
unicode-width.workspace = true
xterm-color.workspace = true
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]

View File

@@ -15,7 +15,7 @@
use crate::screen::{CharOffset, Line, ScreenData, wcswidth_rendered, wcwidth_rendered};
use crate::termsize::Termsize;
use fish_wcstringutil::string_fuzzy_match_string;
use unicode_width::UnicodeWidthStr as _;
use fish_widestring::decoded_width;
/// Represents rendering from the pager.
#[derive(Default)]
@@ -1044,13 +1044,11 @@ pub fn set_fully_disclosed(&mut self) {
// Position of the cursor.
pub fn cursor_position(&self) -> usize {
let mut result = sprintf!(
let mut result = decoded_width(&sprintf!(
"%s %s",
wgettext!(SEARCH_FIELD_PROMPT),
self.search_field_line.text()
)
.to_string()
.width();
));
// Clamp it to the right edge.
if self.available_term_width > 0 && result + 1 > self.available_term_width {
result = self.available_term_width - 1;