mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-18 22:31:35 +03:00
fix: selection rect out of bounds (#59)
This commit is contained in:
parent
05433c38d0
commit
edd0ad7997
@ -16,7 +16,7 @@ impl<'a> Input<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Widget for Input<'a> {
|
||||
fn render(self, _: Rect, buf: &mut Buffer) {
|
||||
fn render(self, win: Rect, buf: &mut Buffer) {
|
||||
let input = &self.cx.input;
|
||||
let area = self.cx.area(&input.position);
|
||||
|
||||
@ -43,8 +43,11 @@ impl<'a> Widget for Input<'a> {
|
||||
.render(area, buf);
|
||||
|
||||
if let Some(Range { start, end }) = input.selected() {
|
||||
let x = win.width.min(area.x + 1 + start);
|
||||
let y = win.height.min(area.y + 1);
|
||||
|
||||
buf.set_style(
|
||||
Rect { x: area.x + 1 + start, y: area.y + 1, width: end - start, height: 1 },
|
||||
Rect { x, y, width: (end - start).min(win.width - x), height: 1.min(win.height - y) },
|
||||
Style::new().bg(Color::Rgb(72, 77, 102)),
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user