summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2023-07-16 11:43:26 +0100
committerPhil Jones <philj56@gmail.com>2023-07-16 11:43:26 +0100
commit548de1f8c63d4a088400e724a37d483656a2c645 (patch)
treeb391f0b3567769baaefb5966ef6f8552f2b841f8 /src
parent6060daaee163918f97af4db09bba9a7f9272d6c1 (diff)
Fix --print-index when searching.
Diffstat (limited to 'src')
-rw-r--r--src/main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index f7dce5d..ee5c032 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1040,7 +1040,12 @@ static bool do_submit(struct tofi *tofi)
}
} else {
if (entry->mode == TOFI_MODE_PLAIN && tofi->print_index) {
- printf("%u\n", selection + 1);
+ for (size_t i = 0; i < entry->commands.count; i++) {
+ if (res == entry->commands.buf[i].string) {
+ printf("%u\n", i + 1);
+ break;
+ }
+ }
} else {
printf("%s\n", res);
}