Fix completion of symbols in modules #468
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #455
The reason you don't get a completion when typing a symbol in a module, is because the range from
utop-prompt-max
to(point)
does not match the actual prefix of the completion returned fromutop
. The fix is to set thestart
andend
positions of the completion corresponding to the position of the prefixutop
is actually completing.Before, there was a fix that attempted to fix the same thing with some special logic in the processing of the lines returned from
utop
, but using thecadr
of the split string will not work with more than one level of modules, and even then the range of the completion was not set correctly, leading to the issue. With this fix, we can complete things likeList.<TAB>
, and evenBase.Float.O.<TAB>
.There might be a better way to determine the completion prefix; I'm not experienced enough with OCaml to know if splitting by
.
covers finding the prefix for everything thatutop
can autocomplete, but at least it is a start.I'm also not the most experienced elisp hacker, so if the code is in bad style or there is something I have overlooked, feel free to make suggestions as to how I can improve the fix.