fix variable name

pull/88/head
Takayuki Maeda 3 years ago
parent 6e5f99b275
commit aeeb3de55b

@ -11,7 +11,9 @@ use tui::{
Frame,
};
const RESERVED_WORDS: &[&str] = &["IN", "AND", "OR", "NOT", "NULL", "IS"];
const RESERVED_WORDS: &[&str] = &[
"IN", "AND", "OR", "NOT", "NULL", "IS",
];
pub struct CompletionComponent {
key_config: KeyConfig,
@ -95,15 +97,14 @@ impl MovableComponent for CompletionComponent {
) -> Result<()> {
if !self.word.is_empty() {
let width = 30;
let height = 5;
let candidates = self
.filterd_candidates()
.map(|c| ListItem::new(c.to_string()).style(Style::default()))
.map(|c| ListItem::new(c.to_string()))
.collect::<Vec<ListItem>>();
if candidates.is_empty() {
if candidates.clone().is_empty() {
return Ok(());
}
let candidates = List::new(candidates)
let candidate_list = List::new(candidates.clone())
.block(Block::default().borders(Borders::ALL))
.highlight_style(Style::default().bg(Color::Blue))
.style(Style::default());
@ -112,10 +113,10 @@ impl MovableComponent for CompletionComponent {
area.x + x,
area.y + y + 2,
width.min(f.size().width),
height.min(f.size().height),
candidates.len().min(5) as u16 + 2,
);
f.render_widget(Clear, area);
f.render_stateful_widget(candidates, area, &mut self.state);
f.render_stateful_widget(candidate_list, area, &mut self.state);
}
Ok(())
}

@ -163,10 +163,11 @@ impl DrawableComponent for TableFilterComponent {
(self
.table
.as_ref()
.map_or(String::new(), |table| table.name.to_string())
.width() as u16
+ 2)
.saturating_add(self.input_cursor_position),
.map_or(String::new(), |table| {
format!("{} ", table.name.to_string())
})
.width() as u16)
.saturating_add(self.input_cursor_position),
0,
)?;
};
@ -196,7 +197,9 @@ impl Component for TableFilterComponent {
// apply comletion candidates
if key == self.key_config.enter {
self.complete()?;
if self.complete()?.is_consumed() {
return Ok(EventState::Consumed);
};
}
self.completion.selected_candidate();

Loading…
Cancel
Save