Make line a private property

This commit is contained in:
Blaž Hrastnik 2022-03-23 10:39:24 +09:00
parent 96a4eb8483
commit 92bb312f0f
No known key found for this signature in database
GPG key ID: 1238B9C4AD889640
2 changed files with 7 additions and 3 deletions

View file

@ -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(

View file

@ -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);
}