[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocompletehandler pasting full command instead of completing the written command #49

Closed
skast96 opened this issue Mar 8, 2022 · 2 comments

Comments

@skast96
Copy link
skast96 commented Mar 8, 2022

Hello

as the title says the autocomplete is pasting the whole command into the input instead of completing it.
Example:

My commands:

defaultCommands: [
      "print test",
      "print pip list",
    ],

My Autocomplete:

 this.localEcho.addAutocompleteHandler((index, tokens) => {
        if (index !== 0) {
          let possible = this.defaultCommands;
          for (let command of tokens) {
            possible = possible.filter(element => element.includes(command));
          }
          return possible;
        }
        return this.defaultCommands;
      });

The text in the input:

print p **TAB TAB**

Results in:

print p print pip list

Is there a nice and simple solution for that?

@skast96
Copy link
Author
skast96 commented Mar 18, 2022

Fixed it on my own just look at my fork if you need that behavior too.

@skast96 skast96 closed this as completed Mar 18, 2022
@benelliott
Copy link
benelliott commented Apr 26, 2024

The above mentioned fork seems to have been deleted. For anyone else who had this problem, my solution was to change the following around line 584 of LocalEchoController.js:

            } else if (candidates.length <= this.maxAutocompleteEntries) {

              // search for a shared fragement
              const sameFragment = getSharedFragment(inputFragment, candidates);
              
              // if there's a shared fragement between the candidates
              // print complete the shared fragment
              if (sameFragment) {
                const lastToken = getLastToken(inputFragment);
                this.handleCursorInsert(
                  sameFragment.substr(lastToken.length)
                );
              }
          to
            } else if (candidates.length <= this.maxAutocompleteEntries) {
              const lastInputToken = getLastToken(inputFragment);
              // search for a shared fragement
              const sameFragment = getSharedFragment(lastInputToken, candidates);

              // if there's a shared fragement between the candidates
              // print complete the shared fragment
              if (sameFragment) {
                this.handleCursorInsert(
                  sameFragment.substr(lastInputToken.length)
                );
              }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants