repl: Make output buffer be readonly, never dirty (#17121)
This commit is contained in:
parent
6646b15f29
commit
02cd5128c7
5 changed files with 37 additions and 11 deletions
|
@ -35,7 +35,7 @@
|
|||
|
||||
use std::time::Duration;
|
||||
|
||||
use editor::Editor;
|
||||
use editor::{Editor, MultiBuffer};
|
||||
use gpui::{
|
||||
percentage, Animation, AnimationExt, AnyElement, ClipboardItem, Model, Render, Transformation,
|
||||
View, WeakView,
|
||||
|
@ -176,7 +176,18 @@ impl Output {
|
|||
if let Some(buffer_content) = buffer_content.as_ref() {
|
||||
let buffer = buffer_content.clone();
|
||||
let editor = Box::new(cx.new_view(|cx| {
|
||||
Editor::for_buffer(buffer.clone(), None, cx)
|
||||
let multibuffer = cx.new_model(|cx| {
|
||||
let mut multi_buffer =
|
||||
MultiBuffer::singleton(buffer.clone(), cx);
|
||||
|
||||
multi_buffer.set_title("REPL Output".to_string(), cx);
|
||||
multi_buffer
|
||||
});
|
||||
|
||||
let editor =
|
||||
Editor::for_multibuffer(multibuffer, None, false, cx);
|
||||
|
||||
editor
|
||||
}));
|
||||
workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
|
@ -195,6 +206,7 @@ impl Output {
|
|||
|
||||
fn render(
|
||||
&self,
|
||||
|
||||
workspace: WeakView<Workspace>,
|
||||
cx: &mut ViewContext<ExecutionView>,
|
||||
) -> impl IntoElement {
|
||||
|
|
|
@ -58,7 +58,10 @@ impl OutputContent for MarkdownView {
|
|||
fn buffer_content(&mut self, cx: &mut WindowContext) -> Option<Model<Buffer>> {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
// todo!(): Bring in the language registry so we can set the language to markdown
|
||||
Buffer::local(self.raw_text.clone(), cx).with_language(language::PLAIN_TEXT.clone(), cx)
|
||||
let mut buffer = Buffer::local(self.raw_text.clone(), cx)
|
||||
.with_language(language::PLAIN_TEXT.clone(), cx);
|
||||
buffer.set_capability(language::Capability::ReadOnly, cx);
|
||||
buffer
|
||||
});
|
||||
Some(buffer)
|
||||
}
|
||||
|
|
|
@ -328,8 +328,12 @@ impl OutputContent for TerminalOutput {
|
|||
}
|
||||
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::local(self.full_text(), cx).with_language(language::PLAIN_TEXT.clone(), cx)
|
||||
let mut buffer =
|
||||
Buffer::local(self.full_text(), cx).with_language(language::PLAIN_TEXT.clone(), cx);
|
||||
buffer.set_capability(language::Capability::ReadOnly, cx);
|
||||
buffer
|
||||
});
|
||||
|
||||
self.full_buffer = Some(buffer.clone());
|
||||
Some(buffer)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue