Skip to content

Small improvements of completion functions #1203

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

Merged
merged 5 commits into from
Mar 14, 2016
Merged

Small improvements of completion functions #1203

merged 5 commits into from
Mar 14, 2016

Conversation

geraldus
Copy link
Contributor

As a user of company mode I see errors in mini-buffer very often:

Company: An error occurred in auto-begin
Wrong type argument: stringp, nil

Small investigation lead me to proposed changes

Prevent `haskell-utils-repl-response-error-status` and
`haskell-process-get-repl-completions` from trying to split nil-ish
responses, because this yields an error.  Rather return immediately
`'no-error` in response parser and `nil` in completion function.
Prevent `haskell-completions-completion-at-point` from tries of getting
completion candidates for nil prefixes.  Likely this is right way for
this function, moreover passing nil prefix to
`haskell-completions--simple-completions` yields error.
@geraldus geraldus changed the title Small improvements in completion functions Small improvements of completion functions Mar 10, 2016
@gracjan
Copy link
Contributor

gracjan commented Mar 10, 2016

Is there a way to trigger this nil is some kind of test?

@geraldus
Copy link
Contributor Author

@gracjan didn't understood your question well. I've faced the situation, when GHCi fails to start:

The following modules are present in multiple packages:

  • Internal.API (in solitaire-ghcjs-simple, ghcjs-perch-canvas)
  • Internal.FFI (in solitaire-ghcjs-simple, ghcjs-perch-canvas)
  • Internal.Type (in solitaire-ghcjs-simple, ghcjs-perch-canvas)

In this case REPL process is alive, and not marked as restarting and all requests to REPL returns nil. As a consequence, response parser passes this nil value to split-string function which leads to error. I have no strong opinion what to do with nil-ish responses.

Stop static completions to work inside comments and strings (except
pragma comments).  Let other completion function handle this cases, also
keyword candidates are not so useful in comments and string.
@geraldus
Copy link
Contributor Author

Oops. I've found another one bug, force-pushed new changes.

TLDR: first fixes for static completion function added condition case for general type of prefix with nil value associated as result. This was wrong, because instead of just nil value it returned a list of prefix boundaries positions and nil, making impossible other backends to proceed.

@purcell
Copy link
Member

purcell commented Mar 12, 2016

+1 for these fixes: completion-at-point in company is very broken without them. I was about to submit something like 4c6b3ff myself.

@geraldus
Copy link
Contributor Author

@purcell by the way, do you have some special setup for company mode and haskell?

@purcell
Copy link
Member

purcell commented Mar 12, 2016

Not really -- I mostly rely on company-ghci and company-capf in haskell-mode.

@geraldus
Copy link
Contributor Author

@purcell I have found useful to override company-backends in haskell buffers, e.g.

(set (make-local-variable 'company-backends)
       (append '((company-capf company-dabbrev-code) company-dabbrev)
               company-backends))

This combines completions from haskell mode with dabbrev-code completions outside strings and comments (useful for local identifiers defined in where and let blocks) and provides dabbrev completions otherwise. I want to put it in docs.

gracjan added a commit that referenced this pull request Mar 14, 2016
Small improvements of completion functions
@gracjan gracjan merged commit 8a4d424 into haskell:master Mar 14, 2016
@purcell
Copy link
Member

purcell commented Mar 14, 2016

@geraldus Good tip, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants