Fix: Text input selection paint size
This PR is adjusting text input selection paint size to cover better selected text and avoid clipping left edge of the selection:
Examples
| Ex. 1 | Ex. 2 | Ex. 3 | Ex. 4 | |
|---|---|---|---|---|
| Before | ||||
| After |
Does the text layout provide any other information that we should be using to better position the selection? just inflating the rect feels like a solution that will cause as many problems as it solves
Hmm, this also seems to work:
let selection_rect = self
.get_selection_rect(&node_layout, padding_left + 1.)
.to_rounded_rect(border_radius);
cx.save();
// cx.clip(&self.id
// .get_size()
// .unwrap_or(Size::new(selection_rect.width(), selection_rect.height()))
// .to_rect()
// );
cx.fill(&selection_rect, &cursor_color, 0.0);
cx.restore();
Clip does appear to do nothing here though.. 🤔
It makes sense to have the clip in case there are rounded corners or some case where it would clip.
I think we do want to actually fix this properly using info from the TextLayout
Copy that, but I don't feel competent enough to do that, have looked briefly there and have no idea what is going on :D
One note on the side; this change affects only text_input widget, but not the editor, so scope for anything going wrong is very limited, I have tested this change quite extensively on every case I could think of and did not see any regress.
I think it used to have an inflate on it and I removed it some time ago because it was causing problems