Add a way to toggle inlay hints with modifiers #2 (#25766)

https://github.com/zed-industries/zed/pull/25752 with fixes on top

* Ensures no flickering happens for all modifiers `: false` case
* Dismisses the toggled state on focus out
* Reworks cache state so that "enabled" and "toggled by modifiers" are
different states with their own lifecycle

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2025-02-28 10:03:25 +02:00 committed by GitHub
parent bb3aef15eb
commit 7440833ff1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 166 additions and 26 deletions

View file

@ -1,4 +1,5 @@
use serde::Deserialize;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::{
error::Error,
fmt::{Display, Write},
@ -306,24 +307,29 @@ impl std::fmt::Display for Keystroke {
}
/// The state of the modifier keys at some point in time
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default, Deserialize, Hash)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Default, Serialize, Deserialize, Hash, JsonSchema)]
pub struct Modifiers {
/// The control key
#[serde(default)]
pub control: bool,
/// The alt key
/// Sometimes also known as the 'meta' key
#[serde(default)]
pub alt: bool,
/// The shift key
#[serde(default)]
pub shift: bool,
/// The command key, on macos
/// the windows key, on windows
/// the super key, on linux
#[serde(default)]
pub platform: bool,
/// The function key
#[serde(default)]
pub function: bool,
}