Input: wrong wrap width when using a wide character font
When you specify a font family that has a wide character width for an Input element with soft_wrap being true, the wrap width is wrong and lines appear longer than the input width.
This only happens when specifying the font family directly in the input. When you specify the font family in its parent, it works correctly.
(The font used in the screenshot below is IBM Plex Mono)
When specifying font_family directly in the Input element
When specifying font_family in the parent element
I think this is because the font hasn't been applied yet in RenderOnce for Input when the family is assigned there. Perhaps we can move the text wrapper font update to element.rs prepaint?
Move https://github.com/longbridge/gpui-component/blob/main/crates/ui/src/input/input.rs#L251-L253 to https://github.com/longbridge/gpui-component/blob/main/crates/ui/src/input/element.rs#L820
let style = window.text_style();
let font = style.font();
let font_size = style.font_size.to_pixels(window.rem_size());
self.state.update(cx, |state, cx| {
state.text_wrapper.set_font(font, font_size, cx);
state.text_wrapper.prepare_if_need(&state.text, cx);
});
What do you think @huacnlee ?