aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/editor.rs34
-rw-r--r--helix-term/src/ui/mod.rs2
-rw-r--r--helix-term/src/ui/picker.rs2
-rw-r--r--helix-term/src/ui/prompt.rs4
4 files changed, 21 insertions, 21 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 725d58b3..e661c5a0 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -155,21 +155,21 @@ impl EditorView {
syntax
.highlight_iter(text.slice(..), Some(range), None, |language| {
loader
- .language_config_for_scope(&format!("source.{}", language))
- .and_then(|language_config| {
- let config = language_config.highlight_config(scopes)?;
- let config_ref = config.as_ref();
- // SAFETY: the referenced `HighlightConfiguration` behind
- // the `Arc` is guaranteed to remain valid throughout the
- // duration of the highlight.
- let config_ref = unsafe {
- std::mem::transmute::<
- _,
- &'static syntax::HighlightConfiguration,
- >(config_ref)
- };
- Some(config_ref)
- })
+ .language_config_for_scope(&format!("source.{}", language))
+ .and_then(|language_config| {
+ let config = language_config.highlight_config(scopes)?;
+ let config_ref = config.as_ref();
+ // SAFETY: the referenced `HighlightConfiguration` behind
+ // the `Arc` is guaranteed to remain valid throughout the
+ // duration of the highlight.
+ let config_ref = unsafe {
+ std::mem::transmute::<
+ _,
+ &'static syntax::HighlightConfiguration,
+ >(config_ref)
+ };
+ Some(config_ref)
+ })
})
.map(|event| event.unwrap())
.collect() // TODO: we collect here to avoid holding the lock, fix later
@@ -435,7 +435,7 @@ impl EditorView {
let current_line = doc
.text()
- .char_to_line(doc.selection(view.id).primary().anchor);
+ .char_to_line(doc.selection(view.id).primary().cursor(text));
// it's used inside an iterator so the collect isn't needless:
// https://github.com/rust-lang/rust-clippy/issues/6164
@@ -749,7 +749,7 @@ impl EditorView {
_ => noop,
};
Prompt::new(
- format!("{}: ", name),
+ format!("{}: ", name).into(),
None,
completer,
move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index f3f8670e..0a1e24b5 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -27,7 +27,7 @@ use std::path::PathBuf;
pub fn regex_prompt(
cx: &mut crate::commands::Context,
- prompt: String,
+ prompt: std::borrow::Cow<'static, str>,
fun: impl Fn(&mut View, &mut Document, &mut Registers, Regex) + 'static,
) -> Prompt {
let (view, doc) = current!(cx.editor);
diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs
index ef2c434c..06e424ea 100644
--- a/helix-term/src/ui/picker.rs
+++ b/helix-term/src/ui/picker.rs
@@ -202,7 +202,7 @@ impl<T> Picker<T> {
callback_fn: impl Fn(&mut Editor, &T, Action) + 'static,
) -> Self {
let prompt = Prompt::new(
- "".to_string(),
+ "".into(),
None,
|_pattern: &str| Vec::new(),
|_editor: &mut Context, _pattern: &str, _event: PromptEvent| {
diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs
index 7197adea..1d512ad2 100644
--- a/helix-term/src/ui/prompt.rs
+++ b/helix-term/src/ui/prompt.rs
@@ -15,7 +15,7 @@ use helix_view::{
pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
pub struct Prompt {
- prompt: String,
+ prompt: Cow<'static, str>,
pub line: String,
cursor: usize,
completion: Vec<Completion>,
@@ -55,7 +55,7 @@ pub enum Movement {
impl Prompt {
pub fn new(
- prompt: String,
+ prompt: Cow<'static, str>,
history_register: Option<char>,
mut completion_fn: impl FnMut(&str) -> Vec<Completion> + 'static,
callback_fn: impl FnMut(&mut Context, &str, PromptEvent) + 'static,