on master help sign in
Make line a private property
92bb312Blaž Hrastnik
helix-term/src/ui/picker.rs+2−2
@@ -339,7 +339,7 @@ impl<T> Picker<T> {
339 pub fn score(&mut self) {
339 pub fn score(&mut self) {
340 let now = Instant::now();
340 let now = Instant::now();
341
341
342− let pattern = &self.prompt.line;
342+ let pattern = self.prompt.line();
343
343
344 if pattern == &self.previous_pattern {
344 if pattern == &self.previous_pattern {
345 return;
345 return;
@@ -607,7 +607,7 @@ impl<T: 'static> Component for Picker<T> {
607
607
608 let (_score, highlights) = self
608 let (_score, highlights) = self
609 .matcher
609 .matcher
610− .fuzzy_indices(&formatted, &self.prompt.line)
610+ .fuzzy_indices(&formatted, self.prompt.line())
611 .unwrap_or_default();
611 .unwrap_or_default();
612
612
613 surface.set_string_truncated(
613 surface.set_string_truncated(
helix-term/src/ui/prompt.rs+5−1
@@ -19,7 +19,7 @@ pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
19
19
20pub struct Prompt {
20pub struct Prompt {
21 prompt: Cow<'static, str>,
21 prompt: Cow<'static, str>,
22− pub line: String,
22+ line: String,
23 cursor: usize,
23 cursor: usize,
24 completion: Vec<Completion>,
24 completion: Vec<Completion>,
25 selection: Option<usize>,
25 selection: Option<usize>,
@@ -77,6 +77,10 @@ impl Prompt {
77 }
77 }
78 }
78 }
79
79
80+ pub fn line(&self) -> &String {
81+ &self.line
82+ }
83+
80 pub fn recalculate_completion(&mut self, editor: &Editor) {
84 pub fn recalculate_completion(&mut self, editor: &Editor) {
81 self.completion = (self.completion_fn)(editor, &self.line);
85 self.completion = (self.completion_fn)(editor, &self.line);
82 }
86 }