Settings refactor (#38367)
Co-Authored-By: Ben K <ben@zed.dev> Co-Authored-By: Anthony <anthony@zed.dev> Co-Authored-By: Mikayla <mikayla@zed.dev> Release Notes: - settings: Major internal changes to settings. The primary user-facing effect is that some settings which did not make sense in project settings files are no-longer read from there. (For example the inline blame settings) --------- Co-authored-by: Ben Kunkle <ben@zed.dev> Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com> Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
co-authored by
Ben Kunkle
Mikayla Maki
Anthony
parent
0a9023bce0
commit
fcdab160f9
@@ -1,9 +1,10 @@
|
||||
use crate::{code_context_menus::CompletionsMenu, editor_settings::SnippetSortOrder};
|
||||
use crate::code_context_menus::CompletionsMenu;
|
||||
use fuzzy::{StringMatch, StringMatchCandidate};
|
||||
use gpui::TestAppContext;
|
||||
use language::CodeLabel;
|
||||
use lsp::{CompletionItem, CompletionItemKind, LanguageServerId};
|
||||
use project::{Completion, CompletionSource};
|
||||
use settings::SnippetSortOrder;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use text::Anchor;
|
||||
|
||||
@@ -32,7 +32,6 @@ use ui::{Color, IntoElement, ListItem, Pixels, Popover, Styled, prelude::*};
|
||||
use util::ResultExt;
|
||||
|
||||
use crate::CodeActionSource;
|
||||
use crate::editor_settings::SnippetSortOrder;
|
||||
use crate::hover_popover::{hover_markdown_style, open_markdown_url};
|
||||
use crate::{
|
||||
CodeActionProvider, CompletionId, CompletionItemKind, CompletionProvider, DisplayRow, Editor,
|
||||
@@ -40,6 +39,7 @@ use crate::{
|
||||
actions::{ConfirmCodeAction, ConfirmCompletion},
|
||||
split_words, styled_runs_for_code_label,
|
||||
};
|
||||
use settings::SnippetSortOrder;
|
||||
|
||||
pub const MENU_GAP: Pixels = px(4.);
|
||||
pub const MENU_ASIDE_X_PADDING: Pixels = px(16.);
|
||||
|
||||
@@ -1529,12 +1529,11 @@ pub mod tests {
|
||||
use language::{
|
||||
Buffer, Diagnostic, DiagnosticEntry, DiagnosticSet, Language, LanguageConfig,
|
||||
LanguageMatcher,
|
||||
language_settings::{AllLanguageSettings, AllLanguageSettingsContent},
|
||||
};
|
||||
use lsp::LanguageServerId;
|
||||
use project::Project;
|
||||
use rand::{Rng, prelude::*};
|
||||
use settings::SettingsStore;
|
||||
use settings::{SettingsContent, SettingsStore};
|
||||
use smol::stream::StreamExt;
|
||||
use std::{env, sync::Arc};
|
||||
use text::PointUtf16;
|
||||
@@ -1564,7 +1563,9 @@ pub mod tests {
|
||||
log::info!("wrap width: {:?}", wrap_width);
|
||||
|
||||
cx.update(|cx| {
|
||||
init_test(cx, |s| s.defaults.tab_size = NonZeroU32::new(tab_size));
|
||||
init_test(cx, |s| {
|
||||
s.project.all_languages.defaults.tab_size = NonZeroU32::new(tab_size)
|
||||
});
|
||||
});
|
||||
|
||||
let buffer = cx.update(|cx| {
|
||||
@@ -1623,8 +1624,9 @@ pub mod tests {
|
||||
log::info!("setting tab size to {:?}", tab_size);
|
||||
cx.update(|cx| {
|
||||
cx.update_global::<SettingsStore, _>(|store, cx| {
|
||||
store.update_user_settings::<AllLanguageSettings>(cx, |s| {
|
||||
s.defaults.tab_size = NonZeroU32::new(tab_size);
|
||||
store.update_user_settings(cx, |s| {
|
||||
s.project.all_languages.defaults.tab_size =
|
||||
NonZeroU32::new(tab_size);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -2084,7 +2086,11 @@ pub mod tests {
|
||||
);
|
||||
language.set_theme(&theme);
|
||||
|
||||
cx.update(|cx| init_test(cx, |s| s.defaults.tab_size = Some(2.try_into().unwrap())));
|
||||
cx.update(|cx| {
|
||||
init_test(cx, |s| {
|
||||
s.project.all_languages.defaults.tab_size = Some(2.try_into().unwrap())
|
||||
})
|
||||
});
|
||||
|
||||
let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(language, cx));
|
||||
cx.condition(&buffer, |buf, _| !buf.is_parsing()).await;
|
||||
@@ -2910,7 +2916,7 @@ pub mod tests {
|
||||
chunks
|
||||
}
|
||||
|
||||
fn init_test(cx: &mut App, f: impl Fn(&mut AllLanguageSettingsContent)) {
|
||||
fn init_test(cx: &mut App, f: impl Fn(&mut SettingsContent)) {
|
||||
let settings = SettingsStore::test(cx);
|
||||
cx.set_global(settings);
|
||||
workspace::init_settings(cx);
|
||||
@@ -2919,7 +2925,7 @@ pub mod tests {
|
||||
Project::init_settings(cx);
|
||||
theme::init(LoadThemes::JustBase, cx);
|
||||
cx.update_global::<SettingsStore, _>(|store, cx| {
|
||||
store.update_user_settings::<AllLanguageSettings>(cx, f);
|
||||
store.update_user_settings(cx, f);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -160,9 +160,7 @@ use project::{
|
||||
},
|
||||
git_store::{GitStoreEvent, RepositoryEvent},
|
||||
lsp_store::{CompletionDocumentation, FormatTrigger, LspFormatTarget, OpenLspBufferHandle},
|
||||
project_settings::{
|
||||
DiagnosticSeverity, GitGutterSetting, GoToDiagnosticSeverityFilter, ProjectSettings,
|
||||
},
|
||||
project_settings::{DiagnosticSeverity, GoToDiagnosticSeverityFilter, ProjectSettings},
|
||||
};
|
||||
use rand::seq::SliceRandom;
|
||||
use rpc::{ErrorCode, ErrorExt, proto::PeerId};
|
||||
@@ -171,7 +169,7 @@ use selections_collection::{
|
||||
MutableSelectionsCollection, SelectionsCollection, resolve_selections,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{Settings, SettingsLocation, SettingsStore, update_settings_file};
|
||||
use settings::{GitGutterSetting, Settings, SettingsLocation, SettingsStore, update_settings_file};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use snippet::Snippet;
|
||||
use std::{
|
||||
@@ -2189,7 +2187,7 @@ impl Editor {
|
||||
show_selection_menu: None,
|
||||
show_git_blame_inline_delay_task: None,
|
||||
git_blame_inline_enabled: full_mode
|
||||
&& ProjectSettings::get_global(cx).git.inline_blame_enabled(),
|
||||
&& ProjectSettings::get_global(cx).git.inline_blame.enabled,
|
||||
render_diff_hunk_controls: Arc::new(render_diff_hunk_controls),
|
||||
serialize_dirty_buffers: !is_minimap
|
||||
&& ProjectSettings::get_global(cx)
|
||||
@@ -5591,8 +5589,9 @@ impl Editor {
|
||||
.language_at(buffer_position)
|
||||
.map(|language| language.name());
|
||||
|
||||
let completion_settings =
|
||||
language_settings(language.clone(), buffer_snapshot.file(), cx).completions;
|
||||
let completion_settings = language_settings(language.clone(), buffer_snapshot.file(), cx)
|
||||
.completions
|
||||
.clone();
|
||||
|
||||
let show_completion_documentation = buffer_snapshot
|
||||
.settings_at(buffer_position, cx)
|
||||
@@ -19008,8 +19007,8 @@ impl Editor {
|
||||
};
|
||||
let fs = workspace.read(cx).app_state().fs.clone();
|
||||
let current_show = TabBarSettings::get_global(cx).show;
|
||||
update_settings_file::<TabBarSettings>(fs, cx, move |setting, _| {
|
||||
setting.show = Some(!current_show);
|
||||
update_settings_file(fs, cx, move |setting, _| {
|
||||
setting.tab_bar.get_or_insert_default().show = Some(!current_show);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20723,7 +20722,7 @@ impl Editor {
|
||||
|
||||
if self.mode.is_full() {
|
||||
let show_inline_diagnostics = project_settings.diagnostics.inline.enabled;
|
||||
let inline_blame_enabled = project_settings.git.inline_blame_enabled();
|
||||
let inline_blame_enabled = project_settings.git.inline_blame.enabled;
|
||||
if self.show_inline_diagnostics != show_inline_diagnostics {
|
||||
self.show_inline_diagnostics = show_inline_diagnostics;
|
||||
self.refresh_inline_diagnostics(false, window, cx);
|
||||
@@ -21679,11 +21678,12 @@ impl Editor {
|
||||
}
|
||||
}
|
||||
|
||||
// todo(settings_refactor) this should not be!
|
||||
fn vim_enabled(cx: &App) -> bool {
|
||||
cx.global::<SettingsStore>()
|
||||
.raw_user_settings()
|
||||
.get("vim_mode")
|
||||
== Some(&serde_json::Value::Bool(true))
|
||||
.and_then(|settings| settings.content.vim_mode)
|
||||
== Some(true)
|
||||
}
|
||||
|
||||
fn process_completion_for_edit(
|
||||
@@ -23123,7 +23123,7 @@ impl EditorSnapshot {
|
||||
let show_git_gutter = self.show_git_diff_gutter.unwrap_or_else(|| {
|
||||
matches!(
|
||||
ProjectSettings::get_global(cx).git.git_gutter,
|
||||
Some(GitGutterSetting::TrackedFiles)
|
||||
GitGutterSetting::TrackedFiles
|
||||
)
|
||||
});
|
||||
let gutter_settings = EditorSettings::get_global(cx).gutter;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use gpui::{App, FontFeatures, FontWeight};
|
||||
use project::project_settings::{InlineBlameSettings, ProjectSettings};
|
||||
use settings::{EditableSettingControl, Settings};
|
||||
use project::project_settings::ProjectSettings;
|
||||
use settings::{EditableSettingControl, Settings, SettingsContent};
|
||||
use theme::{FontFamilyCache, FontFamilyName, ThemeSettings};
|
||||
use ui::{
|
||||
CheckboxWithLabel, ContextMenu, DropdownMenu, NumericStepper, SettingsContainer, SettingsGroup,
|
||||
@@ -59,7 +59,6 @@ struct BufferFontFamilyControl;
|
||||
|
||||
impl EditableSettingControl for BufferFontFamilyControl {
|
||||
type Value = SharedString;
|
||||
type Settings = ThemeSettings;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"Buffer Font Family".into()
|
||||
@@ -70,12 +69,8 @@ impl EditableSettingControl for BufferFontFamilyControl {
|
||||
settings.buffer_font.family.clone()
|
||||
}
|
||||
|
||||
fn apply(
|
||||
settings: &mut <Self::Settings as Settings>::FileContent,
|
||||
value: Self::Value,
|
||||
_cx: &App,
|
||||
) {
|
||||
settings.buffer_font_family = Some(FontFamilyName(value.into()));
|
||||
fn apply(settings: &mut SettingsContent, value: Self::Value, _cx: &App) {
|
||||
settings.theme.buffer_font_family = Some(FontFamilyName(value.into()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +113,6 @@ struct BufferFontSizeControl;
|
||||
|
||||
impl EditableSettingControl for BufferFontSizeControl {
|
||||
type Value = Pixels;
|
||||
type Settings = ThemeSettings;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"Buffer Font Size".into()
|
||||
@@ -128,12 +122,8 @@ impl EditableSettingControl for BufferFontSizeControl {
|
||||
ThemeSettings::get_global(cx).buffer_font_size(cx)
|
||||
}
|
||||
|
||||
fn apply(
|
||||
settings: &mut <Self::Settings as Settings>::FileContent,
|
||||
value: Self::Value,
|
||||
_cx: &App,
|
||||
) {
|
||||
settings.buffer_font_size = Some(value.into());
|
||||
fn apply(settings: &mut SettingsContent, value: Self::Value, _cx: &App) {
|
||||
settings.theme.buffer_font_size = Some(value.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +152,6 @@ struct BufferFontWeightControl;
|
||||
|
||||
impl EditableSettingControl for BufferFontWeightControl {
|
||||
type Value = FontWeight;
|
||||
type Settings = ThemeSettings;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"Buffer Font Weight".into()
|
||||
@@ -173,12 +162,8 @@ impl EditableSettingControl for BufferFontWeightControl {
|
||||
settings.buffer_font.weight
|
||||
}
|
||||
|
||||
fn apply(
|
||||
settings: &mut <Self::Settings as Settings>::FileContent,
|
||||
value: Self::Value,
|
||||
_cx: &App,
|
||||
) {
|
||||
settings.buffer_font_weight = Some(value.0);
|
||||
fn apply(settings: &mut SettingsContent, value: Self::Value, _cx: &App) {
|
||||
settings.theme.buffer_font_weight = Some(value.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +200,6 @@ struct BufferFontLigaturesControl;
|
||||
|
||||
impl EditableSettingControl for BufferFontLigaturesControl {
|
||||
type Value = bool;
|
||||
type Settings = ThemeSettings;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"Buffer Font Ligatures".into()
|
||||
@@ -230,14 +214,11 @@ impl EditableSettingControl for BufferFontLigaturesControl {
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
fn apply(
|
||||
settings: &mut <Self::Settings as Settings>::FileContent,
|
||||
value: Self::Value,
|
||||
_cx: &App,
|
||||
) {
|
||||
fn apply(settings: &mut SettingsContent, value: Self::Value, _cx: &App) {
|
||||
let value = if value { 1 } else { 0 };
|
||||
|
||||
let mut features = settings
|
||||
.theme
|
||||
.buffer_font_features
|
||||
.as_ref()
|
||||
.map(|features| features.tag_value_list().to_vec())
|
||||
@@ -249,7 +230,7 @@ impl EditableSettingControl for BufferFontLigaturesControl {
|
||||
features.push(("calt".into(), value));
|
||||
}
|
||||
|
||||
settings.buffer_font_features = Some(FontFeatures(Arc::new(features)));
|
||||
settings.theme.buffer_font_features = Some(FontFeatures(Arc::new(features)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +260,6 @@ struct InlineGitBlameControl;
|
||||
|
||||
impl EditableSettingControl for InlineGitBlameControl {
|
||||
type Value = bool;
|
||||
type Settings = ProjectSettings;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"Inline Git Blame".into()
|
||||
@@ -287,22 +267,16 @@ impl EditableSettingControl for InlineGitBlameControl {
|
||||
|
||||
fn read(cx: &App) -> Self::Value {
|
||||
let settings = ProjectSettings::get_global(cx);
|
||||
settings.git.inline_blame_enabled()
|
||||
settings.git.inline_blame.enabled
|
||||
}
|
||||
|
||||
fn apply(
|
||||
settings: &mut <Self::Settings as Settings>::FileContent,
|
||||
value: Self::Value,
|
||||
_cx: &App,
|
||||
) {
|
||||
if let Some(inline_blame) = settings.git.inline_blame.as_mut() {
|
||||
inline_blame.enabled = value;
|
||||
} else {
|
||||
settings.git.inline_blame = Some(InlineBlameSettings {
|
||||
enabled: false,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
fn apply(settings: &mut SettingsContent, value: Self::Value, _cx: &App) {
|
||||
settings
|
||||
.git
|
||||
.get_or_insert_default()
|
||||
.inline_blame
|
||||
.get_or_insert_default()
|
||||
.enabled = Some(value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +306,6 @@ struct LineNumbersControl;
|
||||
|
||||
impl EditableSettingControl for LineNumbersControl {
|
||||
type Value = bool;
|
||||
type Settings = EditorSettings;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"Line Numbers".into()
|
||||
@@ -343,19 +316,8 @@ impl EditableSettingControl for LineNumbersControl {
|
||||
settings.gutter.line_numbers
|
||||
}
|
||||
|
||||
fn apply(
|
||||
settings: &mut <Self::Settings as Settings>::FileContent,
|
||||
value: Self::Value,
|
||||
_cx: &App,
|
||||
) {
|
||||
if let Some(gutter) = settings.gutter.as_mut() {
|
||||
gutter.line_numbers = Some(value);
|
||||
} else {
|
||||
settings.gutter = Some(crate::editor_settings::GutterContent {
|
||||
line_numbers: Some(value),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
fn apply(settings: &mut SettingsContent, value: Self::Value, _cx: &App) {
|
||||
settings.editor.gutter.get_or_insert_default().line_numbers = Some(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +347,6 @@ struct RelativeLineNumbersControl;
|
||||
|
||||
impl EditableSettingControl for RelativeLineNumbersControl {
|
||||
type Value = bool;
|
||||
type Settings = EditorSettings;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"Relative Line Numbers".into()
|
||||
@@ -396,12 +357,8 @@ impl EditableSettingControl for RelativeLineNumbersControl {
|
||||
settings.relative_line_numbers
|
||||
}
|
||||
|
||||
fn apply(
|
||||
settings: &mut <Self::Settings as Settings>::FileContent,
|
||||
value: Self::Value,
|
||||
_cx: &App,
|
||||
) {
|
||||
settings.relative_line_numbers = Some(value);
|
||||
fn apply(settings: &mut SettingsContent, value: Self::Value, _cx: &App) {
|
||||
settings.editor.relative_line_numbers = Some(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,15 +22,15 @@ use indoc::indoc;
|
||||
use language::{
|
||||
BracketPairConfig,
|
||||
Capability::ReadWrite,
|
||||
DiagnosticSourceKind, FakeLspAdapter, LanguageConfig, LanguageConfigOverride, LanguageMatcher,
|
||||
LanguageName, Override, Point,
|
||||
DiagnosticSourceKind, FakeLspAdapter, IndentGuideSettings, LanguageConfig,
|
||||
LanguageConfigOverride, LanguageMatcher, LanguageName, Override, Point,
|
||||
language_settings::{
|
||||
AllLanguageSettings, AllLanguageSettingsContent, CompletionSettings, FormatterList,
|
||||
LanguageSettingsContent, LspInsertMode, PrettierSettings, SelectedFormatter,
|
||||
CompletionSettingsContent, FormatterList, LanguageSettingsContent, LspInsertMode,
|
||||
SelectedFormatter,
|
||||
},
|
||||
tree_sitter_python,
|
||||
};
|
||||
use language_settings::{Formatter, IndentGuideSettings};
|
||||
use language_settings::Formatter;
|
||||
use lsp::CompletionParams;
|
||||
use multi_buffer::{IndentGuide, PathKey};
|
||||
use parking_lot::Mutex;
|
||||
@@ -38,9 +38,13 @@ use pretty_assertions::{assert_eq, assert_ne};
|
||||
use project::{
|
||||
FakeFs,
|
||||
debugger::breakpoint_store::{BreakpointState, SourceBreakpoint},
|
||||
project_settings::{LspSettings, ProjectSettings},
|
||||
project_settings::LspSettings,
|
||||
};
|
||||
use serde_json::{self, json};
|
||||
use settings::{
|
||||
AllLanguageSettingsContent, IndentGuideBackgroundColoring, IndentGuideColoring,
|
||||
ProjectSettingsContent,
|
||||
};
|
||||
use std::{cell::RefCell, future::Future, rc::Rc, sync::atomic::AtomicBool, time::Instant};
|
||||
use std::{
|
||||
iter,
|
||||
@@ -11699,10 +11703,7 @@ async fn test_document_format_manual_trigger(cx: &mut TestAppContext) {
|
||||
update_test_language_settings(cx, |settings| {
|
||||
// Enable Prettier formatting for the same buffer, and ensure
|
||||
// LSP is called instead of Prettier.
|
||||
settings.defaults.prettier = Some(PrettierSettings {
|
||||
allowed: true,
|
||||
..PrettierSettings::default()
|
||||
});
|
||||
settings.defaults.prettier.get_or_insert_default().allowed = Some(true);
|
||||
});
|
||||
let mut fake_servers = language_registry.register_fake_lsp(
|
||||
"Rust",
|
||||
@@ -12088,10 +12089,7 @@ async fn test_organize_imports_manual_trigger(cx: &mut TestAppContext) {
|
||||
Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()),
|
||||
)));
|
||||
update_test_language_settings(cx, |settings| {
|
||||
settings.defaults.prettier = Some(PrettierSettings {
|
||||
allowed: true,
|
||||
..PrettierSettings::default()
|
||||
});
|
||||
settings.defaults.prettier.get_or_insert_default().allowed = Some(true);
|
||||
});
|
||||
let mut fake_servers = language_registry.register_fake_lsp(
|
||||
"TypeScript",
|
||||
@@ -12402,8 +12400,8 @@ async fn test_handle_input_for_show_signature_help_auto_signature_help_true(
|
||||
|
||||
cx.update(|cx| {
|
||||
cx.update_global::<SettingsStore, _>(|settings, cx| {
|
||||
settings.update_user_settings::<EditorSettings>(cx, |settings| {
|
||||
settings.auto_signature_help = Some(true);
|
||||
settings.update_user_settings(cx, |settings| {
|
||||
settings.editor.auto_signature_help = Some(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -12542,9 +12540,9 @@ async fn test_handle_input_with_different_show_signature_settings(cx: &mut TestA
|
||||
|
||||
cx.update(|cx| {
|
||||
cx.update_global::<SettingsStore, _>(|settings, cx| {
|
||||
settings.update_user_settings::<EditorSettings>(cx, |settings| {
|
||||
settings.auto_signature_help = Some(false);
|
||||
settings.show_signature_help_after_edits = Some(false);
|
||||
settings.update_user_settings(cx, |settings| {
|
||||
settings.editor.auto_signature_help = Some(false);
|
||||
settings.editor.show_signature_help_after_edits = Some(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -12669,9 +12667,9 @@ async fn test_handle_input_with_different_show_signature_settings(cx: &mut TestA
|
||||
// Ensure that signature_help is called when enabled afte edits
|
||||
cx.update(|_, cx| {
|
||||
cx.update_global::<SettingsStore, _>(|settings, cx| {
|
||||
settings.update_user_settings::<EditorSettings>(cx, |settings| {
|
||||
settings.auto_signature_help = Some(false);
|
||||
settings.show_signature_help_after_edits = Some(true);
|
||||
settings.update_user_settings(cx, |settings| {
|
||||
settings.editor.auto_signature_help = Some(false);
|
||||
settings.editor.show_signature_help_after_edits = Some(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -12711,9 +12709,9 @@ async fn test_handle_input_with_different_show_signature_settings(cx: &mut TestA
|
||||
// Ensure that signature_help is called when auto signature help override is enabled
|
||||
cx.update(|_, cx| {
|
||||
cx.update_global::<SettingsStore, _>(|settings, cx| {
|
||||
settings.update_user_settings::<EditorSettings>(cx, |settings| {
|
||||
settings.auto_signature_help = Some(true);
|
||||
settings.show_signature_help_after_edits = Some(false);
|
||||
settings.update_user_settings(cx, |settings| {
|
||||
settings.editor.auto_signature_help = Some(true);
|
||||
settings.editor.show_signature_help_after_edits = Some(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -12755,8 +12753,8 @@ async fn test_signature_help(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
cx.update(|cx| {
|
||||
cx.update_global::<SettingsStore, _>(|settings, cx| {
|
||||
settings.update_user_settings::<EditorSettings>(cx, |settings| {
|
||||
settings.auto_signature_help = Some(true);
|
||||
settings.update_user_settings(cx, |settings| {
|
||||
settings.editor.auto_signature_help = Some(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -13346,12 +13344,11 @@ async fn test_completion_mode(cx: &mut TestAppContext) {
|
||||
);
|
||||
|
||||
update_test_language_settings(&mut cx, |settings| {
|
||||
settings.defaults.completions = Some(CompletionSettings {
|
||||
lsp_insert_mode,
|
||||
words: WordsCompletionMode::Disabled,
|
||||
words_min_length: 0,
|
||||
lsp: true,
|
||||
lsp_fetch_timeout_ms: 0,
|
||||
settings.defaults.completions = Some(CompletionSettingsContent {
|
||||
lsp_insert_mode: Some(lsp_insert_mode),
|
||||
words: Some(WordsCompletionMode::Disabled),
|
||||
words_min_length: Some(0),
|
||||
..Default::default()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13406,13 +13403,12 @@ async fn test_completion_with_mode_specified_by_action(cx: &mut TestAppContext)
|
||||
let expected_with_replace_mode = "SubscriptionErrorˇ";
|
||||
|
||||
update_test_language_settings(&mut cx, |settings| {
|
||||
settings.defaults.completions = Some(CompletionSettings {
|
||||
words: WordsCompletionMode::Disabled,
|
||||
words_min_length: 0,
|
||||
settings.defaults.completions = Some(CompletionSettingsContent {
|
||||
words: Some(WordsCompletionMode::Disabled),
|
||||
words_min_length: Some(0),
|
||||
// set the opposite here to ensure that the action is overriding the default behavior
|
||||
lsp_insert_mode: LspInsertMode::Insert,
|
||||
lsp: true,
|
||||
lsp_fetch_timeout_ms: 0,
|
||||
lsp_insert_mode: Some(LspInsertMode::Insert),
|
||||
..Default::default()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13443,13 +13439,12 @@ async fn test_completion_with_mode_specified_by_action(cx: &mut TestAppContext)
|
||||
apply_additional_edits.await.unwrap();
|
||||
|
||||
update_test_language_settings(&mut cx, |settings| {
|
||||
settings.defaults.completions = Some(CompletionSettings {
|
||||
words: WordsCompletionMode::Disabled,
|
||||
words_min_length: 0,
|
||||
settings.defaults.completions = Some(CompletionSettingsContent {
|
||||
words: Some(WordsCompletionMode::Disabled),
|
||||
words_min_length: Some(0),
|
||||
// set the opposite here to ensure that the action is overriding the default behavior
|
||||
lsp_insert_mode: LspInsertMode::Replace,
|
||||
lsp: true,
|
||||
lsp_fetch_timeout_ms: 0,
|
||||
lsp_insert_mode: Some(LspInsertMode::Replace),
|
||||
..Default::default()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14185,12 +14180,11 @@ async fn test_completion_reuse(cx: &mut TestAppContext) {
|
||||
async fn test_word_completion(cx: &mut TestAppContext) {
|
||||
let lsp_fetch_timeout_ms = 10;
|
||||
init_test(cx, |language_settings| {
|
||||
language_settings.defaults.completions = Some(CompletionSettings {
|
||||
words: WordsCompletionMode::Fallback,
|
||||
words_min_length: 0,
|
||||
lsp: true,
|
||||
lsp_fetch_timeout_ms: 10,
|
||||
lsp_insert_mode: LspInsertMode::Insert,
|
||||
language_settings.defaults.completions = Some(CompletionSettingsContent {
|
||||
words_min_length: Some(0),
|
||||
lsp_fetch_timeout_ms: Some(10),
|
||||
lsp_insert_mode: Some(LspInsertMode::Insert),
|
||||
..Default::default()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14282,12 +14276,11 @@ async fn test_word_completion(cx: &mut TestAppContext) {
|
||||
#[gpui::test]
|
||||
async fn test_word_completions_do_not_duplicate_lsp_ones(cx: &mut TestAppContext) {
|
||||
init_test(cx, |language_settings| {
|
||||
language_settings.defaults.completions = Some(CompletionSettings {
|
||||
words: WordsCompletionMode::Enabled,
|
||||
words_min_length: 0,
|
||||
lsp: true,
|
||||
lsp_fetch_timeout_ms: 0,
|
||||
lsp_insert_mode: LspInsertMode::Insert,
|
||||
language_settings.defaults.completions = Some(CompletionSettingsContent {
|
||||
words: Some(WordsCompletionMode::Enabled),
|
||||
words_min_length: Some(0),
|
||||
lsp_insert_mode: Some(LspInsertMode::Insert),
|
||||
..Default::default()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14346,12 +14339,11 @@ async fn test_word_completions_do_not_duplicate_lsp_ones(cx: &mut TestAppContext
|
||||
#[gpui::test]
|
||||
async fn test_word_completions_continue_on_typing(cx: &mut TestAppContext) {
|
||||
init_test(cx, |language_settings| {
|
||||
language_settings.defaults.completions = Some(CompletionSettings {
|
||||
words: WordsCompletionMode::Disabled,
|
||||
words_min_length: 0,
|
||||
lsp: true,
|
||||
lsp_fetch_timeout_ms: 0,
|
||||
lsp_insert_mode: LspInsertMode::Insert,
|
||||
language_settings.defaults.completions = Some(CompletionSettingsContent {
|
||||
words: Some(WordsCompletionMode::Disabled),
|
||||
words_min_length: Some(0),
|
||||
lsp_insert_mode: Some(LspInsertMode::Insert),
|
||||
..Default::default()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14420,12 +14412,11 @@ async fn test_word_completions_continue_on_typing(cx: &mut TestAppContext) {
|
||||
#[gpui::test]
|
||||
async fn test_word_completions_usually_skip_digits(cx: &mut TestAppContext) {
|
||||
init_test(cx, |language_settings| {
|
||||
language_settings.defaults.completions = Some(CompletionSettings {
|
||||
words: WordsCompletionMode::Fallback,
|
||||
words_min_length: 0,
|
||||
lsp: false,
|
||||
lsp_fetch_timeout_ms: 0,
|
||||
lsp_insert_mode: LspInsertMode::Insert,
|
||||
language_settings.defaults.completions = Some(CompletionSettingsContent {
|
||||
words_min_length: Some(0),
|
||||
lsp: Some(false),
|
||||
lsp_insert_mode: Some(LspInsertMode::Insert),
|
||||
..Default::default()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14483,12 +14474,11 @@ async fn test_word_completions_usually_skip_digits(cx: &mut TestAppContext) {
|
||||
#[gpui::test]
|
||||
async fn test_word_completions_do_not_show_before_threshold(cx: &mut TestAppContext) {
|
||||
init_test(cx, |language_settings| {
|
||||
language_settings.defaults.completions = Some(CompletionSettings {
|
||||
words: WordsCompletionMode::Enabled,
|
||||
words_min_length: 3,
|
||||
lsp: true,
|
||||
lsp_fetch_timeout_ms: 0,
|
||||
lsp_insert_mode: LspInsertMode::Insert,
|
||||
language_settings.defaults.completions = Some(CompletionSettingsContent {
|
||||
words: Some(WordsCompletionMode::Enabled),
|
||||
words_min_length: Some(3),
|
||||
lsp_insert_mode: Some(LspInsertMode::Insert),
|
||||
..Default::default()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14553,12 +14543,11 @@ async fn test_word_completions_do_not_show_before_threshold(cx: &mut TestAppCont
|
||||
#[gpui::test]
|
||||
async fn test_word_completions_disabled(cx: &mut TestAppContext) {
|
||||
init_test(cx, |language_settings| {
|
||||
language_settings.defaults.completions = Some(CompletionSettings {
|
||||
words: WordsCompletionMode::Enabled,
|
||||
words_min_length: 0,
|
||||
lsp: true,
|
||||
lsp_fetch_timeout_ms: 0,
|
||||
lsp_insert_mode: LspInsertMode::Insert,
|
||||
language_settings.defaults.completions = Some(CompletionSettingsContent {
|
||||
words: Some(WordsCompletionMode::Enabled),
|
||||
words_min_length: Some(0),
|
||||
lsp_insert_mode: Some(LspInsertMode::Insert),
|
||||
..Default::default()
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17067,7 +17056,7 @@ async fn test_language_server_restart_due_to_settings_change(cx: &mut TestAppCon
|
||||
let _fake_server = fake_servers.next().await.unwrap();
|
||||
update_test_language_settings(cx, |language_settings| {
|
||||
language_settings.languages.0.insert(
|
||||
language_name.clone(),
|
||||
language_name.clone().0,
|
||||
LanguageSettingsContent {
|
||||
tab_size: NonZeroU32::new(8),
|
||||
..Default::default()
|
||||
@@ -17991,10 +17980,7 @@ async fn test_document_format_with_prettier(cx: &mut TestAppContext) {
|
||||
Some(tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into()),
|
||||
)));
|
||||
update_test_language_settings(cx, |settings| {
|
||||
settings.defaults.prettier = Some(PrettierSettings {
|
||||
allowed: true,
|
||||
..PrettierSettings::default()
|
||||
});
|
||||
settings.defaults.prettier.get_or_insert_default().allowed = Some(true);
|
||||
});
|
||||
|
||||
let test_plugin = "test_plugin";
|
||||
@@ -19982,7 +19968,8 @@ fn indent_guide(buffer_id: BufferId, start_row: u32, end_row: u32, depth: u32) -
|
||||
enabled: true,
|
||||
line_width: 1,
|
||||
active_line_width: 1,
|
||||
..Default::default()
|
||||
coloring: IndentGuideColoring::default(),
|
||||
background_coloring: IndentGuideBackgroundColoring::default(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -23672,8 +23659,8 @@ println!("5");
|
||||
});
|
||||
|
||||
cx.update_global(|store: &mut SettingsStore, cx| {
|
||||
store.update_user_settings::<WorkspaceSettings>(cx, |s| {
|
||||
s.restore_on_file_reopen = Some(false);
|
||||
store.update_user_settings(cx, |s| {
|
||||
s.workspace.restore_on_file_reopen = Some(false);
|
||||
});
|
||||
});
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
@@ -23697,8 +23684,8 @@ println!("5");
|
||||
assert!(pane.active_item().is_none());
|
||||
});
|
||||
cx.update_global(|store: &mut SettingsStore, cx| {
|
||||
store.update_user_settings::<WorkspaceSettings>(cx, |s| {
|
||||
s.restore_on_file_reopen = Some(true);
|
||||
store.update_user_settings(cx, |s| {
|
||||
s.workspace.restore_on_file_reopen = Some(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25120,18 +25107,18 @@ pub(crate) fn update_test_language_settings(
|
||||
) {
|
||||
cx.update(|cx| {
|
||||
SettingsStore::update_global(cx, |store, cx| {
|
||||
store.update_user_settings::<AllLanguageSettings>(cx, f);
|
||||
store.update_user_settings(cx, |settings| f(&mut settings.project.all_languages));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn update_test_project_settings(
|
||||
cx: &mut TestAppContext,
|
||||
f: impl Fn(&mut ProjectSettings),
|
||||
f: impl Fn(&mut ProjectSettingsContent),
|
||||
) {
|
||||
cx.update(|cx| {
|
||||
SettingsStore::update_global(cx, |store, cx| {
|
||||
store.update_user_settings::<ProjectSettings>(cx, f);
|
||||
store.update_user_settings(cx, |settings| f(&mut settings.project));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -51,9 +51,7 @@ use gpui::{
|
||||
transparent_black,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use language::language_settings::{
|
||||
IndentGuideBackgroundColoring, IndentGuideColoring, IndentGuideSettings, ShowWhitespaceSetting,
|
||||
};
|
||||
use language::{IndentGuideSettings, language_settings::ShowWhitespaceSetting};
|
||||
use markdown::Markdown;
|
||||
use multi_buffer::{
|
||||
Anchor, ExcerptId, ExcerptInfo, ExpandExcerptDirection, ExpandInfo, MultiBufferPoint,
|
||||
@@ -63,9 +61,12 @@ use multi_buffer::{
|
||||
use project::{
|
||||
Entry, ProjectPath,
|
||||
debugger::breakpoint_store::{Breakpoint, BreakpointSessionState},
|
||||
project_settings::{GitGutterSetting, GitHunkStyleSetting, ProjectSettings},
|
||||
project_settings::ProjectSettings,
|
||||
};
|
||||
use settings::{
|
||||
GitGutterSetting, GitHunkStyleSetting, IndentGuideBackgroundColoring, IndentGuideColoring,
|
||||
Settings,
|
||||
};
|
||||
use settings::Settings;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use std::{
|
||||
any::TypeId,
|
||||
@@ -2099,10 +2100,7 @@ impl EditorElement {
|
||||
.display_diff_hunks_for_rows(display_rows, folded_buffers)
|
||||
.map(|hunk| (hunk, None))
|
||||
.collect::<Vec<_>>();
|
||||
let git_gutter_setting = ProjectSettings::get_global(cx)
|
||||
.git
|
||||
.git_gutter
|
||||
.unwrap_or_default();
|
||||
let git_gutter_setting = ProjectSettings::get_global(cx).git.git_gutter;
|
||||
if let GitGutterSetting::TrackedFiles = git_gutter_setting {
|
||||
for (hunk, hitbox) in &mut display_hunks {
|
||||
if matches!(hunk, DisplayDiffHunk::Unfolded { .. }) {
|
||||
@@ -2454,11 +2452,7 @@ impl EditorElement {
|
||||
let padding = {
|
||||
const INLINE_ACCEPT_SUGGESTION_EM_WIDTHS: f32 = 14.;
|
||||
|
||||
let mut padding = ProjectSettings::get_global(cx)
|
||||
.git
|
||||
.inline_blame
|
||||
.unwrap_or_default()
|
||||
.padding as f32;
|
||||
let mut padding = ProjectSettings::get_global(cx).git.inline_blame.padding as f32;
|
||||
|
||||
if let Some(edit_prediction) = editor.active_edit_prediction.as_ref()
|
||||
&& let EditPrediction::Edit {
|
||||
@@ -2492,12 +2486,10 @@ impl EditorElement {
|
||||
|
||||
let padded_line_end = line_end + padding;
|
||||
|
||||
let min_column_in_pixels = ProjectSettings::get_global(cx)
|
||||
.git
|
||||
.inline_blame
|
||||
.map(|settings| settings.min_column)
|
||||
.map(|col| self.column_pixels(col as usize, window))
|
||||
.unwrap_or(px(0.));
|
||||
let min_column_in_pixels = self.column_pixels(
|
||||
ProjectSettings::get_global(cx).git.inline_blame.min_column as usize,
|
||||
window,
|
||||
);
|
||||
let min_start = content_origin.x - scroll_pixel_position.x + min_column_in_pixels;
|
||||
|
||||
cmp::max(padded_line_end, min_start)
|
||||
@@ -5673,7 +5665,7 @@ impl EditorElement {
|
||||
|
||||
for indent_guide in indent_guides {
|
||||
let indent_accent_colors = cx.theme().accents().color_for_index(indent_guide.depth);
|
||||
let settings = indent_guide.settings;
|
||||
let settings = &indent_guide.settings;
|
||||
|
||||
// TODO fixed for now, expose them through themes later
|
||||
const INDENT_AWARE_ALPHA: f32 = 0.2;
|
||||
@@ -6008,7 +6000,7 @@ impl EditorElement {
|
||||
.unwrap_or_else(|| {
|
||||
matches!(
|
||||
ProjectSettings::get_global(cx).git.git_gutter,
|
||||
Some(GitGutterSetting::TrackedFiles)
|
||||
GitGutterSetting::TrackedFiles
|
||||
)
|
||||
});
|
||||
if show_git_gutter {
|
||||
@@ -7303,10 +7295,10 @@ impl EditorElement {
|
||||
|
||||
fn diff_hunk_hollow(status: DiffHunkStatus, cx: &mut App) -> bool {
|
||||
let unstaged = status.has_secondary_hunk();
|
||||
let unstaged_hollow = ProjectSettings::get_global(cx)
|
||||
.git
|
||||
.hunk_style
|
||||
.is_some_and(|style| matches!(style, GitHunkStyleSetting::UnstagedHollow));
|
||||
let unstaged_hollow = matches!(
|
||||
ProjectSettings::get_global(cx).git.hunk_style,
|
||||
GitHunkStyleSetting::UnstagedHollow
|
||||
);
|
||||
|
||||
unstaged == unstaged_hollow
|
||||
}
|
||||
@@ -8843,13 +8835,9 @@ impl Element for EditorElement {
|
||||
})
|
||||
.flatten()?;
|
||||
let mut element = render_inline_blame_entry(blame_entry, style, cx)?;
|
||||
let inline_blame_padding = ProjectSettings::get_global(cx)
|
||||
.git
|
||||
.inline_blame
|
||||
.unwrap_or_default()
|
||||
.padding
|
||||
as f32
|
||||
* em_advance;
|
||||
let inline_blame_padding =
|
||||
ProjectSettings::get_global(cx).git.inline_blame.padding as f32
|
||||
* em_advance;
|
||||
Some(
|
||||
element
|
||||
.layout_as_root(AvailableSpace::min_size(), window, cx)
|
||||
|
||||
@@ -931,8 +931,8 @@ mod tests {
|
||||
use futures::StreamExt;
|
||||
use gpui::Modifiers;
|
||||
use indoc::indoc;
|
||||
use language::language_settings::InlayHintSettings;
|
||||
use lsp::request::{GotoDefinition, GotoTypeDefinition};
|
||||
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,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1004,8 +1004,8 @@ mod tests {
|
||||
use collections::BTreeSet;
|
||||
use gpui::App;
|
||||
use indoc::indoc;
|
||||
use language::language_settings::InlayHintSettings;
|
||||
use markdown::parser::MarkdownEvent;
|
||||
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,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -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 language::language_settings::InlayHintSettings;
|
||||
use smol::lock::Semaphore;
|
||||
use sum_tree::Bias;
|
||||
use text::{BufferId, ToOffset, ToPoint};
|
||||
@@ -1301,13 +1303,13 @@ pub mod tests {
|
||||
use futures::StreamExt;
|
||||
use gpui::{AppContext as _, Context, SemanticVersion, TestAppContext, WindowHandle};
|
||||
use itertools::Itertools as _;
|
||||
use language::{Capability, FakeLspAdapter, language_settings::AllLanguageSettingsContent};
|
||||
use language::{Capability, FakeLspAdapter};
|
||||
use language::{Language, LanguageConfig, LanguageMatcher};
|
||||
use lsp::FakeLanguageServer;
|
||||
use parking_lot::Mutex;
|
||||
use project::{FakeFs, Project};
|
||||
use serde_json::json;
|
||||
use settings::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,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -328,7 +328,7 @@ pub(crate) fn refresh_enabled_in_any_buffer(
|
||||
snapshot.file(),
|
||||
cx,
|
||||
);
|
||||
if language_settings.jsx_tag_auto_close.enabled {
|
||||
if language_settings.jsx_tag_auto_close {
|
||||
found_enabled = true;
|
||||
}
|
||||
}
|
||||
@@ -406,7 +406,7 @@ pub(crate) fn handle_from(
|
||||
};
|
||||
|
||||
let language_settings = snapshot.settings_at(edit.new.end, cx);
|
||||
if !language_settings.jsx_tag_auto_close.enabled {
|
||||
if !language_settings.jsx_tag_auto_close {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -620,14 +620,17 @@ mod jsx_tag_autoclose_tests {
|
||||
|
||||
use super::*;
|
||||
use gpui::{AppContext as _, TestAppContext};
|
||||
use language::language_settings::JsxTagAutoCloseSettings;
|
||||
use languages::language;
|
||||
use multi_buffer::ExcerptRange;
|
||||
use text::Selection;
|
||||
|
||||
async fn test_setup(cx: &mut TestAppContext) -> EditorTestContext {
|
||||
init_test(cx, |settings| {
|
||||
settings.defaults.jsx_tag_auto_close = Some(JsxTagAutoCloseSettings { enabled: true });
|
||||
settings
|
||||
.defaults
|
||||
.jsx_tag_auto_close
|
||||
.get_or_insert_default()
|
||||
.enabled = Some(true);
|
||||
});
|
||||
|
||||
let mut cx = EditorTestContext::new(cx).await;
|
||||
@@ -789,7 +792,11 @@ mod jsx_tag_autoclose_tests {
|
||||
#[gpui::test]
|
||||
async fn test_multibuffer(cx: &mut TestAppContext) {
|
||||
init_test(cx, |settings| {
|
||||
settings.defaults.jsx_tag_auto_close = Some(JsxTagAutoCloseSettings { enabled: true });
|
||||
settings
|
||||
.defaults
|
||||
.jsx_tag_auto_close
|
||||
.get_or_insert_default()
|
||||
.enabled = Some(true);
|
||||
});
|
||||
|
||||
let buffer_a = cx.new(|cx| {
|
||||
|
||||
Reference in New Issue
Block a user