Skip to content

Commit

Permalink
fix(commit): fixup fuzzy finder feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ttys3 committed Jan 18, 2021
1 parent ced3b98 commit 9aac63a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
**/*.rs.bk
/.idea
20 changes: 18 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "convco"
version = "0.3.3"
version = "0.3.4"
description = "Conventional commit tools"
keywords = ["conventional", "commit", "changelog", "semantic", "versioning"]
categories = ["development-tools::build-utils"]
Expand All @@ -27,6 +27,7 @@ url = "2.1.1"
dialoguer = "0.6.2"
thiserror = "1.0.22"
skim = "*"
console = "0.14.0"

[build-dependencies]
structopt = "0.3.16"
Expand Down
25 changes: 17 additions & 8 deletions src/cmd/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,16 @@ impl Dialog {
let item_reader = SkimItemReader::default();
let items = item_reader.of_bufread(Cursor::new(input));

// use dialoguer::theme::ColorfulTheme;
// let mut header : String = "type: ".to_owned();
// header.push_str(ColorfulTheme::default().active_item_prefix.to_string().as_str());
// .header(Some(header.as_str()))
let options = SkimOptionsBuilder::default()
.min_height(Some("10"))
.prompt(Some("? type () › "))
.height(Some("25%"))
.multi(false)
.reverse(true)
.build()
.unwrap();
// `run_with` would read and show items from the stream
Expand All @@ -179,15 +186,17 @@ impl Dialog {
.unwrap_or_else(|| Vec::new());

for item in selected_items.iter() {
// print!("{}{}", item.output(), "\n");
let _: String = dialoguer::Input::with_theme(theme)
.with_prompt("type")
.with_initial_text(item.output().to_string())
.allow_empty(true)
.interact()?;
return Ok(item.output().to_string());
let sel = item.output().to_string();

let term: &console::Term = &console::Term::stderr();
let mut buf = String::new();
let _ = theme.format_input_prompt_selection(&mut buf, "type", &sel);
term.write_line(buf.as_str())?;
term.clear_line()?;

return Ok(sel);
}
Ok("".to_string())
Ok(selected.to_string())
}

// Prompt all
Expand Down

0 comments on commit 9aac63a

Please sign in to comment.