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

Change of 'word' breaks 'before' param #10

Open
jblandry opened this issue May 6, 2017 · 11 comments
Open

Change of 'word' breaks 'before' param #10

jblandry opened this issue May 6, 2017 · 11 comments

Comments

@jblandry
Copy link
Contributor

jblandry commented May 6, 2017

Hi,
I tried to switch to 0.4.0 and the change of fetching method for word (b74b232#diff-564d24cceffda49c18bf427e92b8baa3R23) makes the parameter before undefined when an incomplete word is tabbed.

Ex:

lorem <tab><tab>      -> a1 b1       👍 
lorem a<tab>          -> a1          👍
lorem a1 <tab><tab>   -> a2 b2 c2    👍
lorem a1 a<tab>       -> nothing     👎 

My script that goes like this

const autocomplete = {
  'a1': {
    'a2': {
      'a3': {
        'a4': {},
        'b4': {}
      },
      'b3': {}
    },
    'b2': {},
    'c2': {}
  },
  'b1': {
    'a2': {},
    'b2': {
      'a3': {
        'a4': {},
        'b4': {}
      },
      'b3': {}
    },
    'c2': {}
  }
};


const completion = omelette('lorem');

completion.on('$1', ({ reply }) => {
  reply(Object.keys(autocomplete));
});

completion.on('$2', ({ reply, before }) => {
  try {
    reply(Object.keys(autocomplete[before]));
  } catch (e) {}
});

completion.on('$3', ({ reply, before, line }) => {
  const [, lvl1] = line.split(' ');
  try {
    reply(Object.keys(autocomplete[lvl1][before]));
  } catch (e) {}
});

completion.on('$4', ({ reply, before, line }) => {
  const [, lvl1, lvl2] = line.split(' ');
  try {
    reply(Object.keys(autocomplete[lvl1][lvl2][before]));
  } catch (e) {}
});

completion.init();
@f
Copy link
Owner

f commented May 6, 2017

-Out of context-

This tree thingy made me excited! Very nice idea! I wrote a PoC for Omelette to support tree syntax.

Can you check https://github.com/f/omelette/tree/completion-tree#autocompletion-tree?

@f
Copy link
Owner

f commented May 6, 2017

The problem still exists btw, I'll check it out.

@f f closed this as completed May 6, 2017
@f f reopened this May 6, 2017
@f
Copy link
Owner

f commented May 6, 2017

Ups, accidentally closed :)

@jblandry
Copy link
Contributor Author

jblandry commented May 7, 2017

Wow this is way more than I asked for! Works really well and simplifies my implementation. Kudos 👍

@f
Copy link
Owner

f commented May 7, 2017 via email

@jblandry
Copy link
Contributor Author

jblandry commented May 7, 2017

Hell yeah!

@f
Copy link
Owner

f commented May 7, 2017

https://github.com/f/omelette/blob/master/README.md#autocompletion-tree 😍 Thank you @jblandry for this great improvement!

@jblandry
Copy link
Contributor Author

jblandry commented Oct 5, 2017

FYI: The original bug is still there.

@f
Copy link
Owner

f commented Oct 5, 2017

Sorry about it, can you explain the original bug again please?

@jblandry
Copy link
Contributor Author

jblandry commented Oct 6, 2017

Everything is in the first post of this thread :)

@TxHawks
Copy link

TxHawks commented Dec 30, 2018

Just hit this as well.
My workaround is to implement before manually using line, but i'd really rather not to

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

3 participants