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.

Show-hint does not display suggestions if 'previous' suggestion starts at char 0

See original GitHub issue

I’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 to cursor.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:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marijnhcommented, Nov 20, 2017

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.

0reactions
baoshancommented, Nov 21, 2017

Thanks for the patch! Will do my job in case of anything strange.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Autocomplete does not work for "dot" correctly. #5414 - GitHub
But when I start typing abort... which is the first method suggestion, the other list pops up and replaces all the method list ......
Read more >
CodeMirror editor: show hint after specific key pattern like
I solved it like this.If there is a better suggestion , please post. var editor = CodeMirror.fromTextArea(document.getElementById("code") ...
Read more >
sap,m.Input suggestionRows shows only 100 records.
in ODataModel I have total of around 40000 data. But while suggesting it is picking up only top 100 records. I have already...
Read more >
Building autocomplete with ANTLR and CodeMirror
CodeMirror together with its React wrapper for rendering the code editor input together with the show-hint plugin to display the suggestions.
Read more >
sap.m.Input - API Reference - Demo Kit - SAPUI5 SDK
This event is only fired when showSuggestion is set to true and there are suggestionItems shown in the suggestion popup. Since: 1.16.3. Visibility:...
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