Merge pull request #1154 from keepassxreboot/fix/autocomplete_max_name_length

Trim entry name in Autocomplete Menu when needed
This commit is contained in:
Sami Vänttinen 2020-12-20 15:43:22 +02:00 committed by GitHub
commit 7f628f53db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -1,5 +1,7 @@
'use strict';
const MAX_AUTOCOMPLETE_NAME_LEN = 50;
const kpxcAutocomplete = {};
kpxcAutocomplete.autoSubmit = false;
kpxcAutocomplete.elements = [];

View file

@ -1140,9 +1140,12 @@ kpxc.initLoginPopup = function() {
}
const getLoginText = function(credential, withGroup) {
const name = credential.name.length < MAX_AUTOCOMPLETE_NAME_LEN
? credential.name
: credential.name.substr(0, MAX_AUTOCOMPLETE_NAME_LEN) + '…';
const group = (withGroup && credential.group) ? `[${credential.group}] ` : '';
const visibleLogin = (credential.login.length > 0) ? credential.login : tr('credentialsNoUsername');
const text = `${group}${credential.name} (${visibleLogin})`;
const text = `${group}${name} (${visibleLogin})`;
if (credential.expired && credential.expired === 'true') {
return `${text} [${tr('credentialExpired')}]`;