diff options
author | 2020-04-09 05:01:09 +0200 | |
---|---|---|
committer | 2020-04-09 05:01:09 +0200 | |
commit | 9afa31899f9daa4523cb23db75e736d7d652da13 (patch) | |
tree | 6a7a807c5d83b33cf6598c5f3aefb6191541f407 /wgpu | |
parent | d51b501d2f5170f79c953c63e0532490882e9ca9 (diff) | |
download | iced-9afa31899f9daa4523cb23db75e736d7d652da13.tar.gz iced-9afa31899f9daa4523cb23db75e736d7d652da13.tar.bz2 iced-9afa31899f9daa4523cb23db75e736d7d652da13.zip |
Fix `measure_value` for text input in `iced_wgpu`
It accounts for spaces at the start of text now.
Diffstat (limited to 'wgpu')
-rw-r--r-- | wgpu/src/renderer/widget/text_input.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/wgpu/src/renderer/widget/text_input.rs b/wgpu/src/renderer/widget/text_input.rs index 9093b0c6..ab0ba363 100644 --- a/wgpu/src/renderer/widget/text_input.rs +++ b/wgpu/src/renderer/widget/text_input.rs @@ -23,11 +23,11 @@ impl text_input::Renderer for Renderer { Size::INFINITY, ); - let spaces_at_the_end = value.len() - value.trim_end().len(); + let spaces_around = value.len() - value.trim().len(); - if spaces_at_the_end > 0 { + if spaces_around > 0 { let space_width = self.text_pipeline.space_width(size as f32); - width += spaces_at_the_end as f32 * space_width; + width += spaces_around as f32 * space_width; } width |