question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve select prompt (with search)

See original GitHub issue

Hi,

I’ve finally found the time to experiment with the select prompt with auto-complete and here is the feedback.

Ctrl-C keeps the console dirty

When someone ctrl-c’s instead of validating the prompt, the options stay displayed and clutter the terminal.

Selection_057

If it is possible, it’d be nice to catch the SIGINT signal and cleanup.

Less-strict search method

The current search method shows a few improvement opportunities IMO:

  • it currently only matches the values. This has the drawback that when searching in options with names, the values are not displayed and may not share a single character in common with the values (ex: {name: 'Blue', value: '#0000AA'}).
  • is searches at the beginning of the value and not everywhere (meaning new does not match Add a new feature).

I think it would be better to search on names when provided and to use a case-insensitive-match-anywhere search method.

Something like:

function searchMethod (allOptions, searchText) {
  return allOptions
    .filter(option => !option.disabled)
    .reduce(
      (seed, option) => {
        const lowerCaseName = option.name.toLocaleLowerCase();
        const lowerCaseValue = option.value.toLocaleLowerCase();
        const lowerCaseSearch = searchText.toLocaleLowerCase();
        
        const matchesPerfectly = lowerCaseName === lowerCaseSearch || lowerCaseValue === lowerCaseSearch;
        if (matchesPerfectly) { // Put perfect match first!
          return [ option, ...seed ];
        }
        
        const matches = lowerCaseName.includes(lowerCaseSearch) || lowerCaseValue.includes(lowerCaseSearch);
        return matches ? [ ...seed, option ] : seed;
      },
      [],
    );
}

WDYT?

I can help with implementation if you want to take these, and can split issues etc… 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
quilicicfcommented, Feb 4, 2021

Noice! I’ve tested it and it works on commit a6b5d36 thanks 😃

0reactions
c4sparcommented, Feb 3, 2021

@quilicicf the issue with the stdout should be fixed now. i realized, there was realy no logic for clearing the stdout. i think, it was just my zsh and docker which cleared the stdout automatically. With the bash shell i got the same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resize Select and Search or Value prompts to ... - IBM
Multi-select Search&Select prompts have two fields, both of which must be widened. Steps 1 and 2 will widen the right-side prompt. Add the ......
Read more >
Tips and Tricks: Add a Select and Search Prompt to a Report ...
One of the missing features with Data Modules is the ability to use a Select & Search (search and select?) prompt in Cognos...
Read more >
Advanced Select and Search Prompts - CognosPaul
So I was asked to find a way to shrink it down. SnS hogging the page. Obviously the solution was to everything but...
Read more >
Is there any way to increase the size of select & search prompt
Hi All, I have a select & search prompt in my prompt page. The values loaded in this prompt are of charecters with...
Read more >
increasing the width of a search and select prompt
I managed to increase the width of the window where the search results are displayed using javascript. Does anyone know how to.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found