Show-hint does not display suggestions if 'previous' suggestion starts at char 0
See original GitHub issueI’m working on an autocompletion that should complete an object’s properties after pressing the ‘.’ character. In a nutshell, my autocomplete function does the following:
- Take the current line up until the cursor
- If there is no dot character in the line, return a list of first-level properties, with property
from
set to 0 (start of line),end
tocursor.ch
(current cursor position). - If there is a dot character in the line, look up the properties for the object before the dot, return the list with property
from
set to the position of the dot,to
to end of line.
However, when transitioning from the ‘first level’ to ‘second-level’, the suggestions do not pop up. I think I’ve isolated the cause to the result of the previous completion result (from = 0
and the second (from = 3
for example). This issue occurs when fully typing the first string (e.g. foo.
); it does NOT trigger when having selected the foo
suggestion from the list and triggering the autocompletion result.
I have a working (or, not working) example here: http://jsbin.com/kisaxefulo/edit
Expected: type foo.
, get a suggestion list displayed of ‘foo’, ‘bar’ and ‘baz’.
Actual: type foo.
, get nothing. Type foo
, select one option from the list, type .
, and the list is displayed. The list does appear after typing more than 2 characters after the dot, e.g. `foo.bar.
What am I missing? I feel like I’m returning the right object and properties. I did see a function isNewCompletion
(https://github.com/codemirror/CodeMirror/blob/master/addon/hint/show-hint.js#L138) which may be related, but I can’t see the issue myself. The documentation also doesn’t note anything particular about what the hinting function should return in what situations.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
I agree that the code does look very suspicious, and doesn’t seem to help with the original issue. The state management in this plugin is a mess, and should at some point be cleaned up, but for now we can just drop that line and see if anyone complains. See attached patch.
Thanks for the patch! Will do my job in case of anything strange.