Skip to content
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

Initial clause is inserted in wrong place for functions with multiline type annotation. #72

Closed
artemkonenko opened this issue Oct 9, 2015 · 4 comments · Fixed by #78
Labels

Comments

@artemkonenko
Copy link

If function has several lines of type annotation then generated initial clause for it should be inserted in the annotation's following line instead the middle of type annotation.

Now it is not.
For example:

addMatrix : Num numType => Vect rows (Vect cols numType)
                           -> Vect rows (Vect cols numType)
                           -> Vect rows (Vect cols numType)

after use ctrl+alt+a:

addMatrix : Num numType => Vect rows (Vect cols numType)
addMatrix xs ys = ?addMatrix_rhs
                           -> Vect rows (Vect cols numType)
                           -> Vect rows (Vect cols numType)
@archaeron archaeron added the bug label Oct 9, 2015
@david-christiansen
Copy link
Member

We used to have this problem in idris-mode for Emacs. Unfortunately, solving it correctly requires a parse tree with good location information, but I put in a hack that mostly works, which is to check the indentation of the name that the command is called on, then insert the body before the next line whose indentation is less than or equal to it.

@david-christiansen
Copy link
Member

Really, though, we should set up Idris's IDE protocol to tell the editor where it goes. Unfortunately, I don't have time for that right now.

@edwinb
Copy link
Contributor

edwinb commented Oct 16, 2015

The vim mode (or rather, the version of the command which updates the file) does this in a differently hacky way, which is simply to put the clause on the next blank line. While this also produces odd results sometimes, at least the most common behaviour is less surprising.

I agree that the right solution is for the protocol to say where to put it. Probably using file location information from the parser.

archaeron added a commit that referenced this issue Oct 17, 2015
@archaeron
Copy link
Member

thanks for reporting the issue @Dummer

and thanks for giving me two alternatives @david-christiansen and @edwinb
I went for the simpler solution at the moment, i.e. searching for the next empty line and inserting the clause there.

I'm happy to change this behaviour if it causes trouble or the compiler tells me where to put it :)

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

Successfully merging a pull request may close this issue.

4 participants