Make language settings accessors take an arc dyn file
This commit is contained in:
parent
a2ab7c9eb9
commit
03a351fb26
10 changed files with 41 additions and 54 deletions
|
@ -1808,11 +1808,7 @@ impl BufferSnapshot {
|
|||
|
||||
pub fn language_indent_size_at<T: ToOffset>(&self, position: T, cx: &AppContext) -> IndentSize {
|
||||
let language_name = self.language_at(position).map(|language| language.name());
|
||||
let settings = language_settings(
|
||||
language_name.as_deref(),
|
||||
self.file().map(|f| f.as_ref()),
|
||||
cx,
|
||||
);
|
||||
let settings = language_settings(language_name.as_deref(), self.file(), cx);
|
||||
if settings.hard_tabs {
|
||||
IndentSize::tab()
|
||||
} else {
|
||||
|
@ -2139,7 +2135,7 @@ impl BufferSnapshot {
|
|||
let language = self.language_at(position);
|
||||
language_settings(
|
||||
language.map(|l| l.name()).as_deref(),
|
||||
self.file.as_ref().map(AsRef::as_ref),
|
||||
self.file.as_ref(),
|
||||
cx,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn init(cx: &mut AppContext) {
|
|||
|
||||
pub fn language_settings<'a>(
|
||||
language: Option<&str>,
|
||||
file: Option<&dyn File>,
|
||||
file: Option<&Arc<dyn File>>,
|
||||
cx: &'a AppContext,
|
||||
) -> &'a LanguageSettings {
|
||||
settings::get_local::<AllLanguageSettings>(
|
||||
|
@ -27,7 +27,7 @@ pub fn language_settings<'a>(
|
|||
}
|
||||
|
||||
pub fn all_language_settings<'a>(
|
||||
file: Option<&dyn File>,
|
||||
file: Option<&Arc<dyn File>>,
|
||||
cx: &'a AppContext,
|
||||
) -> &'a AllLanguageSettings {
|
||||
settings::get_local::<AllLanguageSettings>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue