f / f/omelette
Change of 'word' breaks 'before' param
- Dominant language
- CoffeeScript
- Stars
- 1.4k
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I tried to switch to 0.4.0 and the change of fetching method for `word` (https://github.com/f/omelette/commit/b74b23209f5b8254f0d28b120fdfbf034086c30c#diff-564d24cceffda49c18bf427e92b8baa3R23) makes the parameter `before` undefined when an incomplete word is tabbed.
Ex:
```
lorem -> a1 b1 👍
lorem a -> a1 👍
lorem a1 -> a2 b2 c2 👍
lorem a1 a -> nothing 👎
```
My script that goes like this
```js
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();
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.