Skip to content

Commit 183d72b

Browse files
Improve expanded macro presentation
Make the editor non-dirty and readonly
1 parent 5ae93ce commit 183d72b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

crates/editor/src/rust_analyzer_ext.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{fs, path::Path};
22

33
use anyhow::Context as _;
44
use gpui::{App, AppContext as _, Context, Entity, Window};
5-
use language::Language;
5+
use language::{Capability, Language};
66
use multi_buffer::MultiBuffer;
77
use project::lsp_ext_command::ExpandMacro;
88
use text::ToPointUtf16;
@@ -80,14 +80,18 @@ pub fn expand_macro_recursively(
8080
.await?;
8181
workspace.update_in(&mut cx, |workspace, window, cx| {
8282
buffer.update(cx, |buffer, cx| {
83-
buffer.edit([(0..0, macro_expansion.expansion)], None, cx);
84-
buffer.set_language(Some(rust_language), cx)
83+
buffer.set_text(macro_expansion.expansion, cx);
84+
buffer.set_language(Some(rust_language), cx);
85+
buffer.set_capability(Capability::ReadOnly, cx);
8586
});
8687
let multibuffer =
8788
cx.new(|cx| MultiBuffer::singleton(buffer, cx).with_title(macro_expansion.name));
8889
workspace.add_item_to_active_pane(
8990
Box::new(cx.new(|cx| {
90-
Editor::for_multibuffer(multibuffer, Some(project), true, window, cx)
91+
let mut editor =
92+
Editor::for_multibuffer(multibuffer, Some(project), true, window, cx);
93+
editor.set_read_only(true);
94+
editor
9195
})),
9296
None,
9397
true,

0 commit comments

Comments
 (0)