Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions crates/gpui/src/platform/linux/wayland/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,7 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientStatePtr {
state.repeat.current_keycode = Some(keycode);

let rate = state.repeat.characters_per_second;
let repeat_interval = Duration::from_secs(1) / rate;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let repeat_interval = Duration::from_secs(1) / rate;
let repeat_interval = Duration::from_secs(1) / rate.max(1);

to prevent division by zero crash?

@olejorgenb olejorgenb Dec 12, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, did not consider 0 was a possible rate, but I guess it's possible to configure that if you want to turn of key-repeat altogether. Fixed here: #44151

let id = state.repeat.current_id;
state
.loop_handle
Expand All @@ -1398,7 +1399,7 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientStatePtr {
is_held: true,
prefer_character_input: false,
});
move |_event, _metadata, this| {
move |event_timestamp, _metadata, this| {
let mut client = this.get_client();
let mut state = client.borrow_mut();
let is_repeating = id == state.repeat.current_id
Expand All @@ -1415,7 +1416,8 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientStatePtr {
drop(state);
focused_window.handle_input(input.clone());

TimeoutAction::ToDuration(Duration::from_secs(1) / rate)
// If the new scheduled time is in the past the event will repeat as soon as possible
TimeoutAction::ToInstant(event_timestamp + repeat_interval)
}
})
.unwrap();
Expand Down
Loading