From 92bb312f0fadc0cb60f51241a10d39783c020a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Wed, 23 Mar 2022 10:39:24 +0900 Subject: [PATCH] Make line a private property --- helix-term/src/ui/picker.rs | 4 ++-- helix-term/src/ui/prompt.rs | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index e54985833..a1a22c71b 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -339,7 +339,7 @@ impl Picker { pub fn score(&mut self) { let now = Instant::now(); - let pattern = &self.prompt.line; + let pattern = self.prompt.line(); if pattern == &self.previous_pattern { return; @@ -607,7 +607,7 @@ impl Component for Picker { let (_score, highlights) = self .matcher - .fuzzy_indices(&formatted, &self.prompt.line) + .fuzzy_indices(&formatted, self.prompt.line()) .unwrap_or_default(); surface.set_string_truncated( diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index c3402f023..4daa33e54 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -19,7 +19,7 @@ pub type Completion = (RangeFrom, Cow<'static, str>); pub struct Prompt { prompt: Cow<'static, str>, - pub line: String, + line: String, cursor: usize, completion: Vec, selection: Option, @@ -77,6 +77,10 @@ impl Prompt { } } + pub fn line(&self) -> &String { + &self.line + } + pub fn recalculate_completion(&mut self, editor: &Editor) { self.completion = (self.completion_fn)(editor, &self.line); }