editor: Hide mouse cursor also for movements and selections (#27677)
This enables hiding mouse cursor even on cursor movements like up, down, etc. or selections made using keyboard, etc. Renamed existing boolean setting "hide_mouse_while_typing" to "hide_mouse". It can have three values: `on_typing_and_movement`, `on_typing`, `never`. Release Notes: - Now mouse cursor hides even when you navigate, or make selections using keyboard in editor. This behavior can be changed by setting `hide_mouse` to `on_typing_and_movement`, `on_typing` or `never`.
This commit is contained in:
parent
7fe6188f8e
commit
4970fe2d56
8 changed files with 264 additions and 44 deletions
|
@ -31,3 +31,9 @@ pub(crate) mod m_2025_03_06 {
|
|||
|
||||
pub(crate) use keymap::KEYMAP_PATTERNS;
|
||||
}
|
||||
|
||||
pub(crate) mod m_2025_03_29 {
|
||||
mod settings;
|
||||
|
||||
pub(crate) use settings::SETTINGS_PATTERNS;
|
||||
}
|
||||
|
|
65
crates/migrator/src/migrations/m_2025_03_29/settings.rs
Normal file
65
crates/migrator/src/migrations/m_2025_03_29/settings.rs
Normal file
|
@ -0,0 +1,65 @@
|
|||
use std::ops::Range;
|
||||
use tree_sitter::{Query, QueryMatch};
|
||||
|
||||
use crate::patterns::SETTINGS_ROOT_KEY_VALUE_PATTERN;
|
||||
use crate::MigrationPatterns;
|
||||
|
||||
pub const SETTINGS_PATTERNS: MigrationPatterns = &[
|
||||
(SETTINGS_ROOT_KEY_VALUE_PATTERN, replace_setting_name),
|
||||
(SETTINGS_ROOT_KEY_VALUE_PATTERN, replace_setting_value),
|
||||
];
|
||||
|
||||
fn replace_setting_value(
|
||||
contents: &str,
|
||||
mat: &QueryMatch,
|
||||
query: &Query,
|
||||
) -> Option<(Range<usize>, String)> {
|
||||
let setting_capture_ix = query.capture_index_for_name("name")?;
|
||||
let setting_name_range = mat
|
||||
.nodes_for_capture_index(setting_capture_ix)
|
||||
.next()?
|
||||
.byte_range();
|
||||
let setting_name = contents.get(setting_name_range.clone())?;
|
||||
|
||||
if setting_name != "hide_mouse_while_typing" {
|
||||
return None;
|
||||
}
|
||||
|
||||
let value_capture_ix = query.capture_index_for_name("value")?;
|
||||
let value_range = mat
|
||||
.nodes_for_capture_index(value_capture_ix)
|
||||
.next()?
|
||||
.byte_range();
|
||||
let value = contents.get(value_range.clone())?;
|
||||
|
||||
let new_value = if value.trim() == "true" {
|
||||
"\"on_typing_and_movement\""
|
||||
} else if value.trim() == "false" {
|
||||
"\"never\""
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
|
||||
Some((value_range, new_value.to_string()))
|
||||
}
|
||||
|
||||
fn replace_setting_name(
|
||||
contents: &str,
|
||||
mat: &QueryMatch,
|
||||
query: &Query,
|
||||
) -> Option<(Range<usize>, String)> {
|
||||
let setting_capture_ix = query.capture_index_for_name("name")?;
|
||||
let setting_name_range = mat
|
||||
.nodes_for_capture_index(setting_capture_ix)
|
||||
.next()?
|
||||
.byte_range();
|
||||
let setting_name = contents.get(setting_name_range.clone())?;
|
||||
|
||||
let new_setting_name = if setting_name == "hide_mouse_while_typing" {
|
||||
"hide_mouse"
|
||||
} else {
|
||||
return None;
|
||||
};
|
||||
|
||||
Some((setting_name_range, new_setting_name.to_string()))
|
||||
}
|
|
@ -116,6 +116,10 @@ pub fn migrate_settings(text: &str) -> Result<Option<String>> {
|
|||
migrations::m_2025_01_30::SETTINGS_PATTERNS,
|
||||
&SETTINGS_QUERY_2025_01_30,
|
||||
),
|
||||
(
|
||||
migrations::m_2025_03_29::SETTINGS_PATTERNS,
|
||||
&SETTINGS_QUERY_2025_03_29,
|
||||
),
|
||||
];
|
||||
run_migrations(text, migrations)
|
||||
}
|
||||
|
@ -182,6 +186,10 @@ define_query!(
|
|||
SETTINGS_QUERY_2025_01_30,
|
||||
migrations::m_2025_01_30::SETTINGS_PATTERNS
|
||||
);
|
||||
define_query!(
|
||||
SETTINGS_QUERY_2025_03_29,
|
||||
migrations::m_2025_03_29::SETTINGS_PATTERNS
|
||||
);
|
||||
|
||||
// custom query
|
||||
static EDIT_PREDICTION_SETTINGS_MIGRATION_QUERY: LazyLock<Query> = LazyLock::new(|| {
|
||||
|
|
|
@ -2,7 +2,7 @@ pub const SETTINGS_ROOT_KEY_VALUE_PATTERN: &str = r#"(document
|
|||
(object
|
||||
(pair
|
||||
key: (string (string_content) @name)
|
||||
value: (_)
|
||||
value: (_) @value
|
||||
)
|
||||
)
|
||||
)"#;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue