Fix selection clipping out of bounds in TextEditor
This commit is contained in:
parent
68d49459ce
commit
70e49df428
1 changed files with 36 additions and 27 deletions
|
|
@ -406,38 +406,47 @@ where
|
||||||
style.text_color,
|
style.text_color,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let translation = Vector::new(
|
||||||
|
bounds.x + self.padding.left,
|
||||||
|
bounds.y + self.padding.top,
|
||||||
|
);
|
||||||
|
|
||||||
if state.is_focused {
|
if state.is_focused {
|
||||||
match internal.editor.cursor() {
|
match internal.editor.cursor() {
|
||||||
Cursor::Caret(position) => {
|
Cursor::Caret(position) => {
|
||||||
renderer.fill_quad(
|
let position = position + translation;
|
||||||
renderer::Quad {
|
|
||||||
bounds: Rectangle {
|
if bounds.contains(position) {
|
||||||
x: position.x + bounds.x + self.padding.left,
|
|
||||||
y: position.y + bounds.y + self.padding.top,
|
|
||||||
width: 1.0,
|
|
||||||
height: self
|
|
||||||
.line_height
|
|
||||||
.to_absolute(self.text_size.unwrap_or_else(
|
|
||||||
|| renderer.default_size(),
|
|
||||||
))
|
|
||||||
.into(),
|
|
||||||
},
|
|
||||||
border_radius: 0.0.into(),
|
|
||||||
border_width: 0.0,
|
|
||||||
border_color: Color::TRANSPARENT,
|
|
||||||
},
|
|
||||||
theme.value_color(&self.style),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Cursor::Selection(ranges) => {
|
|
||||||
for range in ranges {
|
|
||||||
renderer.fill_quad(
|
renderer.fill_quad(
|
||||||
renderer::Quad {
|
renderer::Quad {
|
||||||
bounds: range
|
bounds: Rectangle {
|
||||||
+ Vector::new(
|
x: position.x,
|
||||||
bounds.x + self.padding.left,
|
y: position.y,
|
||||||
bounds.y + self.padding.top,
|
width: 1.0,
|
||||||
),
|
height: self
|
||||||
|
.line_height
|
||||||
|
.to_absolute(
|
||||||
|
self.text_size.unwrap_or_else(
|
||||||
|
|| renderer.default_size(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
},
|
||||||
|
border_radius: 0.0.into(),
|
||||||
|
border_width: 0.0,
|
||||||
|
border_color: Color::TRANSPARENT,
|
||||||
|
},
|
||||||
|
theme.value_color(&self.style),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Cursor::Selection(ranges) => {
|
||||||
|
for range in ranges.into_iter().filter_map(|range| {
|
||||||
|
bounds.intersection(&(range + translation))
|
||||||
|
}) {
|
||||||
|
renderer.fill_quad(
|
||||||
|
renderer::Quad {
|
||||||
|
bounds: range,
|
||||||
border_radius: 0.0.into(),
|
border_radius: 0.0.into(),
|
||||||
border_width: 0.0,
|
border_width: 0.0,
|
||||||
border_color: Color::TRANSPARENT,
|
border_color: Color::TRANSPARENT,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue