From 8804c65df90a08fd44545ffa70df30ae793ce431 Mon Sep 17 00:00:00 2001 From: Andrew Kaiser Date: Fri, 28 Sep 2018 20:32:26 -0400 Subject: [PATCH] fix dmenu selected accountName index not matching list of accounts --- package.json | 2 +- src/index.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 58bbd92..a17584e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitwarden-dmenu", - "version": "1.2.3", + "version": "1.2.4", "description": "dmenu for bitwarden password manager.", "keywords": [ "bitwarden", diff --git a/src/index.js b/src/index.js index a67539a..cb8a539 100644 --- a/src/index.js +++ b/src/index.js @@ -56,13 +56,14 @@ const getAccounts = ({ session }) => { // choose one account with dmenu const chooseAccount = async ({ list }) => { const LOGIN_TYPE = 1 - const accountNames = list - .filter(a => a.type === LOGIN_TYPE) - .map(a => `${a.name}: ${a.login.username}`) + const loginList = list.filter(a => a.type === LOGIN_TYPE) + + const accountNames = loginList.map(a => `${a.name}: ${a.login.username}`) // -i allows case insensitive matching const selected = await dmenuRun('-i')(accountNames.join('\n')) const index = accountNames.indexOf(selected) - const selectedAccount = list[index] + // accountNames indexes match loginList indexes + const selectedAccount = loginList[index] console.debug('selected account:\n', obfuscate(selectedAccount)) return selectedAccount }