Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typos using typos #30

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "MIT"
homepage = "https://github.com/kyoto7250/zhobo"
repository = "https://github.com/kyoto7250/zhobo"
readme = "README.md"
description = "A cross-platform TUI database viewer written in Rust. Personaly maintained gobang project"
description = "A cross-platform TUI database viewer written in Rust. Personally maintained gobang project"
exclude = ["resources/"]

[dependencies]
Expand Down
24 changes: 12 additions & 12 deletions src/components/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl CompletionComponent {
fn next(&mut self) {
let i = match self.state.selected() {
Some(i) => {
if i + 1 >= self.filterd_candidates().count() {
if i + 1 >= self.filtered_candidates().count() {
0
} else {
i + 1
Expand All @@ -63,7 +63,7 @@ impl CompletionComponent {
let i = match self.state.selected() {
Some(i) => {
if i == 0 {
self.filterd_candidates()
self.filtered_candidates()
.count()
.checked_sub(1)
.unwrap_or(0)
Expand All @@ -76,7 +76,7 @@ impl CompletionComponent {
self.state.select(Some(i));
}

fn filterd_candidates(&self) -> impl Iterator<Item = &String> {
fn filtered_candidates(&self) -> impl Iterator<Item = &String> {
self.candidates.iter().filter(move |c| {
(c.starts_with(self.word.to_lowercase().as_str())
|| c.starts_with(self.word.to_uppercase().as_str()))
Expand All @@ -85,7 +85,7 @@ impl CompletionComponent {
}

pub fn selected_candidate(&self) -> Option<String> {
self.filterd_candidates()
self.filtered_candidates()
.collect::<Vec<&String>>()
.get(self.state.selected()?)
.map(|c| c.to_string())
Expand All @@ -101,7 +101,7 @@ impl MovableComponent for CompletionComponent {
if !self.word.is_empty() {
let width = 30;
let candidates = self
.filterd_candidates()
.filtered_candidates()
.map(|c| ListItem::new(c.to_string()))
.collect::<Vec<ListItem>>();
if candidates.clone().is_empty() {
Expand Down Expand Up @@ -148,37 +148,37 @@ mod test {
use super::{CompletionComponent, KeyConfig};

#[test]
fn test_filterd_candidates_lowercase() {
fn test_filtered_candidates_lowercase() {
assert_eq!(
CompletionComponent::new(KeyConfig::default(), "an", false)
.filterd_candidates()
.filtered_candidates()
.collect::<Vec<&String>>(),
vec![&"AND".to_string()]
);
}

#[test]
fn test_filterd_candidates_uppercase() {
fn test_filtered_candidates_uppercase() {
assert_eq!(
CompletionComponent::new(KeyConfig::default(), "AN", false)
.filterd_candidates()
.filtered_candidates()
.collect::<Vec<&String>>(),
vec![&"AND".to_string()]
);
}

#[test]
fn test_filterd_candidates_multiple_candidates() {
fn test_filtered_candidates_multiple_candidates() {
assert_eq!(
CompletionComponent::new(KeyConfig::default(), "n", false)
.filterd_candidates()
.filtered_candidates()
.collect::<Vec<&String>>(),
vec![&"NOT".to_string(), &"NULL".to_string()]
);

assert_eq!(
CompletionComponent::new(KeyConfig::default(), "N", false)
.filterd_candidates()
.filtered_candidates()
.collect::<Vec<&String>>(),
vec![&"NOT".to_string(), &"NULL".to_string()]
);
Expand Down
14 changes: 7 additions & 7 deletions src/components/databases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub enum Focus {
pub struct DatabasesComponent {
tree: DatabaseTree,
filter: DatabaseFilterComponent,
filterd_tree: Option<DatabaseTree>,
filtered_tree: Option<DatabaseTree>,
scroll: VerticalScroll,
focus: Focus,
key_config: KeyConfig,
Expand All @@ -46,7 +46,7 @@ impl DatabasesComponent {
Self {
tree: DatabaseTree::default(),
filter: DatabaseFilterComponent::new(),
filterd_tree: None,
filtered_tree: None,
scroll: VerticalScroll::new(false, false),
focus: Focus::Tree,
key_config,
Expand All @@ -62,7 +62,7 @@ impl DatabasesComponent {
None => pool.get_databases().await?,
};
self.tree = DatabaseTree::new(databases.as_slice(), &BTreeSet::new())?;
self.filterd_tree = None;
self.filtered_tree = None;
self.filter.reset();
Ok(())
}
Expand All @@ -72,7 +72,7 @@ impl DatabasesComponent {
}

pub fn tree(&self) -> &DatabaseTree {
self.filterd_tree.as_ref().unwrap_or(&self.tree)
self.filtered_tree.as_ref().unwrap_or(&self.tree)
}

fn tree_item_to_span(
Expand Down Expand Up @@ -167,7 +167,7 @@ impl DatabasesComponent {
.draw(f, chunks[0], matches!(self.focus, Focus::Filter))?;

let tree_height = chunks[1].height as usize;
let tree = if let Some(tree) = self.filterd_tree.as_ref() {
let tree = if let Some(tree) = self.filtered_tree.as_ref() {
tree
} else {
&self.tree
Expand Down Expand Up @@ -228,7 +228,7 @@ impl Component for DatabasesComponent {
}

if matches!(self.focus, Focus::Filter) {
self.filterd_tree = if self.filter.input_str().is_empty() {
self.filtered_tree = if self.filter.input_str().is_empty() {
None
} else {
Some(self.tree.filter(self.filter.input_str()))
Expand All @@ -247,7 +247,7 @@ impl Component for DatabasesComponent {
}
key => {
if tree_nav(
if let Some(tree) = self.filterd_tree.as_mut() {
if let Some(tree) = self.filtered_tree.as_mut() {
tree
} else {
&mut self.tree
Expand Down
4 changes: 2 additions & 2 deletions src/ui/reflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub struct LineTruncator<'a, 'b> {
symbols: &'b mut dyn Iterator<Item = StyledGrapheme<'a>>,
max_line_width: u16,
current_line: Vec<StyledGrapheme<'a>>,
/// Record the offet to skip render
/// Record the offset to skip render
horizontal_offset: u16,
}

Expand Down Expand Up @@ -442,7 +442,7 @@ mod test {
assert_eq!(line_truncator, vec![" "]);
}

/// Tests an input starting with a letter, folowed by spaces - some of the behaviour is
/// Tests an input starting with a letter, followed by spaces - some of the behaviour is
/// incidental.
#[test]
fn line_composer_char_plus_lots_of_spaces() {
Expand Down
Loading