mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
cli: handle mouse scroll before setting window
This commit is contained in:
@ -502,20 +502,6 @@ const Preview = struct {
|
|||||||
.height = .{ .limit = win.height },
|
.height = .{ .limit = win.height },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (self.filtered.items.len == 0) {
|
|
||||||
self.current = 0;
|
|
||||||
self.window = 0;
|
|
||||||
} else {
|
|
||||||
const start = self.window;
|
|
||||||
const end = self.window + theme_list.height - 1;
|
|
||||||
if (self.current > end)
|
|
||||||
self.window = self.current - theme_list.height + 1;
|
|
||||||
if (self.current < start)
|
|
||||||
self.window = self.current;
|
|
||||||
if (self.window >= self.filtered.items.len)
|
|
||||||
self.window = self.filtered.items.len - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var highlight: ?usize = null;
|
var highlight: ?usize = null;
|
||||||
|
|
||||||
if (self.mouse) |mouse| {
|
if (self.mouse) |mouse| {
|
||||||
@ -536,6 +522,20 @@ const Preview = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.filtered.items.len == 0) {
|
||||||
|
self.current = 0;
|
||||||
|
self.window = 0;
|
||||||
|
} else {
|
||||||
|
const start = self.window;
|
||||||
|
const end = self.window + theme_list.height - 1;
|
||||||
|
if (self.current > end)
|
||||||
|
self.window = self.current - theme_list.height + 1;
|
||||||
|
if (self.current < start)
|
||||||
|
self.window = self.current;
|
||||||
|
if (self.window >= self.filtered.items.len)
|
||||||
|
self.window = self.filtered.items.len - 1;
|
||||||
|
}
|
||||||
|
|
||||||
theme_list.fill(.{ .style = self.ui_standard() });
|
theme_list.fill(.{ .style = self.ui_standard() });
|
||||||
|
|
||||||
for (0..theme_list.height) |row| {
|
for (0..theme_list.height) |row| {
|
||||||
|
Reference in New Issue
Block a user