From 0393de48900f4ad13979588859c478d9eeaf3039 Mon Sep 17 00:00:00 2001 From: wiru Date: Tue, 11 Jun 2024 23:53:16 -0300 Subject: [PATCH] fix: using chars().count() instead of len() --- hac-client/src/pages/collection_viewer/collection_viewer.rs | 2 +- .../request_editor/headers_editor_edit_form.rs | 6 ++++-- .../collection_viewer/sidebar/create_directory_form.rs | 5 ++++- .../src/pages/collection_viewer/sidebar/request_form.rs | 5 ++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/hac-client/src/pages/collection_viewer/collection_viewer.rs b/hac-client/src/pages/collection_viewer/collection_viewer.rs index 1a76996..0ad30cc 100755 --- a/hac-client/src/pages/collection_viewer/collection_viewer.rs +++ b/hac-client/src/pages/collection_viewer/collection_viewer.rs @@ -306,7 +306,7 @@ impl Renderable for CollectionViewer<'_> { self.layout .req_uri .x - .add(request.read().unwrap().uri.len() as u16) + .add(request.read().unwrap().uri.chars().count() as u16) .add(1), self.layout.req_uri.y.add(1), ) diff --git a/hac-client/src/pages/collection_viewer/request_editor/headers_editor_edit_form.rs b/hac-client/src/pages/collection_viewer/request_editor/headers_editor_edit_form.rs index ce8392a..9d9ad4d 100644 --- a/hac-client/src/pages/collection_viewer/request_editor/headers_editor_edit_form.rs +++ b/hac-client/src/pages/collection_viewer/request_editor/headers_editor_edit_form.rs @@ -184,13 +184,15 @@ impl Renderable for HeadersEditorForm<'_> { match self.focused_input { HeadersEditorFormInput::Name => { frame.set_cursor( - name_size.x.add(header.pair.0.len().add(1) as u16), + name_size.x.add(header.pair.0.chars().count().add(1) as u16), name_size.y.add(1), ); } HeadersEditorFormInput::Value => { frame.set_cursor( - value_size.x.add(header.pair.1.len().add(1) as u16), + value_size + .x + .add(header.pair.1.chars().count().add(1) as u16), value_size.y.add(1), ); } diff --git a/hac-client/src/pages/collection_viewer/sidebar/create_directory_form.rs b/hac-client/src/pages/collection_viewer/sidebar/create_directory_form.rs index 7945bc7..f510383 100644 --- a/hac-client/src/pages/collection_viewer/sidebar/create_directory_form.rs +++ b/hac-client/src/pages/collection_viewer/sidebar/create_directory_form.rs @@ -106,7 +106,10 @@ impl Renderable for CreateDirectoryForm<'_> { frame.render_widget(hint, hint_size); frame.set_cursor( - input_size.x.add(self.dir_name.len() as u16).add(1), + input_size + .x + .add(self.dir_name.chars().count() as u16) + .add(1), input_size.y.add(1), ); diff --git a/hac-client/src/pages/collection_viewer/sidebar/request_form.rs b/hac-client/src/pages/collection_viewer/sidebar/request_form.rs index 31ba65d..d8270a0 100644 --- a/hac-client/src/pages/collection_viewer/sidebar/request_form.rs +++ b/hac-client/src/pages/collection_viewer/sidebar/request_form.rs @@ -184,7 +184,10 @@ impl<'rf, State> Renderable for RequestForm<'rf, State> { if self.focused_field.eq(&FormField::Name) { frame.set_cursor( - name_size.x.add(self.request_name.len() as u16).add(1), + name_size + .x + .add(self.request_name.chars().count() as u16) + .add(1), name_size.y.add(1), ); }