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
haskell-process-get-repl-completions result contains unnecessary item #776
Comments
@geraldus: Can you reformulate this as a list of todo items (in github use |
Surely, but I want to make this change myself, because in my PR #772 I have already introduced a workaround for this in completion function ( |
As you wish.
I like what you describe, seems good to me, minus one thing: you should not
call `error` as this function will be called async from inside `complete`
backend. It is not great to fail that horribly, but I do not know how to
fail more gracefully.
|
@gracjan this function is synchronous (the command is executed using |
Done in #781 |
The result of GHCi REPL
:complete repl
command always outputs results summary in first line, it is consists of number of showed completions, number of all possible completions and of unused part of string for which completions were searched. E.g.In the example above
2
is a number of returned completions,6
is a number of all completions ("co"
could be completed with 6 unique completions) and"map "
is unused part of string (which was ignored, completions were searched only for"co"
part). In case when completion requested for single word, for example:complete repl "ma"
, an empty string is returned as unused part always.Currently,
haskell-process-get-repl-completions
1 returns mentioned unused part of input string as first element in resulting list:It stores this unused part in
h1
variable. First, REPL response is being split by newlines into a list and stored ins1
. Then it decodes all completions froms1
's tail usinghaskell-string-literal-decode
function (e.g. converts"smth"
to lisp string objectsmth
) and stores this incs
variable. The first line of response (init ofs1
) is stored inh0
variable and the last part of it (that is, unused part of input string) is stored inh1
variable using regular expression andstring-match
function. Finally, if all checks are passed it returns a cons cell ofh1
andcs
, as you can see in source code. So the first item of resulting list is that unused part of input.Firstly, I think this is at least inconvenient with the function name, i.e. unused part of input is not a completion itself, while user may expect that all items in resulting list should be a valid completions for given input. Secondly, if there is no completions available the result should be empty list, while currently it always consists of one element at least. Thirdly, I don't know any use case of this information.
So, I want to fix this by not including unused part of input in results list. Any thoughts?
The text was updated successfully, but these errors were encountered: