Skip to content

Commit

Permalink
Suggest command as first match at auto completion (#292)
Browse files Browse the repository at this point in the history
When typing the full name of a command make the command itself the first
suggestion in the auto completion.

Additionally always suggest attributes but below command suggestions.
  • Loading branch information
kofrezo committed Feb 20, 2023
1 parent 3d6ce09 commit 1b65f6f
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ $(document).ready(function() {
Object.keys(commands).sort().forEach(function(name) {
if (
command === '' ||
(name !== command && name.startsWith(command))
name.startsWith(command)
) {
let desc = $(`#cmd-${name} td:nth-of-type(3)`).text();
desc = desc === undefined ? '' : desc;
Expand All @@ -71,16 +71,14 @@ $(document).ready(function() {
}
});

if (choices.length === 0) {
servershell.attributes.map(item => item.attribute_id).sort().forEach(function(attribute) {
if (attribute !== command && attribute.startsWith(command)) {
choices.push({
'label': `${attribute}`,
'value': `${attribute} `,
});
}
});
}
servershell.attributes.map(item => item.attribute_id).sort().forEach(function(attribute) {
if (attribute !== command && attribute.startsWith(command)) {
choices.push({
'label': `${attribute}: Display attribute`,
'value': `${attribute} `,
});
}
});
}
else {
// Auto complete for certain commands and its values
Expand Down

0 comments on commit 1b65f6f

Please sign in to comment.