Display subtle-mode prediction preview when partial accept modifiers held (#32212)

Closes #27567

Release notes covered by the notes for #32193

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-05 20:52:16 -06:00 committed by GitHub
parent f62d76159b
commit 920ca688a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 8 deletions

View file

@ -2248,15 +2248,21 @@ impl Editor {
pub fn accept_edit_prediction_keybind(
&self,
accept_partial: bool,
window: &Window,
cx: &App,
) -> AcceptEditPredictionBinding {
let key_context = self.key_context_internal(true, window, cx);
let in_conflict = self.edit_prediction_in_conflict();
let bindings = if accept_partial {
window.bindings_for_action_in_context(&AcceptPartialEditPrediction, key_context)
} else {
window.bindings_for_action_in_context(&AcceptEditPrediction, key_context)
};
AcceptEditPredictionBinding(
window
.bindings_for_action_in_context(&AcceptEditPrediction, key_context)
bindings
.into_iter()
.filter(|binding| {
!in_conflict
@ -7119,12 +7125,25 @@ impl Editor {
window: &mut Window,
cx: &mut Context<Self>,
) {
let accept_keybind = self.accept_edit_prediction_keybind(window, cx);
let Some(accept_keystroke) = accept_keybind.keystroke() else {
return;
let mut modifiers_held = false;
if let Some(accept_keystroke) = self
.accept_edit_prediction_keybind(false, window, cx)
.keystroke()
{
modifiers_held = modifiers_held
|| (&accept_keystroke.modifiers == modifiers
&& accept_keystroke.modifiers.modified());
};
if let Some(accept_partial_keystroke) = self
.accept_edit_prediction_keybind(true, window, cx)
.keystroke()
{
modifiers_held = modifiers_held
|| (&accept_partial_keystroke.modifiers == modifiers
&& accept_partial_keystroke.modifiers.modified());
}
if &accept_keystroke.modifiers == modifiers && accept_keystroke.modifiers.modified() {
if modifiers_held {
if matches!(
self.edit_prediction_preview,
EditPredictionPreview::Inactive { .. }
@ -8441,7 +8460,7 @@ impl Editor {
window: &mut Window,
cx: &App,
) -> Option<AnyElement> {
let accept_binding = self.accept_edit_prediction_keybind(window, cx);
let accept_binding = self.accept_edit_prediction_keybind(false, window, cx);
let accept_keystroke = accept_binding.keystroke()?;
let is_platform_style_mac = PlatformStyle::platform() == PlatformStyle::Mac;

View file

@ -3881,7 +3881,8 @@ impl EditorElement {
let edit_prediction = if edit_prediction_popover_visible {
self.editor.update(cx, move |editor, cx| {
let accept_binding = editor.accept_edit_prediction_keybind(window, cx);
let accept_binding =
editor.accept_edit_prediction_keybind(false, window, cx);
let mut element = editor.render_edit_prediction_cursor_popover(
min_width,
max_width,