buffer: Keep the shorter language setting names for the common operation (#43915)
cc https://github.com/zed-industries/zed/pull/43888#issuecomment-3597265087 Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -684,9 +684,8 @@ impl LocalBufferStore {
|
||||
cx: &mut Context<BufferStore>,
|
||||
) -> Task<Result<Entity<Buffer>>> {
|
||||
cx.spawn(async move |buffer_store, cx| {
|
||||
let buffer = cx.new(|cx| {
|
||||
Buffer::local("", cx).with_language_immediate(language::PLAIN_TEXT.clone(), cx)
|
||||
})?;
|
||||
let buffer =
|
||||
cx.new(|cx| Buffer::local("", cx).with_language(language::PLAIN_TEXT.clone(), cx))?;
|
||||
buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store.add_buffer(buffer.clone(), cx).log_err();
|
||||
if !project_searchable {
|
||||
@@ -1592,10 +1591,8 @@ impl BufferStore {
|
||||
cx: &mut Context<Self>,
|
||||
) -> Entity<Buffer> {
|
||||
let buffer = cx.new(|cx| {
|
||||
Buffer::local(text, cx).with_language_immediate(
|
||||
language.unwrap_or_else(|| language::PLAIN_TEXT.clone()),
|
||||
cx,
|
||||
)
|
||||
Buffer::local(text, cx)
|
||||
.with_language(language.unwrap_or_else(|| language::PLAIN_TEXT.clone()), cx)
|
||||
});
|
||||
|
||||
self.add_buffer(buffer.clone(), cx).log_err();
|
||||
|
||||
@@ -3885,7 +3885,7 @@ impl Repository {
|
||||
let git_commit_language =
|
||||
language_registry.language_for_name("Git Commit").await?;
|
||||
buffer.update(&mut cx, |buffer, cx| {
|
||||
buffer.set_language_immediate(Some(git_commit_language), cx);
|
||||
buffer.set_language(Some(git_commit_language), cx);
|
||||
})?;
|
||||
}
|
||||
this.update(&mut cx, |this, _| {
|
||||
@@ -3912,7 +3912,7 @@ impl Repository {
|
||||
if let Some(language_registry) = language_registry {
|
||||
let git_commit_language = language_registry.language_for_name("Git Commit").await?;
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
buffer.set_language_immediate(Some(git_commit_language), cx);
|
||||
buffer.set_language(Some(git_commit_language), cx);
|
||||
})?;
|
||||
}
|
||||
|
||||
|
||||
@@ -4289,8 +4289,9 @@ impl LspStore {
|
||||
for buffer in buffer_store.buffers() {
|
||||
if let Some(f) = File::from_dyn(buffer.read(cx).file()).cloned()
|
||||
{
|
||||
buffer
|
||||
.update(cx, |buffer, cx| buffer.set_language(None, cx));
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
buffer.set_language_async(None, cx)
|
||||
});
|
||||
if let Some(local) = this.as_local_mut() {
|
||||
local.reset_buffer(&buffer, &f, cx);
|
||||
|
||||
@@ -4413,7 +4414,7 @@ impl LspStore {
|
||||
.language()
|
||||
.is_none_or(|old_language| !Arc::ptr_eq(old_language, &new_language))
|
||||
{
|
||||
buffer.set_language(Some(new_language.clone()), cx);
|
||||
buffer.set_language_async(Some(new_language.clone()), cx);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user