Make line a private property

pull/1872/head
Blaž Hrastnik 3 years ago
parent 96a4eb8483
commit 92bb312f0f
No known key found for this signature in database
GPG Key ID: 1238B9C4AD889640

@ -339,7 +339,7 @@ impl<T> Picker<T> {
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<T: 'static> Component for Picker<T> {
let (_score, highlights) = self
.matcher
.fuzzy_indices(&formatted, &self.prompt.line)
.fuzzy_indices(&formatted, self.prompt.line())
.unwrap_or_default();
surface.set_string_truncated(

@ -19,7 +19,7 @@ pub type Completion = (RangeFrom<usize>, Cow<'static, str>);
pub struct Prompt {
prompt: Cow<'static, str>,
pub line: String,
line: String,
cursor: usize,
completion: Vec<Completion>,
selection: Option<usize>,
@ -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);
}

Loading…
Cancel
Save