fix clippy warnings

pull/30/head
Takayuki Maeda 3 years ago
parent 13d343af56
commit 53524faf06

@ -301,20 +301,18 @@ impl App {
return Ok(EventState::Consumed);
}
}
Focus::DabataseList => match key {
Key::Right if self.databases.tree_focused() => {
Focus::DabataseList => {
if matches!(key, Key::Right) && self.databases.tree_focused() {
self.focus = Focus::Table;
return Ok(EventState::Consumed);
}
_ => (),
},
Focus::Table => match key {
Key::Left => {
}
Focus::Table => {
if let Key::Left = key {
self.focus = Focus::DabataseList;
return Ok(EventState::Consumed);
}
_ => (),
},
}
}
Ok(EventState::NotConsumed)
}

@ -91,8 +91,8 @@ impl Component for RecordTableComponent {
self.focus = Focus::Filter;
return Ok(EventState::Consumed);
}
key if matches!(self.focus, Focus::Filter) => return Ok(self.filter.event(key)?),
key if matches!(self.focus, Focus::Table) => return Ok(self.table.event(key)?),
key if matches!(self.focus, Focus::Filter) => return self.filter.event(key),
key if matches!(self.focus, Focus::Table) => return self.table.event(key),
_ => (),
}
Ok(EventState::NotConsumed)

@ -52,9 +52,9 @@ impl TableComponent {
state.select(Some(0))
}
Self {
rows,
headers,
state,
headers,
rows,
..Self::default()
}
}
@ -227,7 +227,6 @@ impl TableComponent {
row[x.min(self.selected_left_column_index)
..x.max(self.selected_left_column_index) + 1]
.join(",")
.to_string()
})
.collect::<Vec<String>>()
.join("\n"),
@ -299,7 +298,7 @@ impl TableComponent {
self.column_page_start.set(self.selected_column_index());
}
let right_column_index = self.selected_column_index().clone();
let right_column_index = self.selected_column_index();
let mut column_index = self.selected_column_index();
let number_clomn_width = (self.rows.len() + 1).to_string().width() as u16;
let mut widths = vec![];
@ -324,7 +323,7 @@ impl TableComponent {
)
.clamp(&3, &20)
});
if widths.iter().map(|(_, width)| width).sum::<usize>() + length + widths.len() * 1
if widths.iter().map(|(_, width)| width).sum::<usize>() + length + widths.len()
> area_width.saturating_sub(number_clomn_width) as usize
{
column_index += 1;
@ -340,7 +339,7 @@ impl TableComponent {
widths.reverse();
let selected_column_index = widths.len().saturating_sub(1);
let mut column_index = right_column_index + 1;
while widths.iter().map(|(_, width)| width).sum::<usize>() + widths.len() * 1
while widths.iter().map(|(_, width)| width).sum::<usize>() + widths.len()
<= area_width.saturating_sub(number_clomn_width) as usize
{
let length = self

@ -89,12 +89,10 @@ impl Component for TableFilterComponent {
return Ok(EventState::Consumed);
}
Key::Delete | Key::Backspace => {
if input_str.width() > 0 {
if !self.input.is_empty() && self.input_idx > 0 {
let last_c = self.input.remove(self.input_idx - 1);
self.input_idx -= 1;
self.input_cursor_position -= compute_character_width(last_c);
}
if input_str.width() > 0 && !self.input.is_empty() && self.input_idx > 0 {
let last_c = self.input.remove(self.input_idx - 1);
self.input_idx -= 1;
self.input_cursor_position -= compute_character_width(last_c);
}
return Ok(EventState::Consumed);
}

@ -13,15 +13,15 @@ pub trait Pool {
async fn get_tables(&self, database: String) -> anyhow::Result<Vec<Table>>;
async fn get_records(
&self,
database: &String,
table: &String,
database: &str,
table: &str,
page: u16,
filter: Option<String>,
) -> anyhow::Result<(Vec<String>, Vec<Vec<String>>)>;
async fn get_columns(
&self,
database: &String,
table: &String,
database: &str,
table: &str,
) -> anyhow::Result<(Vec<String>, Vec<Vec<String>>)>;
async fn close(&self);
}
@ -67,8 +67,8 @@ impl Pool for MySqlPool {
async fn get_records(
&self,
database: &String,
table: &String,
database: &str,
table: &str,
page: u16,
filter: Option<String>,
) -> anyhow::Result<(Vec<String>, Vec<Vec<String>>)> {
@ -111,8 +111,8 @@ impl Pool for MySqlPool {
async fn get_columns(
&self,
database: &String,
table: &String,
database: &str,
table: &str,
) -> anyhow::Result<(Vec<String>, Vec<Vec<String>>)> {
let query = format!("SHOW FULL COLUMNS FROM `{}`.`{}`", database, table);
let mut rows = sqlx::query(query.as_str()).fetch(&self.pool);

Loading…
Cancel
Save