Fix inlay settings

Conrad Irwin created

Change summary

assets/settings/default.json                     |   1 
crates/collab/src/tests/editor_tests.rs          |  94 ++--
crates/editor/src/editor.rs                      |   9 
crates/editor/src/hover_links.rs                 |  20 
crates/editor/src/hover_popover.rs               |  20 
crates/editor/src/inlay_hint_cache.rs            | 315 +++++++++--------
crates/language/src/language_settings.rs         | 123 ++++++
crates/onboarding/src/basics_page.rs             |   4 
crates/onboarding/src/editing_page.rs            |  11 
crates/settings/src/settings_content/language.rs |  64 --
crates/settings/src/settings_store.rs            |   3 
11 files changed, 375 insertions(+), 289 deletions(-)

Detailed changes

assets/settings/default.json 🔗

@@ -603,6 +603,7 @@
     // Toggle certain types of hints on and off, all switched on by default.
     "show_type_hints": true,
     "show_parameter_hints": true,
+    "show_value_hints": true,
     // Corresponds to null/None LSP hint type value.
     "show_other_hints": true,
     // Whether to show a background for inlay hints.

crates/collab/src/tests/editor_tests.rs 🔗

@@ -27,7 +27,7 @@ use project::{
 use recent_projects::disconnected_overlay::DisconnectedOverlay;
 use rpc::RECEIVE_TIMEOUT;
 use serde_json::json;
-use settings::{InlayHintSettings, InlineBlameSettings, SettingsStore};
+use settings::{InlayHintSettingsContent, InlineBlameSettings, SettingsStore};
 use std::{
     collections::BTreeSet,
     ops::{Deref as _, Range},
@@ -1786,34 +1786,36 @@ async fn test_mutual_editor_inlay_hint_cache_update(
     cx_a.update(|cx| {
         SettingsStore::update_global(cx, |store, cx| {
             store.update_user_settings(cx, |settings| {
-                settings.project.all_languages.defaults.inlay_hints = Some(InlayHintSettings {
-                    enabled: true,
-                    show_value_hints: true,
-                    edit_debounce_ms: 0,
-                    scroll_debounce_ms: 0,
-                    show_type_hints: true,
-                    show_parameter_hints: false,
-                    show_other_hints: true,
-                    show_background: false,
-                    toggle_on_modifiers_press: None,
-                })
+                settings.project.all_languages.defaults.inlay_hints =
+                    Some(InlayHintSettingsContent {
+                        enabled: true,
+                        show_value_hints: true,
+                        edit_debounce_ms: 0,
+                        scroll_debounce_ms: 0,
+                        show_type_hints: true,
+                        show_parameter_hints: false,
+                        show_other_hints: true,
+                        show_background: false,
+                        toggle_on_modifiers_press: None,
+                    })
             });
         });
     });
     cx_b.update(|cx| {
         SettingsStore::update_global(cx, |store, cx| {
             store.update_user_settings(cx, |settings| {
-                settings.project.all_languages.defaults.inlay_hints = Some(InlayHintSettings {
-                    show_value_hints: true,
-                    enabled: true,
-                    edit_debounce_ms: 0,
-                    scroll_debounce_ms: 0,
-                    show_type_hints: true,
-                    show_parameter_hints: false,
-                    show_other_hints: true,
-                    show_background: false,
-                    toggle_on_modifiers_press: None,
-                })
+                settings.project.all_languages.defaults.inlay_hints =
+                    Some(InlayHintSettingsContent {
+                        show_value_hints: true,
+                        enabled: true,
+                        edit_debounce_ms: 0,
+                        scroll_debounce_ms: 0,
+                        show_type_hints: true,
+                        show_parameter_hints: false,
+                        show_other_hints: true,
+                        show_background: false,
+                        toggle_on_modifiers_press: None,
+                    })
             });
         });
     });
@@ -2036,34 +2038,36 @@ async fn test_inlay_hint_refresh_is_forwarded(
     cx_a.update(|cx| {
         SettingsStore::update_global(cx, |store, cx| {
             store.update_user_settings(cx, |settings| {
-                settings.project.all_languages.defaults.inlay_hints = Some(InlayHintSettings {
-                    show_value_hints: true,
-                    enabled: false,
-                    edit_debounce_ms: 0,
-                    scroll_debounce_ms: 0,
-                    show_type_hints: false,
-                    show_parameter_hints: false,
-                    show_other_hints: false,
-                    show_background: false,
-                    toggle_on_modifiers_press: None,
-                })
+                settings.project.all_languages.defaults.inlay_hints =
+                    Some(InlayHintSettingsContent {
+                        show_value_hints: true,
+                        enabled: false,
+                        edit_debounce_ms: 0,
+                        scroll_debounce_ms: 0,
+                        show_type_hints: false,
+                        show_parameter_hints: false,
+                        show_other_hints: false,
+                        show_background: false,
+                        toggle_on_modifiers_press: None,
+                    })
             });
         });
     });
     cx_b.update(|cx| {
         SettingsStore::update_global(cx, |store, cx| {
             store.update_user_settings(cx, |settings| {
-                settings.project.all_languages.defaults.inlay_hints = Some(InlayHintSettings {
-                    show_value_hints: true,
-                    enabled: true,
-                    edit_debounce_ms: 0,
-                    scroll_debounce_ms: 0,
-                    show_type_hints: true,
-                    show_parameter_hints: true,
-                    show_other_hints: true,
-                    show_background: false,
-                    toggle_on_modifiers_press: None,
-                })
+                settings.project.all_languages.defaults.inlay_hints =
+                    Some(InlayHintSettingsContent {
+                        show_value_hints: true,
+                        enabled: true,
+                        edit_debounce_ms: 0,
+                        scroll_debounce_ms: 0,
+                        show_type_hints: true,
+                        show_parameter_hints: true,
+                        show_other_hints: true,
+                        show_background: false,
+                        toggle_on_modifiers_press: None,
+                    })
             });
         });
     });

crates/editor/src/editor.rs 🔗

@@ -126,8 +126,8 @@ use language::{
     Language, OffsetRangeExt, Point, Runnable, RunnableRange, Selection, SelectionGoal, TextObject,
     TransactionId, TreeSitterOptions, WordsQuery,
     language_settings::{
-        self, LspInsertMode, RewrapBehavior, WordsCompletionMode, all_language_settings,
-        language_settings,
+        self, InlayHintSettings, LspInsertMode, RewrapBehavior, WordsCompletionMode,
+        all_language_settings, language_settings,
     },
     point_from_lsp, point_to_lsp, text_diff_with_options,
 };
@@ -169,10 +169,7 @@ use selections_collection::{
     MutableSelectionsCollection, SelectionsCollection, resolve_selections,
 };
 use serde::{Deserialize, Serialize};
-use settings::{
-    GitGutterSetting, InlayHintSettings, Settings, SettingsLocation, SettingsStore,
-    update_settings_file,
-};
+use settings::{GitGutterSetting, Settings, SettingsLocation, SettingsStore, update_settings_file};
 use smallvec::{SmallVec, smallvec};
 use snippet::Snippet;
 use std::{

crates/editor/src/hover_links.rs 🔗

@@ -932,7 +932,7 @@ mod tests {
     use gpui::Modifiers;
     use indoc::indoc;
     use lsp::request::{GotoDefinition, GotoTypeDefinition};
-    use settings::InlayHintSettings;
+    use settings::InlayHintSettingsContent;
     use util::{assert_set_eq, path};
     use workspace::item::Item;
 
@@ -1280,15 +1280,15 @@ mod tests {
     #[gpui::test]
     async fn test_inlay_hover_links(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                enabled: true,
-                show_value_hints: false,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                enabled: Some(true),
+                show_value_hints: Some(false),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });

crates/editor/src/hover_popover.rs 🔗

@@ -1005,7 +1005,7 @@ mod tests {
     use gpui::App;
     use indoc::indoc;
     use markdown::parser::MarkdownEvent;
-    use settings::InlayHintSettings;
+    use settings::InlayHintSettingsContent;
     use smol::stream::StreamExt;
     use std::sync::atomic;
     use std::sync::atomic::AtomicUsize;
@@ -1551,15 +1551,15 @@ mod tests {
     #[gpui::test]
     async fn test_hover_inlay_label_parts(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });

crates/editor/src/inlay_hint_cache.rs 🔗

@@ -20,12 +20,14 @@ use anyhow::Context as _;
 use clock::Global;
 use futures::future;
 use gpui::{AppContext as _, AsyncApp, Context, Entity, Task, Window};
-use language::{Buffer, BufferSnapshot, language_settings::InlayHintKind};
+use language::{
+    Buffer, BufferSnapshot,
+    language_settings::{InlayHintKind, InlayHintSettings},
+};
 use parking_lot::RwLock;
 use project::{InlayHint, ResolveState};
 
 use collections::{HashMap, HashSet, hash_map};
-use settings::InlayHintSettings;
 use smol::lock::Semaphore;
 use sum_tree::Bias;
 use text::{BufferId, ToOffset, ToPoint};
@@ -1307,7 +1309,7 @@ pub mod tests {
     use parking_lot::Mutex;
     use project::{FakeFs, Project};
     use serde_json::json;
-    use settings::{AllLanguageSettingsContent, InlayHintSettings, SettingsStore};
+    use settings::{AllLanguageSettingsContent, InlayHintSettingsContent, SettingsStore};
     use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering};
     use text::Point;
     use util::path;
@@ -1318,15 +1320,17 @@ pub mod tests {
     async fn test_basic_cache_update_with_duplicate_hints(cx: &mut gpui::TestAppContext) {
         let allowed_hint_kinds = HashSet::from_iter([None, Some(InlayHintKind::Type)]);
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: allowed_hint_kinds.contains(&Some(InlayHintKind::Type)),
-                show_parameter_hints: allowed_hint_kinds.contains(&Some(InlayHintKind::Parameter)),
-                show_other_hints: allowed_hint_kinds.contains(&None),
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(allowed_hint_kinds.contains(&Some(InlayHintKind::Type))),
+                show_parameter_hints: Some(
+                    allowed_hint_kinds.contains(&Some(InlayHintKind::Parameter)),
+                ),
+                show_other_hints: Some(allowed_hint_kinds.contains(&None)),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -1428,15 +1432,15 @@ pub mod tests {
     #[gpui::test]
     async fn test_cache_update_on_lsp_completion_tasks(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -1535,15 +1539,15 @@ pub mod tests {
     #[gpui::test]
     async fn test_no_hint_updates_for_unrelated_language_files(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -1765,15 +1769,17 @@ pub mod tests {
     async fn test_hint_setting_changes(cx: &mut gpui::TestAppContext) {
         let allowed_hint_kinds = HashSet::from_iter([None, Some(InlayHintKind::Type)]);
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: allowed_hint_kinds.contains(&Some(InlayHintKind::Type)),
-                show_parameter_hints: allowed_hint_kinds.contains(&Some(InlayHintKind::Parameter)),
-                show_other_hints: allowed_hint_kinds.contains(&None),
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(allowed_hint_kinds.contains(&Some(InlayHintKind::Type))),
+                show_parameter_hints: Some(
+                    allowed_hint_kinds.contains(&Some(InlayHintKind::Parameter)),
+                ),
+                show_other_hints: Some(allowed_hint_kinds.contains(&None)),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -1926,16 +1932,19 @@ pub mod tests {
             ),
         ] {
             update_test_language_settings(cx, |settings| {
-                settings.defaults.inlay_hints = Some(InlayHintSettings {
-                    show_value_hints: true,
-                    enabled: true,
-                    edit_debounce_ms: 0,
-                    scroll_debounce_ms: 0,
-                    show_type_hints: new_allowed_hint_kinds.contains(&Some(InlayHintKind::Type)),
-                    show_parameter_hints: new_allowed_hint_kinds
-                        .contains(&Some(InlayHintKind::Parameter)),
-                    show_other_hints: new_allowed_hint_kinds.contains(&None),
-                    show_background: false,
+                settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                    show_value_hints: Some(true),
+                    enabled: Some(true),
+                    edit_debounce_ms: Some(0),
+                    scroll_debounce_ms: Some(0),
+                    show_type_hints: Some(
+                        new_allowed_hint_kinds.contains(&Some(InlayHintKind::Type)),
+                    ),
+                    show_parameter_hints: Some(
+                        new_allowed_hint_kinds.contains(&Some(InlayHintKind::Parameter)),
+                    ),
+                    show_other_hints: Some(new_allowed_hint_kinds.contains(&None)),
+                    show_background: Some(false),
                     toggle_on_modifiers_press: None,
                 })
             });
@@ -1970,16 +1979,19 @@ pub mod tests {
 
         let another_allowed_hint_kinds = HashSet::from_iter([Some(InlayHintKind::Type)]);
         update_test_language_settings(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: false,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: another_allowed_hint_kinds.contains(&Some(InlayHintKind::Type)),
-                show_parameter_hints: another_allowed_hint_kinds
-                    .contains(&Some(InlayHintKind::Parameter)),
-                show_other_hints: another_allowed_hint_kinds.contains(&None),
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(false),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(
+                    another_allowed_hint_kinds.contains(&Some(InlayHintKind::Type)),
+                ),
+                show_parameter_hints: Some(
+                    another_allowed_hint_kinds.contains(&Some(InlayHintKind::Parameter)),
+                ),
+                show_other_hints: Some(another_allowed_hint_kinds.contains(&None)),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -2027,16 +2039,19 @@ pub mod tests {
 
         let final_allowed_hint_kinds = HashSet::from_iter([Some(InlayHintKind::Parameter)]);
         update_test_language_settings(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: final_allowed_hint_kinds.contains(&Some(InlayHintKind::Type)),
-                show_parameter_hints: final_allowed_hint_kinds
-                    .contains(&Some(InlayHintKind::Parameter)),
-                show_other_hints: final_allowed_hint_kinds.contains(&None),
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(
+                    final_allowed_hint_kinds.contains(&Some(InlayHintKind::Type)),
+                ),
+                show_parameter_hints: Some(
+                    final_allowed_hint_kinds.contains(&Some(InlayHintKind::Parameter)),
+                ),
+                show_other_hints: Some(final_allowed_hint_kinds.contains(&None)),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -2102,15 +2117,15 @@ pub mod tests {
     #[gpui::test]
     async fn test_hint_request_cancellation(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -2239,15 +2254,15 @@ pub mod tests {
     #[gpui::test(iterations = 10)]
     async fn test_large_buffer_inlay_requests_split(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -2540,15 +2555,15 @@ pub mod tests {
     #[gpui::test]
     async fn test_multiple_excerpts_large_multibuffer(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -2864,15 +2879,15 @@ pub mod tests {
     #[gpui::test]
     async fn test_excerpts_removed(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: false,
-                show_parameter_hints: false,
-                show_other_hints: false,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(false),
+                show_parameter_hints: Some(false),
+                show_other_hints: Some(false),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -3041,15 +3056,15 @@ pub mod tests {
             .unwrap();
 
         update_test_language_settings(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -3074,15 +3089,15 @@ pub mod tests {
     #[gpui::test]
     async fn test_inside_char_boundary_range_hints(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -3167,15 +3182,15 @@ pub mod tests {
     #[gpui::test]
     async fn test_toggle_inlay_hints(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: false,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(false),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -3244,15 +3259,15 @@ pub mod tests {
             .unwrap();
 
         update_test_language_settings(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });
@@ -3305,15 +3320,15 @@ pub mod tests {
     #[gpui::test]
     async fn test_inlays_at_the_same_place(cx: &mut gpui::TestAppContext) {
         init_test(cx, |settings| {
-            settings.defaults.inlay_hints = Some(InlayHintSettings {
-                show_value_hints: true,
-                enabled: true,
-                edit_debounce_ms: 0,
-                scroll_debounce_ms: 0,
-                show_type_hints: true,
-                show_parameter_hints: true,
-                show_other_hints: true,
-                show_background: false,
+            settings.defaults.inlay_hints = Some(InlayHintSettingsContent {
+                show_value_hints: Some(true),
+                enabled: Some(true),
+                edit_debounce_ms: Some(0),
+                scroll_debounce_ms: Some(0),
+                show_type_hints: Some(true),
+                show_parameter_hints: Some(true),
+                show_other_hints: Some(true),
+                show_background: Some(false),
                 toggle_on_modifiers_press: None,
             })
         });

crates/language/src/language_settings.rs 🔗

@@ -7,7 +7,7 @@ use ec4rs::{
     property::{FinalNewline, IndentSize, IndentStyle, MaxLineLen, TabWidth, TrimTrailingWs},
 };
 use globset::{Glob, GlobMatcher, GlobSet, GlobSetBuilder};
-use gpui::App;
+use gpui::{App, Modifiers};
 use itertools::{Either, Itertools};
 use schemars::{JsonSchema, json_schema};
 use serde::{Deserialize, Serialize};
@@ -130,7 +130,7 @@ pub struct LanguageSettings {
     /// Whether to start a new line with a comment when a previous line is a comment as well.
     pub extend_comment_on_newline: bool,
     /// Inlay hint related settings.
-    pub inlay_hints: settings::InlayHintSettings,
+    pub inlay_hints: InlayHintSettings,
     /// Whether to automatically close brackets.
     pub use_autoclose: bool,
     /// Whether to automatically surround text with brackets.
@@ -211,6 +211,73 @@ impl LanguageSettings {
     }
 }
 
+// The settings for inlay hints.
+#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+pub struct InlayHintSettings {
+    /// Global switch to toggle hints on and off.
+    ///
+    /// Default: false
+    pub enabled: bool,
+    /// Global switch to toggle inline values on and off when debugging.
+    ///
+    /// Default: true
+    pub show_value_hints: bool,
+    /// Whether type hints should be shown.
+    ///
+    /// Default: true
+    pub show_type_hints: bool,
+    /// Whether parameter hints should be shown.
+    ///
+    /// Default: true
+    pub show_parameter_hints: bool,
+    /// Whether other hints should be shown.
+    ///
+    /// Default: true
+    pub show_other_hints: bool,
+    /// Whether to show a background for inlay hints.
+    ///
+    /// If set to `true`, the background will use the `hint.background` color
+    /// from the current theme.
+    ///
+    /// Default: false
+    pub show_background: bool,
+    /// Whether or not to debounce inlay hints updates after buffer edits.
+    ///
+    /// Set to 0 to disable debouncing.
+    ///
+    /// Default: 700
+    pub edit_debounce_ms: u64,
+    /// Whether or not to debounce inlay hints updates after buffer scrolls.
+    ///
+    /// Set to 0 to disable debouncing.
+    ///
+    /// Default: 50
+    pub scroll_debounce_ms: u64,
+    /// Toggles inlay hints (hides or shows) when the user presses the modifiers specified.
+    /// If only a subset of the modifiers specified is pressed, hints are not toggled.
+    /// If no modifiers are specified, this is equivalent to `None`.
+    ///
+    /// Default: None
+    pub toggle_on_modifiers_press: Option<Modifiers>,
+}
+
+impl InlayHintSettings {
+    /// Returns the kinds of inlay hints that are enabled based on the settings.
+    pub fn enabled_inlay_hint_kinds(&self) -> HashSet<Option<InlayHintKind>> {
+        let mut kinds = HashSet::default();
+        if self.show_type_hints {
+            kinds.insert(Some(InlayHintKind::Type));
+        }
+        if self.show_parameter_hints {
+            kinds.insert(Some(InlayHintKind::Parameter));
+        }
+        if self.show_other_hints {
+            kinds.insert(None);
+        }
+        kinds
+    }
+}
+
 /// The settings for edit predictions, such as [GitHub Copilot](https://github.com/features/copilot)
 /// or [Supermaven](https://supermaven.com).
 #[derive(Clone, Debug, Default, SettingsUi)]
@@ -377,6 +444,7 @@ impl settings::Settings for AllLanguageSettings {
     fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
         let all_languages = &content.project.all_languages;
         let defaults = all_languages.defaults.clone();
+        let inlay_hints = defaults.inlay_hints.unwrap();
         let default_language_settings = LanguageSettings {
             tab_size: defaults.tab_size.unwrap(),
             hard_tabs: defaults.hard_tabs.unwrap(),
@@ -401,7 +469,17 @@ impl settings::Settings for AllLanguageSettings {
             show_whitespaces: defaults.show_whitespaces.unwrap(),
             whitespace_map: defaults.whitespace_map.unwrap(),
             extend_comment_on_newline: defaults.extend_comment_on_newline.unwrap(),
-            inlay_hints: defaults.inlay_hints.unwrap(),
+            inlay_hints: InlayHintSettings {
+                enabled: inlay_hints.enabled.unwrap(),
+                show_value_hints: inlay_hints.show_value_hints.unwrap(),
+                show_type_hints: inlay_hints.show_type_hints.unwrap(),
+                show_parameter_hints: inlay_hints.show_parameter_hints.unwrap(),
+                show_other_hints: inlay_hints.show_other_hints.unwrap(),
+                show_background: inlay_hints.show_background.unwrap(),
+                edit_debounce_ms: inlay_hints.edit_debounce_ms.unwrap(),
+                scroll_debounce_ms: inlay_hints.scroll_debounce_ms.unwrap(),
+                toggle_on_modifiers_press: inlay_hints.toggle_on_modifiers_press,
+            },
             use_autoclose: defaults.use_autoclose.unwrap(),
             use_auto_surround: defaults.use_auto_surround.unwrap(),
             use_on_type_format: defaults.use_on_type_format.unwrap(),
@@ -805,7 +883,44 @@ fn merge_settings(settings: &mut LanguageSettings, src: &LanguageSettingsContent
     settings
         .extend_comment_on_newline
         .merge_from(&src.extend_comment_on_newline);
-    settings.inlay_hints.merge_from(&src.inlay_hints.clone());
+    if let Some(inlay_hints) = &src.inlay_hints {
+        settings
+            .inlay_hints
+            .enabled
+            .merge_from(&inlay_hints.enabled);
+        settings
+            .inlay_hints
+            .show_value_hints
+            .merge_from(&inlay_hints.show_value_hints);
+        settings
+            .inlay_hints
+            .show_type_hints
+            .merge_from(&inlay_hints.show_type_hints);
+        settings
+            .inlay_hints
+            .show_parameter_hints
+            .merge_from(&inlay_hints.show_parameter_hints);
+        settings
+            .inlay_hints
+            .show_other_hints
+            .merge_from(&inlay_hints.show_other_hints);
+        settings
+            .inlay_hints
+            .show_background
+            .merge_from(&inlay_hints.show_background);
+        settings
+            .inlay_hints
+            .edit_debounce_ms
+            .merge_from(&inlay_hints.edit_debounce_ms);
+        settings
+            .inlay_hints
+            .scroll_debounce_ms
+            .merge_from(&inlay_hints.scroll_debounce_ms);
+        if let Some(toggle_on_modifiers_press) = &inlay_hints.toggle_on_modifiers_press {
+            settings.inlay_hints.toggle_on_modifiers_press =
+                Some(toggle_on_modifiers_press.clone());
+        }
+    }
     settings
         .show_completions_on_input
         .merge_from(&src.show_completions_on_input);

crates/onboarding/src/basics_page.rs 🔗

@@ -251,9 +251,7 @@ fn render_telemetry_section(tab_index: &mut isize, cx: &App) -> impl IntoElement
                     fs.clone(),
                     cx,
                     move |setting, _| {
-                        dbg!(&setting.telemetry);
                         setting.telemetry.get_or_insert_default().metrics = Some(enabled);
-                        dbg!(&setting.telemetry);
                     }
                     ,
                 );
@@ -295,9 +293,7 @@ fn render_telemetry_section(tab_index: &mut isize, cx: &App) -> impl IntoElement
                         fs.clone(),
                         cx,
                         move |setting, _| {
-                            dbg!(&setting.telemetry);
                             setting.telemetry.get_or_insert_default().diagnostics = Some(enabled);
-                            dbg!(&setting.telemetry);
                         },
 
                     );

crates/onboarding/src/editing_page.rs 🔗

@@ -58,19 +58,14 @@ fn write_inlay_hints(enabled: bool, cx: &mut App) {
     curr_settings.defaults.inlay_hints.enabled = enabled;
     AllLanguageSettings::override_global(curr_settings, cx);
 
-    update_settings_file(fs, cx, move |settings, cx| {
+    update_settings_file(fs, cx, move |settings, _cx| {
         settings
             .project
             .all_languages
             .defaults
             .inlay_hints
-            .get_or_insert_with(|| {
-                AllLanguageSettings::get_global(cx)
-                    .clone()
-                    .defaults
-                    .inlay_hints
-            })
-            .enabled = enabled;
+            .get_or_insert_default()
+            .enabled = Some(enabled);
     });
 }
 

crates/settings/src/settings_content/language.rs 🔗

@@ -218,7 +218,7 @@ pub struct LanguageSettingsContent {
     /// Default: true
     pub extend_comment_on_newline: Option<bool>,
     /// Inlay hint related settings.
-    pub inlay_hints: Option<InlayHintSettings>,
+    pub inlay_hints: Option<InlayHintSettingsContent>,
     /// Whether to automatically type closing characters for you. For example,
     /// when you type (, Zed will automatically add a closing ) at the correct position.
     ///
@@ -348,81 +348,55 @@ pub struct JsxTagAutoCloseSettings {
 /// The settings for inlay hints.
 /// todo!() the fields of this struct should likely be optional,
 /// and a similar struct exposed from the language crate.
-#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
-pub struct InlayHintSettings {
+#[derive(Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
+pub struct InlayHintSettingsContent {
     /// Global switch to toggle hints on and off.
     ///
     /// Default: false
-    #[serde(default)]
-    pub enabled: bool,
+    pub enabled: Option<bool>,
     /// Global switch to toggle inline values on and off when debugging.
     ///
     /// Default: true
-    #[serde(default = "default_true")]
-    pub show_value_hints: bool,
+    pub show_value_hints: Option<bool>,
     /// Whether type hints should be shown.
     ///
     /// Default: true
-    #[serde(default = "default_true")]
-    pub show_type_hints: bool,
+    pub show_type_hints: Option<bool>,
     /// Whether parameter hints should be shown.
     ///
     /// Default: true
-    #[serde(default = "default_true")]
-    pub show_parameter_hints: bool,
+    pub show_parameter_hints: Option<bool>,
     /// Whether other hints should be shown.
     ///
     /// Default: true
-    #[serde(default = "default_true")]
-    pub show_other_hints: bool,
+    pub show_other_hints: Option<bool>,
     /// Whether to show a background for inlay hints.
     ///
     /// If set to `true`, the background will use the `hint.background` color
     /// from the current theme.
     ///
     /// Default: false
-    #[serde(default)]
-    pub show_background: bool,
+    pub show_background: Option<bool>,
     /// Whether or not to debounce inlay hints updates after buffer edits.
     ///
     /// Set to 0 to disable debouncing.
     ///
     /// Default: 700
-    #[serde(default = "edit_debounce_ms")]
-    pub edit_debounce_ms: u64,
+    pub edit_debounce_ms: Option<u64>,
     /// Whether or not to debounce inlay hints updates after buffer scrolls.
     ///
     /// Set to 0 to disable debouncing.
     ///
     /// Default: 50
-    #[serde(default = "scroll_debounce_ms")]
-    pub scroll_debounce_ms: u64,
+    pub scroll_debounce_ms: Option<u64>,
     /// Toggles inlay hints (hides or shows) when the user presses the modifiers specified.
     /// If only a subset of the modifiers specified is pressed, hints are not toggled.
-    /// If no modifiers are specified, this is equivalent to `None`.
+    /// If no modifiers are specified, this is equivalent to `null`.
     ///
-    /// Default: None
-    #[serde(default)]
+    /// Default: null
     pub toggle_on_modifiers_press: Option<Modifiers>,
 }
 
-impl InlayHintSettings {
-    /// Returns the kinds of inlay hints that are enabled based on the settings.
-    pub fn enabled_inlay_hint_kinds(&self) -> HashSet<Option<InlayHintKind>> {
-        let mut kinds = HashSet::default();
-        if self.show_type_hints {
-            kinds.insert(Some(InlayHintKind::Type));
-        }
-        if self.show_parameter_hints {
-            kinds.insert(Some(InlayHintKind::Parameter));
-        }
-        if self.show_other_hints {
-            kinds.insert(None);
-        }
-        kinds
-    }
-}
-
 /// The kind of an inlay hint.
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
 pub enum InlayHintKind {
@@ -433,7 +407,7 @@ pub enum InlayHintKind {
 }
 
 impl InlayHintKind {
-    /// Returns the [`InlayHintKind`] from the given name.
+    /// Returns the [`InlayHintKind`]fromthe given name.
     ///
     /// Returns `None` if `name` does not match any of the expected
     /// string representations.
@@ -454,15 +428,7 @@ impl InlayHintKind {
     }
 }
 
-fn edit_debounce_ms() -> u64 {
-    700
-}
-
-fn scroll_debounce_ms() -> u64 {
-    50
-}
-
-/// Controls how completions are processed for this language.
+/// Controls how completions are processedfor this anguage.
 #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
 #[serde(rename_all = "snake_case")]
 pub struct CompletionSettings {

crates/settings/src/settings_store.rs 🔗

@@ -424,7 +424,6 @@ impl SettingsStore {
                 async move {
                     let res = async move {
                         let old_text = Self::load_settings(&fs).await?;
-                        dbg!(&old_text);
                         let new_text = update(old_text, cx)?;
                         let settings_path = paths::settings_file().as_path();
                         if fs.is_file(settings_path).await {
@@ -555,10 +554,8 @@ impl SettingsStore {
         text: &str,
         update: impl FnOnce(&mut SettingsContent),
     ) -> Vec<(Range<usize>, String)> {
-        dbg!(&text);
         let old_content: UserSettingsContent =
             parse_json_with_comments(text).log_err().unwrap_or_default();
-        dbg!(&old_content);
         let mut new_content = old_content.clone();
         update(&mut new_content.content);