Skip to content

Commit

Permalink
Merge pull request #258 from lotabout/ticket-225
Browse files Browse the repository at this point in the history
fix #225: disable score in filter output
  • Loading branch information
lotabout authored Jan 27, 2020
2 parents 067ec36 + 7c6211f commit c65925c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,17 @@ impl Skim {
while !reader_control.is_done() {
for item in reader_control.take().into_iter() {
if let Some(matched) = engine.match_item(item) {
println!("{}\t{}", -matched.rank.score, matched.item.get_output_text());
if options.print_score {
println!("{}\t{}", -matched.rank.score, matched.item.get_output_text());
} else {
println!("{}", matched.item.get_output_text());
}
match_count += 1;
}
}
}

if match_count == 0 {
return 1;
} else {
return 0;
}
return if match_count == 0 { 1 } else { 0 };
}

// 10 -> TermHeight::Fixed(10)
Expand Down
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Usage: sk [options]
--print0 Print output delimited by ASCII NUL(\\0) characters
--print-query Print query as the first line
--print-cmd Print command query as the first line (after --print-query)
--print-score Print matching score in filter output (with --filter)
-f, --filter=STR Filter mode. Do not start interactive finder.
Environment variables
Expand Down Expand Up @@ -197,6 +198,7 @@ fn real_main() -> i32 {
.arg(Arg::with_name("history-size").long("history-size").multiple(true).takes_value(true).default_value("500"))
.arg(Arg::with_name("print-query").long("print-query").multiple(true))
.arg(Arg::with_name("print-cmd").long("print-cmd").multiple(true))
.arg(Arg::with_name("print-score").long("print-score").multiple(true))
.arg(Arg::with_name("read0").long("read0").multiple(true))
.arg(Arg::with_name("print0").long("print0").multiple(true))
.arg(Arg::with_name("sync").long("sync").multiple(true))
Expand Down Expand Up @@ -291,6 +293,7 @@ fn parse_options<'a>(options: &'a ArgMatches) -> SkimOptions<'a> {
.print0(options.is_present("print0"))
.print_query(options.is_present("print-query"))
.print_cmd(options.is_present("print-cmd"))
.print_score(options.is_present("print-score"))
.no_hscroll(options.is_present("no-hscroll"))
.tabstop(options.values_of("tabstop").and_then(|vals| vals.last()))
.tiebreak(options.values_of("tiebreak").map(|x| x.collect::<Vec<_>>().join(",")))
Expand Down
2 changes: 2 additions & 0 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct SkimOptions<'a> {
pub tabstop: Option<&'a str>,
pub print_query: bool,
pub print_cmd: bool,
pub print_score: bool,
pub no_hscroll: bool,
pub inline_info: bool,
pub header: Option<&'a str>,
Expand Down Expand Up @@ -79,6 +80,7 @@ impl<'a> Default for SkimOptions<'a> {
tabstop: None,
print_query: false,
print_cmd: false,
print_score: false,
no_hscroll: false,
inline_info: false,
header: None,
Expand Down

0 comments on commit c65925c

Please # to comment.