Update handling of 'pending' keys

Before this change if you had a matching binding and a pending key,
the matching binding happened unconditionally.

Now we will wait a second before triggering that binding to give you
time to complete the action.
This commit is contained in:
Conrad Irwin 2024-01-21 14:36:59 -07:00
parent b8ed83a452
commit b06e2eb6af
7 changed files with 137 additions and 44 deletions

View file

@ -359,7 +359,7 @@ impl PlatformInputHandler {
self.cx
.update(|cx| {
self.handler
.replace_text_in_range(replacement_range, text, cx)
.replace_text_in_range(replacement_range, text, cx);
})
.ok();
}
@ -392,6 +392,13 @@ impl PlatformInputHandler {
.ok()
.flatten()
}
pub(crate) fn flush_pending_input(&mut self, input: &str, cx: &mut WindowContext) {
let Some(range) = self.handler.selected_text_range(cx) else {
return;
};
self.handler.replace_text_in_range(Some(range), &input, cx);
}
}
/// Zed's interface for handling text input from the platform's IME system