on master help sign in
Make line a private property
commit92bb312f0fadc0cb60f51241a10d39783c020a3f authorBlaž Hrastnik <blaz@mxxn.io> dateWed 23 Mar 2022, 10:39 (5 years ago) parent96a4eb8
2 files changed+7−3
helix-term/src/ui/picker.rs+2−2 helix-term/src/ui/prompt.rs+5−1
helix-term/src/ui/picker.rs+2−2
@@ -339,7 +339,7 @@ impl<T> Picker<T> {
339339 pub fn score(&mut self) {
340340 let now = Instant::now();
341341
342− let pattern = &self.prompt.line;
342+ let pattern = self.prompt.line();
343343
344344 if pattern == &self.previous_pattern {
345345 return;
@@ -607,7 +607,7 @@ impl<T: 'static> Component for Picker<T> {
607607
608608 let (_score, highlights) = self
609609 .matcher
610− .fuzzy_indices(&formatted, &self.prompt.line)
610+ .fuzzy_indices(&formatted, self.prompt.line())
611611 .unwrap_or_default();
612612
613613 surface.set_string_truncated(
helix-term/src/ui/prompt.rs+5−1
@@ -19,7 +19,7 @@ pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
1919
2020pub struct Prompt {
2121 prompt: Cow<'static, str>,
22− pub line: String,
22+ line: String,
2323 cursor: usize,
2424 completion: Vec<Completion>,
2525 selection: Option<usize>,
@@ -77,6 +77,10 @@ impl Prompt {
7777 }
7878 }
7979
80+ pub fn line(&self) -> &String {
81+ &self.line
82+ }
83+
8084 pub fn recalculate_completion(&mut self, editor: &Editor) {
8185 self.completion = (self.completion_fn)(editor, &self.line);
8286 }