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

Improve fish#Indent(). #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Improve fish#Indent(). #29

wants to merge 1 commit into from

Conversation

Raimondi
Copy link

This PR addresses some problems with the current fish#indent() function:

  • Fix: multiline strings should not be modified.
  • Fix: "end" is always decreased by one.
  • Fix: "case" and "else" are always decreased by one.
  • Fix: continued lines are not treated differently.
  • Fix: "if", "while", etc followed by "begin" should increment next line
    by two instead of by one.
  • Fix: "case" should be one more than "switch".
  • Fix: multiline strings and continued lines are considered in the
    calculations for the next line.

In this gist you can compare the results of using gg=G in a really bad indented fish file with the current and the proposed fish#indent().

@ElijahLynn
Copy link

May I ask what your improvement is? There aren't any comments and the code isn't that self documenting.

- Fix: multiline strings should not be modified.
- Fix: "end" is always decreased by one.
- Fix: "case" and "else" are always decreased by one.
- Fix: continued lines are not treated differently.
- Fix: "if", "while", etc followed by "begin" should increment next line
  by two instead of by one.
- Fix: "case" should be one more than "switch".
- Fix: multiline strings and continued lines are considered in the
  calculations for the next line.
@Raimondi
Copy link
Author

Raimondi commented Jul 2, 2015

My bad, I was too tired when I finished it and created the PR. I have added comments to the code, a more explicit commit message and some text to the PR comment.

@dag
Copy link
Owner

dag commented Nov 22, 2017

I'm trying to work through the PR queue but this is a bit much for me to review at the moment (not having touched vim scripting for years and not having vim, git, fish or vim-fish currently set up).

However, if I remember correctly the idea was you use gq to format larger blocks of code, which will use the native fish_indent program that should probably handle every case correctly. fish#Indent() is meant to handle manual line-by-line input efficiently; is that working for you?

@dag
Copy link
Owner

dag commented Nov 22, 2017

See also the comments on #20. Does your changes work with endwise?

@amiller27
Copy link

@dag Is there any way this could get merged? I tested with endwise and it seems to work. The indent functionality on master is broken for me and this fixes it.

@MindTooth
Copy link

MindTooth commented Feb 15, 2019

Could this be merged if @Raimondi rebased on master? Having the end living its own life is a bit annoying.

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.

5 participants