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

Extra indentation of def when prefixed with "private" #33939

Closed
faustinoaq opened this issue Sep 7, 2017 · 4 comments
Closed

Extra indentation of def when prefixed with "private" #33939

faustinoaq opened this issue Sep 7, 2017 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues verified Verification succeeded

Comments

@faustinoaq
Copy link
Contributor

  • VSCode Version: 1.15.0
  • OS Version: Manjaro KDE Gellivara

Steps to Reproduce:

  1. Open a ruby file.
  2. Ensure autoIndent is enabled.
  3. Write some function with indentation (by example, inside a class), then try to write end keyword

Reproduces without extensions: Yes

Imgur

Imgur

This happen by default in vscode, but other extensions like vscode-ruby and vscode-crystal-lang also have this issue:

@vscodebot vscodebot bot added the new release label Sep 7, 2017
@vscodebot vscodebot bot added the editor label Sep 7, 2017
@alexdima alexdima added the editor-autoindent Editor auto indentation issues label Sep 12, 2017
@alexdima
Copy link
Member

The root cause for this lies within the indentation rules defined for ruby at

https://github.com/Microsoft/vscode/blob/128a4e3640c5375f7b0bc1cfd37f626481b1386f/extensions/ruby/language-configuration.json#L25

I am not really sure how these should be changed to address the problem.

@alexdima alexdima assigned rebornix and unassigned alexdima Sep 12, 2017
@faustinoaq
Copy link
Contributor Author

Hi @rebornix @alexandrudima I did some indentation rules by myself:

I created it for Crystal but is almost the same for Elixir, Ruby, Julia and other similar languages. In fact, currently I'm using Ruby indentation rules for Crystal

indentationRules: {
    // /^[^#]*(
    //       ((
    //         ((if|elsif|lib|fun|module|struct|class|def|macro|do|rescue)\s)|
    //         (end\.)
    //       ).*)|
    //       ((begin|else|ensure|do|rescue)\b)
    //     )
    // $/
    increaseIndentPattern: /^[^#]*(((((if|elsif|lib|fun|module|struct|class|def|macro|do|rescue)\s)|(end\.)).*)|((begin|else|ensure|do|rescue)\b))$/,
    // /^\s*(
    //        ((rescue|ensure|else)\b)|
    //        (elsif\s.*)|
    //        (end(\..*|\b))
    //      )
    // $/
    decreaseIndentPattern: /^\s*(((rescue|ensure|else)\b)|(elsif\s.*)|(end(\..*|\b)))$/
}

It's working a quite well now, but case statement has a new problem with end keyword.

ezgif-3-d16738dbc4

@faustinoaq
Copy link
Contributor Author

Oh, good news @juicemia did a fix for vscode-ruby here 👉 rubyide/vscode-ruby#206

it was easier than I thought 😅

@alexdima alexdima self-assigned this Sep 22, 2017
@alexdima alexdima added the bug Issue identified by VS Code Team member as probable bug label Sep 22, 2017
@alexdima alexdima added this to the September 2017 milestone Sep 22, 2017
@alexdima
Copy link
Member

Thank you @faustinoaq

@roblourens roblourens added the verified Verification succeeded label Sep 29, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants