aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorMo2024-02-27 17:24:05 +0000
committerGitHub2024-02-27 17:24:05 +0000
commit00653c772e7df6f68071d1cb1c92bfe9ca4876f9 (patch)
treeab89132d7fc7d174216264bd367942e9589b2269 /helix-term/src/ui
parent26b3dc29be886c5a2ed1a5caaaf09eb730829c3e (diff)
Avoid cloning the whole paragraph content just for rendering (#9739)
* Avoid cloning the whole paragraph content just for rendering * Fix tests
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs3
-rw-r--r--helix-term/src/ui/info.rs3
-rw-r--r--helix-term/src/ui/lsp.rs4
-rw-r--r--helix-term/src/ui/markdown.rs2
-rw-r--r--helix-term/src/ui/text.rs2
5 files changed, 8 insertions, 6 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 15a7262a..dffaeea0 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -716,7 +716,8 @@ impl EditorView {
}
}
- let paragraph = Paragraph::new(lines)
+ let text = Text::from(lines);
+ let paragraph = Paragraph::new(&text)
.alignment(Alignment::Right)
.wrap(Wrap { trim: true });
let width = 100.min(viewport.width);
diff --git a/helix-term/src/ui/info.rs b/helix-term/src/ui/info.rs
index cc6b7483..651e5ca9 100644
--- a/helix-term/src/ui/info.rs
+++ b/helix-term/src/ui/info.rs
@@ -2,6 +2,7 @@ use crate::compositor::{Component, Context};
use helix_view::graphics::{Margin, Rect};
use helix_view::info::Info;
use tui::buffer::Buffer as Surface;
+use tui::text::Text;
use tui::widgets::{Block, Borders, Paragraph, Widget};
impl Component for Info {
@@ -31,7 +32,7 @@ impl Component for Info {
let inner = block.inner(area).inner(&margin);
block.render(area, surface);
- Paragraph::new(self.text.as_str())
+ Paragraph::new(&Text::from(self.text.as_str()))
.style(text_style)
.render(inner, surface);
}
diff --git a/helix-term/src/ui/lsp.rs b/helix-term/src/ui/lsp.rs
index 879f963e..a3698e38 100644
--- a/helix-term/src/ui/lsp.rs
+++ b/helix-term/src/ui/lsp.rs
@@ -77,7 +77,7 @@ impl Component for SignatureHelp {
let (_, sig_text_height) = crate::ui::text::required_size(&sig_text, area.width);
let sig_text_area = area.clip_top(1).with_height(sig_text_height);
let sig_text_area = sig_text_area.inner(&margin).intersection(surface.area);
- let sig_text_para = Paragraph::new(sig_text).wrap(Wrap { trim: false });
+ let sig_text_para = Paragraph::new(&sig_text).wrap(Wrap { trim: false });
sig_text_para.render(sig_text_area, surface);
if self.signature_doc.is_none() {
@@ -100,7 +100,7 @@ impl Component for SignatureHelp {
let sig_doc_area = area
.clip_top(sig_text_area.height + 2)
.clip_bottom(u16::from(cx.editor.popup_border()));
- let sig_doc_para = Paragraph::new(sig_doc)
+ let sig_doc_para = Paragraph::new(&sig_doc)
.wrap(Wrap { trim: false })
.scroll((cx.scroll.unwrap_or_default() as u16, 0));
sig_doc_para.render(sig_doc_area.inner(&margin), surface);
diff --git a/helix-term/src/ui/markdown.rs b/helix-term/src/ui/markdown.rs
index 749d5850..81499d03 100644
--- a/helix-term/src/ui/markdown.rs
+++ b/helix-term/src/ui/markdown.rs
@@ -346,7 +346,7 @@ impl Component for Markdown {
let text = self.parse(Some(&cx.editor.theme));
- let par = Paragraph::new(text)
+ let par = Paragraph::new(&text)
.wrap(Wrap { trim: false })
.scroll((cx.scroll.unwrap_or_default() as u16, 0));
diff --git a/helix-term/src/ui/text.rs b/helix-term/src/ui/text.rs
index a379536f..a9c99562 100644
--- a/helix-term/src/ui/text.rs
+++ b/helix-term/src/ui/text.rs
@@ -33,7 +33,7 @@ impl Component for Text {
fn render(&mut self, area: Rect, surface: &mut Surface, _cx: &mut Context) {
use tui::widgets::{Paragraph, Widget, Wrap};
- let par = Paragraph::new(self.contents.clone()).wrap(Wrap { trim: false });
+ let par = Paragraph::new(&self.contents).wrap(Wrap { trim: false });
// .scroll(x, y) offsets
par.render(area, surface);